Grok Imagine - Text to Image
This page is generated from the upstream official OpenAPI documentation. Endpoints, parameters and examples match the official docs; brand and API domain are replaced with ModelFold.
Endpoint
POST /jobs/createTask
Full URL: https://ai.modelfold.online/v1/jobs/createTask
Authentication: every request must include the
Authorization: Bearer <API_KEY>header.
Query Task Status
After submitting a task, use the unified query endpoint to check progress and retrieve results:
- Get Task Details — Learn how to query task status and retrieve generation results
TIP
For production use, we recommend using the callBackUrl parameter to receive automatic notifications when generation completes, rather than polling the status endpoint.
Related Resources
- Market Overview — Explore all available models
- Common API — Check credits and account usage
Request Parameters
Body (application/json)
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | The model name to use for generation. Required field. - Must be grok-imagine/text-to-image for this endpoint Default:"grok-imagine/text-to-image"。 Allowed values:grok-imagine/text-to-image。 示例:grok-imagine/text-to-image。 |
callBackUrl | string | No | The URL to receive image generation task completion updates. Optional but recommended for production use. - System will POST task status and results to this URL when image generation completes - Callback includes generated image URLs and task information - Your callback endpoint should accept POST requests with JSON payload containing image results - Alternatively, use the Get Task Details endpoint to poll task status - To ensure callback security, see Webhook Verification Guide for signature verification implementation 示例: https://your-domain.com/api/callback。 |
input | object | Yes | Input parameters for the image generation task |
input.prompt | string | Yes | Text prompt describing the desired image. Required field. - Should be detailed and specific about the desired visual elements - Describe composition, style, lighting, mood, and other visual details - Maximum length: 5000 characters - Supports English language prompts 示例: Cinematic portrait of a woman sitting by a vinyl record player, retro living room background, soft ambient lighting, warm earthy tones, nostalgic 1970s wardrobe, reflective mood, gentle film grain texture, shallow depth of field, vintage editorial photography style.。 |
input.aspect_ratio | string | Yes | Required. Aspect ratio of the output image: 2:3, 3:2, 1:1, 16:9, 9:16. Allowed values:2:3 / 3:2 / 1:1 / 16:9 / 9:16。 示例:3:2。 |
input.nsfw_checker | boolean | No | Defaults to false. When false, no additional content filtering is applied and results are returned directly by the model. |
input.enable_pro | boolean | No | Controls the request processing strategy. - false: Corresponds to speed mode. The system prioritizes response time and throughput, suitable for latency-sensitive scenarios. - true: Corresponds to quality mode. The system prioritizes processing quality and precision, suitable for scenarios requiring higher accuracy. |
Request Example
curl -X POST "https://ai.modelfold.online/v1/jobs/createTask" \
-H "Authorization: Bearer $MODELFOLD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine/text-to-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "Cinematic portrait of a woman sitting by a vinyl record player, retro living room background, soft ambient lighting, warm earthy tones, nostalgic 1970s wardrobe, reflective mood, gentle film grain texture, shallow depth of field, vintage editorial photography style.",
"aspect_ratio": "3:2"
}
}'{
"model": "grok-imagine/text-to-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "Cinematic portrait of a woman sitting by a vinyl record player, retro living room background, soft ambient lighting, warm earthy tones, nostalgic 1970s wardrobe, reflective mood, gentle film grain texture, shallow depth of field, vintage editorial photography style.",
"aspect_ratio": "3:2"
}
}Response
200 — Request successful
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_grok_12345678"
}
}Callback
onImageGenerated
Callback URL: {$request.body#/callBackUrl} (the callBackUrl in the request body).
Sent when the task succeeds or fails.
Callback body parameters
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | integer | 否 | 200: success. 501: failure; see data.failCode and data.failMsg. Allowed values:200 / 501。 示例:200。 |
msg | string | 否 | Status message 示例:Playground task completed successfully.。 |
data | object | 否 | — |
data.completeTime | integer | 否 | Task completion time, represented as a Unix timestamp in milliseconds 示例:1786431088000。 |
data.costTime | integer | 否 | Processing time in seconds. Present on both success and failure callbacks. 示例:17。 |
data.createTime | integer | 否 | Task creation time, represented as a Unix timestamp in milliseconds 示例:1786431068000。 |
data.creditsConsumed | number | 否 | Credits consumed by the task; 0 for failed tasks. 示例:4。 |
data.model | string | 否 | Image generation model used for the task 示例:grok-imagine/text-to-image。 |
data.param | string | 否 | Parameters submitted when creating the task, in JSON string format 示例:{"input":"{\"aspect_ratio\":\"3:2\",\"prompt\":\"Cinematic portrait of a woman sitting by a vinyl record player,retro living room background, soft ambient lighting, warm earthy tones, nostalgic 1970s wardrobe, reflective mood, gentle film grain texture,shallow depth of field, vintage editorial photography style.\"}","callBackUrl":"https://your-domain.com/api/callback","model":"grok-imagine/text-to-image"}。 |
data.resultJson | string | 否 | Image generation result in JSON string format. resultUrls contains the list of generated image URLs. Present only when state is success. 示例:{"resultUrls":["https://tempfile.aiquickdraw.com/r/18f680df-66a2-4bab-8f2b-91b77ac31fa8.jpg","https://tempfile.aiquickdraw.com/r/80a6536a-43db-4d93-ba18-342bdb3de36b.jpg"]}。 |
data.state | string | 否 | Task status Allowed values:success / fail。 示例:success。 |
data.taskId | string | 否 | Task ID 示例:91b9645a0c7d7aa063d18918204bd2ad。 |
data.updateTime | integer | 否 | Use completeTime as the completion time; updateTime may equal createTime. 示例:1786431088000。 |
data.failCode | string | 否 | Failure code, a numeric string such as "400" or "500". Present only when state is fail. 示例:500。 |
data.failMsg | string | 否 | Failure reason. Present only when state is fail. 示例:<error detail>。 |
Task completed successfully
{
"code": 200,
"msg": "Playground task completed successfully.",
"data": {
"taskId": "91b9645a0c7d7aa063d18918204bd2ad",
"model": "grok-imagine/text-to-image",
"state": "success",
"param": "{\"input\":\"{\\\"aspect_ratio\\\":\\\"3:2\\\",\\\"prompt\\\":\\\"Cinematic portrait of a woman sitting by a vinyl record player,retro living room background, soft ambient lighting, warm earthy tones, nostalgic 1970s wardrobe, reflective mood, gentle film grain texture,shallow depth of field, vintage editorial photography style.\\\"}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"grok-imagine/text-to-image\"}",
"resultJson": "{\"resultUrls\":[\"https://tempfile.aiquickdraw.com/r/18f680df-66a2-4bab-8f2b-91b77ac31fa8.jpg\",\"https://tempfile.aiquickdraw.com/r/80a6536a-43db-4d93-ba18-342bdb3de36b.jpg\"]}",
"costTime": 17,
"createTime": 1786431068000,
"completeTime": 1786431088000,
"updateTime": 1786431088000,
"creditsConsumed": 4
}
}Task failed
{
"code": 501,
"msg": "Playground task failed.",
"data": {
"taskId": "91b9645a0c7d7aa063d18918204bd2ad",
"model": "grok-imagine/text-to-image",
"state": "fail",
"param": "{\"input\":\"{\\\"aspect_ratio\\\":\\\"3:2\\\",\\\"prompt\\\":\\\"Cinematic portrait of a woman sitting by a vinyl record player,retro living room background, soft ambient lighting, warm earthy tones, nostalgic 1970s wardrobe, reflective mood, gentle film grain texture,shallow depth of field, vintage editorial photography style.\\\"}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"grok-imagine/text-to-image\"}",
"costTime": 17,
"createTime": 1786431068000,
"completeTime": 1786431088000,
"updateTime": 1786431088000,
"creditsConsumed": 0,
"failCode": "500",
"failMsg": "<error detail>"
}
}