Image Generation
Supported Models
| Model | Provider | Max Size | Notes |
|---|---|---|---|
azure/flux-kontext-pro | Azure (FLUX) | 1440x1440 | Flux Kontext Pro, high quality |
google/imagen-4.0 | Google Vertex | 2048x2048 | Google Imagen 4 |
google/imagen-4.0-fast | Google Vertex | 2048x2048 | Faster variant |
google/imagen-4.0-ultra | Google Vertex | 2048x2048 | Highest quality |
bailian/wan2.7-image | Alibaba Bailian | 1024x1024 | Wanxiang image generation |
bailian/wan2.7-image-pro | Alibaba Bailian | 1024x1024 | Pro variant |
azure/mai-image-2 | Azure | 2048x2048 | Microsoft MAI Image 2 |
bedrock/stability-* | Amazon Bedrock | 1024x1024 | Stability AI models |
Text-to-Image
Request
POST https://api.chuizi.ai/v1/images/generations
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | -- | Model name |
prompt | string | Yes | -- | Image description |
size | string | No | "1024x1024" | Image dimensions |
response_format | string | No | "url" | url or b64_json |
Size Options
| Size | Aspect Ratio | Supported Models |
|---|---|---|
1024x1024 | 1:1 (square) | All models |
1792x1024 | 16:9 (landscape) | Most models |
1024x1792 | 9:16 (portrait) | Most models |
2048x2048 | 1: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.
Base64 Response
Set response_format to "b64_json" to receive the image as a base64-encoded string instead of a URL:
config.json
json
{ "model": "azure/flux-kontext-pro", "prompt": "A red sunset over mountains", "response_format": "b64_json" }
Response:
config.json
json
{ "created": 1712000000, "data": [ { "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..." } ] }
Use base64 when you need to process the image immediately without downloading from a URL.
Image Editing
Edit existing images with text instructions using POST /v1/images/edits:
terminal
bash
curl -X POST https://api.chuizi.ai/v1/images/edits \ -H "Authorization: Bearer ck-your-key-here" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen/qwen-image-edit-plus", "image": "iVBORw0KGgo...(base64)", "prompt": "Change the background to a beach sunset", "size": "1024x1024" }'
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model name (must support editing) |
image | string | Yes | Source image as base64, with or without a data:image/...;base64, prefix |
prompt | string | Yes | Editing instruction |
size | string | No | Output size (default: same as input) |
Response
Same format as image generation:
config.json
json
{ "created": 1712000000, "data": [ { "url": "https://media.chuizi.ai/images/gen-xxxxxxxxxxxxxxxx.png" } ] }
Code Examples
example.py
python
from openai import OpenAI import base64 import requests 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 with JSON/base64 with open("photo.png", "rb") as file: image_b64 = base64.b64encode(file.read()).decode("utf-8") edit_response = requests.post( "https://api.chuizi.ai/v1/images/edits", headers={ "Authorization": "Bearer ck-your-key-here", "Content-Type": "application/json", }, json={ "model": "qwen/qwen-image-edit-plus", "image": image_b64, "prompt": "Add a rainbow in the sky", "size": "1024x1024", }, ).json() print(edit_response["data"][0].get("url"))
Tips
- Be specific in prompts. Include style ("watercolor", "photorealistic", "minimalist"), subject, lighting, and composition for better results.
- Use the right size for your use case. Square (1024x1024) for avatars and thumbnails. Landscape (1792x1024) for headers and banners. Portrait (1024x1792) for mobile backgrounds.
- CDN URLs are permanent. Unlike some providers that expire image URLs after 1 hour, Chuizi.AI stores images permanently on R2 CDN. You can reference them directly in your application.
- Image generation is billed per request, not per token. Check the pricing page for per-model costs. Generating 4 images (n=4) costs 4x the single-image price.
- Use
b64_jsonfor server-side processing. If you immediately resize, crop, or transform the image, base64 avoids an extra download step.
Next Steps
- Image Generations API — full API reference
- Image Edits API — background removal, inpainting, and upscaling
- Video Generation — generate videos from text prompts