Text to Image

Generate high-quality images using Jimeng (Dreamina) models based on text prompts.

Endpoint

POST /v1/images/generations

Authentication

All requests require a Bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEY

Request Parameters

ParameterTypeRequiredDescription
modelstringYesModel ID, e.g., jimeng-2.1
promptstringYesText description for image generation
negative_promptstringNoNegative prompt describing unwanted content
nintegerNoNumber of images to generate, default 1
sizestringNoImage size, e.g., 1024x1024, 1280x720
stylestringNoImage style
response_formatstringNoResponse format, options: url, b64_json, default url

Request Example

curl -X POST "https://api.example.com/v1/images/generations" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "jimeng-2.1",
    "prompt": "A beautiful landscape painting with misty mountains",
    "negative_prompt": "blurry, low quality",
    "n": 1,
    "size": "1024x1024"
  }'

Response Example

{
  "created": 1700000000,
  "data": [
    {
      "url": "https://example.com/generated-image.png"
    }
  ]
}

Response Fields

FieldTypeDescription
createdintegerCreation timestamp
dataarrayList of generated images
data[].urlstringImage URL
data[].b64_jsonstringBase64 encoded image