Generate Images
Generate images from text prompts — fully OpenAI Images Generations API compatible (DALL·E 2/3, gpt-image-1, etc.)
Create images from a text prompt. Fully compatible with the OpenAI Images Generations API — supports dall-e-2, dall-e-3, gpt-image-1, and similar models.
| Field | Value |
|---|---|
| Method | POST |
| Path | /v1/images/generations |
| Full URL | https://api.amux.ai/v1/images/generations |
| Auth | Authorization: Bearer <API_TOKEN> |
| Request format | application/json |
| Response format | application/json |
This endpoint is fully aligned with the OpenAI Images Generations protocol. You can use the official OpenAI SDK directly — just override the Base URL and API Key.
Request Body
Prop
Type
Passthrough: amux-api forwards any field not listed above to the upstream as-is. Vendor-specific fields such as watermark / watermark_enabled (Zhipu / Aliyun Tongyi), user_id (Aliyun), and extra_body (channel-private params used by Gemini Nano Banana for aspect_ratio / image_size / seed) are recognized and routed to the appropriate channels.
Examples
curl https://api.amux.ai/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AMUX_API_KEY" \
-d '{
"model": "gpt-image-1",
"prompt": "A cute baby sea otter wearing a beret, watercolor style",
"n": 1,
"size": "1024x1024",
"quality": "high",
"background": "transparent",
"output_format": "png"
}'import os
import base64
from openai import OpenAI
client = OpenAI(
base_url="https://api.amux.ai/v1",
api_key=os.environ["AMUX_API_KEY"],
)
response = client.images.generate(
model="gpt-image-1",
prompt="A cute baby sea otter wearing a beret, watercolor style",
n=1,
size="1024x1024",
quality="high",
)
image_b64 = response.data[0].b64_json
with open("otter.png", "wb") as f:
f.write(base64.b64decode(image_b64))import { writeFileSync } from 'node:fs';
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.amux.ai/v1',
apiKey: process.env.AMUX_API_KEY,
});
const response = await client.images.generate({
model: 'gpt-image-1',
prompt: 'A cute baby sea otter wearing a beret, watercolor style',
n: 1,
size: '1024x1024',
quality: 'high',
});
const b64 = response.data![0].b64_json!;
writeFileSync('otter.png', Buffer.from(b64, 'base64'));Response Example
{
"created": 1730000000,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAA...",
"revised_prompt": "A watercolor illustration of a cute baby sea otter wearing a beret..."
}
],
"usage": {
"total_tokens": 1234,
"input_tokens": 28,
"output_tokens": 1206,
"input_tokens_details": {
"text_tokens": 28,
"image_tokens": 0
}
}
}Response Fields
Prop
Type
ImageData Fields
Prop
Type
Error Response
{
"error": {
"message": "...",
"type": "invalid_request_error",
"param": "prompt",
"code": "invalid_value"
}
}| HTTP Status | Meaning |
|---|---|
200 | Success |
400 | Bad request parameters (missing prompt, unsupported size, etc.) |
401 | Missing or invalid API key |
403 | Model not authorized or blocked by content safety policy |
404 | Model not found |
429 | Rate limit triggered or insufficient balance |
500 / 502 / 503 | Server-side error or upstream unavailable |