API 参考
GPT Image-2 API
在 Xenodia 使用 `gpt-image-2` 进行 prompt-only 和 reference-image generation。
gpt-image-2 使用 shared image endpoint:
POST https://api.xenodia.xyz/v1/images/generationsXenodia 暴露一个 public model ID。Prompt-only 和带 reference image 的请求会自动路由。
Prompt-only request
{
"model": "gpt-image-2",
"prompt": "A crisp technical illustration of an AI gateway routing model calls.",
"aspect_ratio": "16:9",
"resolution": "2K",
"response_format": "url"
}Reference-image request
{
"model": "gpt-image-2",
"prompt": "Use the reference as the product shape and render it in a clean studio.",
"image_input": [
"https://example.com/reference.png"
],
"response_format": "url"
}Multipart file reference:
curl -X POST "https://api.xenodia.xyz/v1/images/generations" \
-H "Authorization: Bearer $XENODIA_API_KEY" \
-F "model=gpt-image-2" \
-F "prompt=Use the uploaded reference as the product shape." \
-F "response_format=url" \
-F "image=@./reference.png"Current public rules
reference_input.max_items = 16
accepted_mime = image/jpeg, image/png, image/webp
max_size_per_file_bytes = 31457280
response_format = urlParameters
| Field | Notes |
|---|---|
model | 必须是 gpt-image-2。 |
prompt | 必填文本 prompt。 |
image_input | 可选 reference image input。存在 reference 时会触发 reference-image mode。 |
image / image[] | 可选 multipart reference file fields。 |
aspect_ratio | 当前值包括 auto、1:1、9:16、16:9、4:3、3:4。 |
resolution | 可选:1K、2K、4K。aspect_ratio: auto 时只允许 1K,aspect_ratio: 1:1 不能与 4K 一起使用。 |
output_format | Xenodia 上的 GPT Image-2 当前不支持。 |
async | 设置 true 后返回 202 task envelope。 |
Responses and errors
Sync 返回 200 和 data[].url。Async 返回 202 和 task_id、state、poll_url。使用 Task Retrieval 轮询。
常见错误:400 参数无效,401 key 缺失或无效,402 billing boundary,502 generation failure。