API ドキュメント

API リファレンス

統合のためのドキュメント

REST API
JSON レスポンス
動画生成

認証

Bearer Token 認証

Authorization: Bearer your-api-token-here

セキュリティ: 公開厳禁

ベース URL

リクエスト先:

https://grokimagineapi.com

API エンドポイント

POST

動画生成

/v1/generate

動画を作成

リクエストボディ

{
  "mode": "fun",
  "prompt": "a beautiful landscape with mountains",
  "images": ["https://example.com/image.png"],
  "ratio": "1:1"
}

パラメータ

パラメータタイプ説明
modestringモード
promptstringプロンプト
imagesstring?画像
ratiostring比率
💰 Pricing

Each generation consumes 40 credits, approximately 0.4 USD

レスポンス

{
  "code": 200,
  "message": "success",
  "data": {
    "task_id": "task_123456789"
  }
}
cURL Example
curl -X POST https://grokimagineapi.com/v1/generate \
  -H "Authorization: Bearer your-api-token" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "fun",
    "prompt": "a beautiful landscape with mountains",
    "ratio": "1:1"
  }'
GET

ステータス確認

/v1/status?task_id=xxxx

状況を確認

クエリパラメータ

GET リクエストを使用 task_id=xxxx

Response

{
  "code": 200,
  "message": "success",
  "data": {
    "consumed_credits": 40,
    "created_at": "2024-01-01T00:00:00Z",
    "status": "completed",
    "task_id": "task_123456789",
    "error_message": null,
    "request": {
      "mode": "fun",
      "prompt": "a beautiful landscape with mountains",
      "ratio": "1:1"
    },
    "response": [
      "https://cdn.example.com/generated/video1.mp4",
      "https://cdn.example.com/generated/video2.mp4"
    ]
  }
}
フィールド説明
  • consumed_credits: 消費ポイント
  • created_at: 作成日時
  • status: ステータス
  • task_id: タスク ID
  • error_message: Error details if the task failed. Examples: 'File type not supported', 'Inappropriate content, please try another prompt.', 'grok imagine build failed', 'Network error, please try again later.'
  • request: リクエスト
  • response: レスポンス
cURL Example
curl -X GET "https://grokimagineapi.com/v1/status?task_id=task_123456789" \
  -H "Authorization: Bearer your-api-token"

エラー処理

エラーコード

HTTP コード

200OK
400Bad Request
401Unauthorized
429Rate Limited
500Server Error

形式

{
  "code": 400,
  "message": "Invalid request: The prompt parameter is required",
  "error": "INVALID_REQUEST"
}

ベストプラクティス: 適切に処理

レート制限

100
回/分
無料
1000
requests/minute
Pro
5000
requests/minute
企業

制限ヘッダー: X-RateLimit-Remaining と X-RateLimit-Reset

準備完了?

キーを取得