Image Generation

Supported Models

ModelProviderMax SizeNotes
azure/flux-kontext-proAzure (FLUX)1440x1440Flux Kontext Pro, high quality
azure/flux-2-proAzure (FLUX)1440x1440Flux 2 Pro
google/imagen-4.0Google Vertex2048x2048Google Imagen 4
google/imagen-4.0-fastGoogle Vertex2048x2048Faster variant
google/imagen-4.0-ultraGoogle Vertex2048x2048Highest quality
bailian/wan2.7-imageAlibaba Bailian1024x1024Wanxiang image generation
bailian/wan2.7-image-proAlibaba Bailian1024x1024Pro variant
azure/mai-image-2Azure2048x2048Microsoft MAI Image 2
bedrock/stability-*Amazon Bedrock1024x1024Stability AI models

Text-to-Image

Request

POST https://api.chuizi.ai/v1/images/generations

Parameters

ParameterTypeRequiredDefaultDescription
modelstringYes--Model name
promptstringYes--Image description
sizestringNo"1024x1024"Image dimensions
nintegerNo1Number of images (1-4)
response_formatstringNo"url"url or b64_json

Size Options

SizeAspect RatioSupported Models
1024x10241:1 (square)All models
1792x102416:9 (landscape)Most models
1024x17929:16 (portrait)Most models
2048x20481:1 (large square)Imagen, MAI Image

Example

terminal
bash
curl -X POST https://api.chuizi.ai/v1/images/generations \
  -H "Authorization: Bearer ck-your-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "azure/flux-kontext-pro",
    "prompt": "A minimalist logo design for a coffee shop called 'Morning Brew', clean lines, warm colors",
    "size": "1024x1024",
    "n": 1
  }'

Response

config.json
json
{
  "created": 1712000000,
  "data": [
    {
      "url": "https://media.chuizi.ai/images/gen-xxxxxxxxxxxxxxxx.png"
    }
  ],
  "x_chuizi": {
    "generation_id": "gen-xxxxxxxxxxxxxxxx",
    "cost": "0.05000000",
    "latency_ms": 8500
  }
}

The url is a permanent link hosted on the R2 CDN. It does not expire.

Code Examples

example.py
python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.chuizi.ai/v1",
    api_key="ck-your-key-here",
)

# Generate an image
response = client.images.generate(
    model="azure/flux-kontext-pro",
    prompt="A futuristic cityscape at night, neon lights, cyberpunk style, detailed",
    size="1792x1024",
    n=1,
)
print(f"Image URL: {response.data[0].url}")

# Generate multiple images
response = client.images.generate(
    model="google/imagen-4.0-fast",
    prompt="A watercolor painting of a mountain lake at sunrise",
    size="1024x1024",
    n=4,
)
for i, image in enumerate(response.data):
    print(f"Image {i + 1}: {image.url}")

# Edit an existing image
response = client.images.edit(
    model="azure/flux-kontext-pro",
    image=open("photo.png", "rb"),
    prompt="Add a rainbow in the sky",
    size="1024x1024",
)
print(f"Edited image: {response.data[0].url}")

Next Steps