Skip to content

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.

Request Parameters ​

Body (application/json) ​

ParameterTypeRequiredDescription
modelstringYesThe 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。
callBackUrlstringNoThe 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。
inputobjectYesInput parameters for the image generation task
  input.promptstringYesText 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_ratiostringYesRequired. 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_checkerbooleanNoDefaults to false. When false, no additional content filtering is applied and results are returned directly by the model.
  input.enable_probooleanNoControls 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 ​

bash
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"
  }
}'
json
{
  "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 ​

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

参数类型必填说明
codeinteger否200: success. 501: failure; see data.failCode and data.failMsg. Allowed values:200 / 501。 示例:200。
msgstring否Status message 示例:Playground task completed successfully.。
dataobject否—
  data.completeTimeinteger否Task completion time, represented as a Unix timestamp in milliseconds 示例:1786431088000。
  data.costTimeinteger否Processing time in seconds. Present on both success and failure callbacks. 示例:17。
  data.createTimeinteger否Task creation time, represented as a Unix timestamp in milliseconds 示例:1786431068000。
  data.creditsConsumednumber否Credits consumed by the task; 0 for failed tasks. 示例:4。
  data.modelstring否Image generation model used for the task 示例:grok-imagine/text-to-image。
  data.paramstring否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.resultJsonstring否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.statestring否Task status Allowed values:success / fail。 示例:success。
  data.taskIdstring否Task ID 示例:91b9645a0c7d7aa063d18918204bd2ad。
  data.updateTimeinteger否Use completeTime as the completion time; updateTime may equal createTime. 示例:1786431088000。
  data.failCodestring否Failure code, a numeric string such as "400" or "500". Present only when state is fail. 示例:500。
  data.failMsgstring否Failure reason. Present only when state is fail. 示例:&lt;error detail&gt;。

Task completed successfully

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

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

ModelFold — one API for all the best AI models.