API Documentation
GrokImagine API Reference
Complete API documentation for integrating GrokImagine AI into your applications.
REST API
JSON Responses
Video Generation
Authentication
GrokImagine API uses Bearer Token authentication.
Authorization: Bearer your-api-token-here
Security Note: Never expose your API token in client-side code.
Base URL
All API requests should be made to:
https://grokimagineapi.com
API Endpoints
POST
Generate Video
/v1/generateGenerate videos from text props.
Request Body
{
"mode": "fun",
"prompt": "a beautiful landscape with mountains",
"images": ["https://example.com/image.png"],
"ratio": "1:1"
}Parameters
| Parameter | Type | Description |
|---|---|---|
| mode | string | Mode |
| prompt | string | Prompt |
| images | string? | Images |
| ratio | string | Ratio |
💰 Pricing
Each generation consumes 40 credits, approximately 0.4 USD
Response
{
"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
Get Task Status
/v1/status?task_id=xxxxCheck task status.
Query Parameters
Use GET request 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"
]
}
}Response Fields
- consumed_credits: Credits
- created_at: Created at
- status: Status
- task_id: Task 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: Request
- response: Response
cURL Example
curl -X GET "https://grokimagineapi.com/v1/status?task_id=task_123456789" \ -H "Authorization: Bearer your-api-token"
Error Handling
Error codes.
HTTP Codes
200OK
400Bad Request
401Unauthorized
429Rate Limited
500Server Error
Error Format
{
"code": 400,
"message": "Invalid request: The prompt parameter is required",
"error": "INVALID_REQUEST"
}Best Practice: Handle errors.
Rate Limits
100
req/min
Free
1000
requests/minute
Pro
5000
requests/minute
Enterprise
Rate Limit Headers: Headers X-RateLimit-Remaining and X-RateLimit-Reset