Grok 5 Imagine Generation
API Documentation
Use these endpoints to submit Grok 5 Imagine jobs and check their status. Each call spends credits based on the model used.
Authentication
All requests must include your API key inside the Authorization header:
Authorization: Bearer <YOUR_API_KEY>Missing or invalid keys return 401 Unauthorized.
POST
https://grok5imagine.com/api/generate
Create generation task
Submits a new Grok 5 Imagine job. The call immediately returns a task_id while the render completes asynchronously.
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | No | Model to use: grok-imagine/text-to-image (default), text-to-video, image-to-video, or upscale. |
| input | object | Yes | Input parameters object containing prompt, image_urls, or task_id based on model. |
| input.prompt | string (max 5000 chars) | No | Text prompt describing what to generate (required for text-to-image and text-to-video). |
| input.image_urls | string[] | No | Array of image URLs (required for image-to-video). |
| input.task_id | string | No | Previous task ID for upscale or image-to-video generation. |
| callback_url | string | No | Webhook URL to receive task completion notifications. |
| public | boolean | No | Expose the task to public galleries. |
Credit consumption
Credits deduct when the task is created. Failed jobs are automatically refunded.
| Model | Credits deducted |
|---|---|
| grok-imagine/text-to-image | 5 |
| grok-imagine/text-to-video | 24 |
| grok-imagine/image-to-video | 24 |
| grok-imagine/upscale | 12 |
Sample request
{
"model": "grok-imagine/text-to-image",
"input": {
"prompt": "A majestic dragon flying over a neon-lit cyberpunk city"
}
}Sample response
{
"code": 200,
"message": "success",
"data": {
"task_id": "n31b6d54c8f4b4c4e8kie",
"status": "IN_PROGRESS"
}
}GET / POST
https://grok5imagine.com/api/status
Check task status
Use this endpoint to poll the latest record. When the task is still IN_PROGRESS we query the provider once more before replying.
| Parameter | Type | Required | Description |
|---|---|---|---|
| task_id | string | Yes | ID returned by /generate. Send via query (?task_id=) or JSON body. |
| Field | Description |
|---|---|
| task_id | ID returned from /generate. |
| status | SUCCESS |
| request | Sanitized copy of the submitted payload. |
| response | Object containing resultUrls array when status is SUCCESS. |
| consumed_credits | Credits charged for the task (0 when refunded). |
| error_message | Provider error when status is FAILED. |
| created_at | UTC timestamp when the job was stored. |
Sample request
GET https://grok5imagine.com/api/status?task_id=n31b6d54c8f4b4c4e8kie
Authorization: Bearer <YOUR_API_KEY>
# or POST
POST https://grok5imagine.com/api/status
Authorization: Bearer <YOUR_API_KEY>
Content-Type: application/json
{
"task_id": "n31b6d54c8f4b4c4e8kie"
}Sample response
{
"code": 200,
"message": "success",
"data": {
"task_id": "n31b6d54c8f4b4c4e8kie",
"status": "SUCCESS",
"request": {
"model": "grok-imagine/text-to-image",
"input": {
"prompt": "A majestic dragon flying over a neon-lit cyberpunk city"
}
},
"response": {
"resultUrls": [
"https://static.gogloai.com/grok-imagine/image_001.png"
]
},
"consumed_credits": 5,
"error_message": null,
"created_at": "2025-06-14T05:21:11Z"
}
}Error handling
401 Unauthorized- Missing or invalid API key.402 Payment Required- Credit balance could not cover the deduction.429 Too Many Requests- Reduce the polling cadence or request rate.500- Transient issue; retry with exponential backoff.