Documentation API

Référence API

Documentation pour intégration

API REST
Réponses JSON
Génération vidéo

Authentification

Bearer Token

Authorization: Bearer your-api-token-here

Sécurité: Ne pas exposer

URL de base

Requêtes vers :

https://grokimagineapi.com

Points API

POST

Générer vidéo

/v1/generate

Création vidéo

Corps

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

Paramètres

ParamètreTypeDescription
modestringMode
promptstringPrompt
imagesstring?Images
ratiostringRatio
💰 Pricing

Each generation consumes 40 credits, approximately 0.4 USD

Réponse

{
  "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

Statut tâche

/v1/status?task_id=xxxx

Vérifier statut

Paramètres

Requête 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"
    ]
  }
}
Champs réponse
  • consumed_credits: Crédits
  • created_at: Créé le
  • status: Statut
  • task_id: ID tâche
  • 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: Requête
  • response: Réponse
cURL Example
curl -X GET "https://grokimagineapi.com/v1/status?task_id=task_123456789" \
  -H "Authorization: Bearer your-api-token"

Gestion erreurs

Codes

Codes HTTP

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

Format

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

Pratique: Gérer erreurs

Limites

100
req/min
Gratuit
1000
requests/minute
Pro
5000
requests/minute
Entreprise

En-têtes limites : En-têtes X-RateLimit-Remaining et X-RateLimit-Reset

Prêt ?

Clé API