GenAnh GenAnh
Toggle sidebar
GenAnh
GenAnh
Create image
Quick Creator Studio
Appearance
Light
Dark
System
VI
Tiếng Việt
User guide
For developers

Create images through the API

Generate a key, send a secure request, and understand quota and error responses.

POST /api/ai/images Bearer token Quota aware
01
Generate and protect your API key

Open Account, then API key. Each account has one active key. Regenerating invalidates the previous token immediately while preserving usage statistics.

  • Send the token only in the Authorization header.
  • Never place an API key in browser code, screenshots, or a public repository.
02
Send a generation request

Use JSON for prompt-only requests or multipart form data when you include reference images. Requests are accepted only through the API subdomain. The prompt is required and accepts up to 2,000 characters.

  • POST /api/ai/images creates a private image.
  • POST /api/ai/images/publish creates and publishes the result.
  • Image API requests are synchronous. Concurrent requests share the account limit, and HTTP 409 responses do not consume quota.
03
Read quota and request logs

API quota is separate from daily web quota. One quota is charged only after a successful generation. Validation, moderation, quota, and provider failures do not consume it.

  • Use the latest request logs to diagnose status codes and duration.
  • Regenerating a token does not reset quota or logs.
04
Handle errors by status code

Treat 401 as an invalid key, 403 as a blocked account, 422 as invalid or rejected input, 429 as exhausted quota, and 503 as a temporary review failure.

  • Do not retry 401, 403, 422, or 429 without correcting the cause.
  • Use bounded retries with backoff for temporary 503 or network failures.

Working cURL example

Replace the placeholder token and local image path before running this request.

POST /api/ai/images multipart/form-data
curl -X POST https://api.genanh.com/api/ai/images \
  -H "Authorization: Bearer genanh_xxx" \
  -F "prompt=A cinematic product photo with soft studio lighting" \
  -F "model=cx/gpt-5.5-image" \
  -F "images[]=@/path/to/reference.jpg"
Protect the token
The example uses a placeholder. Keep the real key in a server-side secret manager or environment variable, never in client-side code.
API key settings with masked key, quota, statistics, and logs

API key settings: keep credentials hidden while monitoring usage.

  1. 1 Reveal or copy the key only when you are ready to store it securely.
  2. 2 Check used and remaining lifetime API quota.
  3. 3 Review recent request status, duration, and safe error summaries.
Ready for the next step?
Put the guide into practice, or continue with the next topic when you need a deeper workflow.
Read common questions
Quick Edit

Upload references, let GenAnh suggest the best edit, then review the prompt.

0/5

Reference images
Paste image
Uploading image...
Create image

0/5

Reference images
Paste image
Uploading image...
Prompt
Translate prompt to Vietnamese
Image to prompt
Rewrite prompt
Rewrite prompt

Tell AI how to rewrite your current prompt.

Rewrite instruction
Uploading image...
Analyzing image...
Translating prompt...
GPT Image 2
Auto
1:1 Square
3:4 Portrait
4:5 Portrait
2:3 Tall
9:16 Vertical
4:3 Landscape
3:2 Wide
16:9 Widescreen
1K

Recommended for most use cases

2K

Higher detail, balanced

4K

Maximum resolution

To process this request, GenAnh sends your prompt and any images you upload or select to a third-party AI image service. That can include faces or likenesses visible in those photos. Data is used only to generate or edit the image you asked for.

I allow GenAnh to send my prompt and uploaded images to the third-party AI image service for this request.

Details are in the Privacy Policy sections “Third-party AI image processing” and “Face data in uploaded photos”.