Skip to content

Qwen 2.1 - 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 generation task.

Request Parameters ​

Body (application/json) ​

ParameterTypeRequiredDescription
modelstringYesThe model name used for generation. This endpoint must use qwen2-1/text-to-image. Default:"qwen2-1/text-to-image"。 Allowed values:qwen2-1/text-to-image。 Example:qwen2-1/text-to-image。
promptstringYesPrompt required by the ModelFold gateway; at most 2000 characters. The prompt that describes the image content, style and composition you want to generate. Required. Any language is supported, up to 5000 characters; if it is longer, the request is rejected. minLength: 1. maxLength: 2000. Example:A corgi wearing a yellow rain hat sitting on stone steps after the rain, shallow depth of field。
aspect_ratiostringNoThe output aspect ratio. Default 1:1. The actual pixel size also depends on resolution. Default:"1:1"。 Allowed values:1:1 / 4:3 / 3:4 / 3:2 / 2:3 / 16:9 / 9:16 / 21:9 / 9:21。 Example:1:1。
resolutionstringNoThe output resolution tier. 1K is the faster option; 2K produces four times the pixels and takes longer. Only 1K and 2K are accepted — with any other value, including 4K, the request is rejected. Default:"1K"。 Allowed values:1K / 2K。 Example:1K。
backgroundstringNoBackground type. transparent outputs a PNG or WebP with a real alpha channel and cannot be used with JPEG. When using transparent, describe only the subject — prompts that mention a background, scene, surface, etc. may produce a non-transparent result. Default:"opaque"。 Allowed values:opaque / transparent。 Example:opaque。
output_formatstringNoThe output image format. png (default) and webp both carry an alpha channel and can be used with background: transparent. jpeg has no alpha channel and cannot be combined with a transparent background. Default:"png"。 Allowed values:png / webp / jpeg。 Example:png。
enhance_promptbooleanNoRewrites the prompt into a fuller scene description before generating, which noticeably improves quality. Enabled by default (also when the parameter is omitted); pass false to turn it off. Default:true。 Example:false。
seedintegerNoThe random seed. Omit it to generate with a random seed. Passing the same seed together with the same prompt and parameters reproduces the same image within the same service version. Example:20260921。
nsfw_checkerbooleanNoDefaults to false. When false, no additional content filtering is applied and results are returned directly by the model.

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": "qwen2-1/text-to-image",
  "prompt": "A corgi wearing a yellow rain hat sitting on stone steps after the rain, shallow depth of field",
  "aspect_ratio": "1:1",
  "resolution": "1K",
  "background": "opaque",
  "output_format": "png",
  "enhance_prompt": true
}'
json
{
  "model": "qwen2-1/text-to-image",
  "prompt": "A corgi wearing a yellow rain hat sitting on stone steps after the rain, shallow depth of field",
  "aspect_ratio": "1:1",
  "resolution": "1K",
  "background": "opaque",
  "output_format": "png",
  "enhance_prompt": true
}

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.