Skip to content

Grok Imagine Image 2.0 Text To Image ​

Endpoint ​

POST /images/generations

Full URL: https://modelfold.ai/v1/images/generations

Authentication: every request must include the Authorization: Bearer <API_KEY> header.

Send model parameters directly in the JSON body. Do not wrap them in input. This request waits for generation to finish and returns data[].url; supported media models also offer async jobs, polling and callbacks. Replace example media URLs with your own publicly accessible files. See API gateway for billing and errors.

Input parameters for the image generation task.

Request Parameters ​

Body (application/json) ​

ParameterTypeRequiredDescription
modelstringYesThe model name used for generation. This field is required. This endpoint must use the grok-imagine-image-2-0/text-to-image model. Default:"grok-imagine-image-2-0/text-to-image"。 Allowed values:grok-imagine-image-2-0/text-to-image。 Example:grok-imagine-image-2-0/text-to-image。
promptstringYesPrompt required by the ModelFold gateway; at most 2000 characters. Text prompt describing the desired image. This field is required. Up to 8,000 characters. maxLength: 2000. Example:A small wooden cabin beside a calm lake at sunrise, soft mist over the water。
aspect_ratiostringYesSpecifies the width-to-height ratio of the generated image. Controls the aspect ratio of the output. This field is required. Allowed values:1:1 / 2:3 / 3:2 / 16:9 / 9:16。 Example:1:1。

Request Example ​

bash
curl -X POST "https://modelfold.ai/v1/images/generations" \
  -H "Authorization: Bearer $MODELFOLD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "grok-imagine-image-2-0/text-to-image",
  "prompt": "A small wooden cabin beside a calm lake at sunrise, soft mist over the water",
  "aspect_ratio": "1:1"
}'
json
{
  "model": "grok-imagine-image-2-0/text-to-image",
  "prompt": "A small wooden cabin beside a calm lake at sunrise, soft mist over the water",
  "aspect_ratio": "1:1"
}

Response ​

200 — Generation completed. usage contains actual billing details; result URLs are illustrative. ​

json
{
  "ok": true,
  "created": 1792134000,
  "data": [
    {
      "url": "https://modelfold.ai/uploads/outputs/result.png"
    }
  ],
  "usage": {}
}

ModelFold — one API for all the best AI models.