Image generation API
Generate one image with GPT Image 2 through the CHUA ONE image generation endpoint.
POST /v1/images/generations
Authorization: Bearer $CHUA_API_KEY— project API keyContent-Type: application/jsonIdempotency-Key— a unique value for every new request; reuse it only when retrying the same request
curl -i 'https://chuaone.si/v1/images/generations' \
-H "Authorization: Bearer $CHUA_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: YOUR_UNIQUE_REQUEST_ID' \
-d '{"model":"gpt-image-2","prompt":"A blue ceramic teapot on a white background","n":1,"size":"1024x1024","quality":"low"}'Request fields
model- Required. Use gpt-image-2 for this guide; the key must allow it.
prompt- Required text, from 1 to 800 characters.
n- One image is supported; use 1.
size/quality- GPT Image 2 accepts 1024x1024 and low on this route.
Response fields
The response contains exactly one base64-encoded image in data[0].b64_json, plus size and token usage. Decode the base64 string to save the image. Keep the X-CHUA-Request-ID response header as the request receipt.
Common errors
KEY_INVALID- The key is invalid, expired or revoked.
MODEL_UNAVAILABLE/MODEL_NOT_ALLOWED- The model is not published, ready, or allowed for this key.
RATE_LIMIT- The key reached its request limit. Follow retryAfterSeconds when returned.
CUSTOMER_INFERENCE_DISABLED- Requests are temporarily unavailable. Check the service status before retrying.
Troubleshoot and decide when to retry · Check usage and charges