Skip to content

GPT Image-2 - 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 text-to-image task.

Request Parameters ​

Body (application/json) ​

ParameterTypeRequiredDescription
modelstringYesThe model name used for generation. This field is required. This endpoint must use the gpt-image-2-text-to-image model. Default:"gpt-image-2-text-to-image"。 Allowed values:gpt-image-2-text-to-image。 Example:gpt-image-2-text-to-image。
promptstringYesPrompt required by the ModelFold gateway; at most 2000 characters. Text prompt. Required, maximum 20,000 characters. minLength: 1. maxLength: 2000. Example:A cinematic night city poster with neon reflections on a rainy street.。
aspect_ratiostringNoThe aspect ratio of the generated image is set to auto by default.
Note: for 2K resolution, the following aspect ratios are not supported: 5:4, 4:5, 3:1, 1:3, and 9:21.
for 4K resolution, the following aspect ratios are not supported: 3:1, 1:3, and 9:21. Allowed values:auto / 1:1 / 3:2 / 2:3 / 4:3 / 3:4 / 5:4 / 4:5 / 16:9 / 9:16 / 2:1 / 1:2 / 3:1 / 1:3 / 21:9 / 9:21。 Example:auto。
resolutionstringNoOutput resolution: 1K, 2K or 4K. Set this field explicitly. 2K does not support 5:4, 4:5, 3:1, 1:3 or 9:21; 4K does not support 3:1, 1:3 or 9:21. The background parameter is only available at 1K. Allowed values:1K / 2K / 4K。 Example:1K。
backgroundstringNoImage background
Note: This parameter is only supported when the resolution is 1K. Allowed values:transparent / opaque / auto。 Example:transparent。

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": "gpt-image-2-text-to-image",
  "prompt": "A cinematic night city poster with neon reflections on a rainy street."
}'
json
{
  "model": "gpt-image-2-text-to-image",
  "prompt": "A cinematic night city poster with neon reflections on a rainy street."
}

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.