Image generation API (images/generations)
Generate and edit images with POST /v1/images/generations and the OpenAI SDK: automatic model picking, reference images, aspect ratio, URL or base64.
Updated: 4 Oct 2026
POST /v1/images/generations has OpenAI's shape, so client.images.generate works unchanged. The answer is synchronous: the request stays open until the image exists (usually seconds, at most about a minute).
Python
from openai import OpenAI
client = OpenAI(base_url="https://api.uttapen.ir/v1", api_key="sk-up-...")
img = client.images.generate(
model="uttapen/auto-image", # or a specific model, e.g. bytedance-seed/seedream-4.5
prompt="a café poster with the words 'Morning Coffee' on a brick wall, warm light",
n=1,
)
print(img.data[0].url) # a signed link, valid for 24 hours
Node
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.uttapen.ir/v1", apiKey: "sk-up-..." });
const img = await client.images.generate({ model: "uttapen/auto-image", prompt: "a ceramic cup on a wooden table, soft light" });
console.log(img.data[0].url);
Editing from a reference image
Send one or more images (up to 4, 10 MB each) in image or images, as an https URL or a data:image/…;base64 URI. With uttapen/auto-image, an attached image routes the request to an editing model. A model without image input answers 400 with param: "images".
img = client.images.generate(
model="uttapen/auto-image",
prompt="make the background a beach at sunset",
extra_body={"image": "https://example.com/product.jpg"},
)
Fields
| Field | Meaning |
|---|---|
model | a model id; empty or uttapen/auto-image means automatic picking |
prompt | up to 4,000 characters, Persian or English |
n | number of images, 1 to 4 |
size / aspect_ratio / resolution / quality | e.g. 1024x1024, 16:9, 2K, high; each model supports a subset |
output_format | png, jpeg, webp |
response_format | url (default) or b64_json |
image / images | reference images for an edit |
Answer
{
"created": 1791071431,
"model": "bytedance-seed/seedream-4.5",
"data": [{ "url": "https://api.uttapen.ir/v1/files/…/content?exp=…&sig=…", "mime_type": "image/png", "expires_at": "…" }],
"uttapen": {
"id": "01a1042d-…",
"status": "completed",
"cost_toman": "11605.000000",
"hold_toman": "26186.439266",
"requested_model": "uttapen/auto-image",
"auto": { "intent": "photoreal", "reason": "…", "classifier": "llm" },
"classifier_cost_toman": "11.227838"
}
}
cost_toman is the final cost of this run; hold_toman is the hold that was released straight away. If your connection drops, the run still finishes and the result is available from GET /v1/uttapen/media/{id} (the id is in the X-Uttapen-Media-Id header).
Price
Each model's per-image price is on its page under image models. The final charge is what the model maker reports for that image; a failed run, or one that delivers no image, costs nothing. Billing and file retention are covered in the media overview.
Sign up with a phone number, top up your wallet from 100,000 toman and create a key. Free models work without a top-up — up to 50 requests a day. Create an API key →