API REFERENCE
图像生成
使用与 OpenAI 兼容的统一端点生成和编辑图像,该端点可扇出到 Flux、Nano-Banana、Wan 等。
POST /v1/images/generations
与 OpenAI 直接兼容 images.generate SDK。特定于提供者的参数与标准参数并存——后端转发每个模型理解的内容。
POST
https://api.airforce/v1/images/generations图像模型
…· live常用参数
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | Image model ID. Filter /v1/models by output_modalities.includes("image"). |
| prompt | string | Required | Image description. |
| n | integer | Optional | Number of variations to generate per request. Capped by the model's image_caps.max_n. |
| size | string | Optional | OpenAI-style WxH, e.g. "1024x1024". Provider-specific values pass through. |
| aspect_ratio | string | Optional | Alternative to size. "16:9", "1:1", "9:16", … Validated against image_caps.aspect_ratios. |
| quality | string | Optional | "standard" | "hd" (OpenAI) or model-specific labels. Validated. |
| response_format | string | Optional | "url" (default) or "b64_json". |
| seed | integer | Optional | Reproducibility seed. Same prompt + same seed = same image (where the upstream supports it). |
| input_images | array | Optional | [{ url? } | { b64_json? }] for image-to-image / reference / first-frame. |
| sse | boolean | Optional | When true the response is sent as Server-Sent Events. The full JSON arrives in one event followed by [DONE]. Useful to keep long upstream renders from timing out at proxies. |
基本示例
curl https://api.airforce/v1/images/generations \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-2-dev",
"prompt": "A cute baby sea otter floating on its back",
"n": 1,
"response_format": "url"
}'响应形状
| Parameter | Type | Required | Description |
|---|---|---|---|
| created | integer | Optional | Unix timestamp. |
| data | array | Optional | Generated assets. |
| data[].url | string | Optional | Pre-signed CDN URL when response_format is "url". |
| data[].b64_json | string | Optional | Base64-encoded PNG when response_format is "b64_json". |
| data[].revised_prompt | string | Optional | Some models rewrite the prompt before generating; the rewritten version is returned here. |
{
"created": 1715000000,
"data": [{
"url": "https://cdn.api.airforce/images/abc123.png"
}]
}流媒体版本
经过 sse: true 当通过具有严格空闲超时的中间件进行代理时。响应是一个带有完整 JSON 的 SSE 事件,然后 [DONE].
data: {"created":1715000000,"data":[{"url":"https://cdn.api.airforce/images/abc123.png"}]}
data: [DONE]图像到图像和参考
型号有 image_caps.max_input_images > 0 接受参考图像。传递 URL 或 Base64 编码的数据。
curl https://api.airforce/v1/images/generations \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-2-dev",
"prompt": "Same character, now in a snowy forest",
"aspect_ratio": "16:9",
"input_images": [
{"url": "https://example.com/character.jpg"}
]
}'特定型号参数
除了上述通用参数之外,个别型号系列还接受额外参数。未知参数按原样转发到上游,因此任何未来特定于提供商的旋钮也无需更新 SDK 即可工作。
Flux
flux-2-klein-4b, flux-2-klein-9b, flux-2-dev
| Parameter | Type | Required | Description |
|---|---|---|---|
| aspect_ratio | string | Optional | "1:1", "16:9", "9:16", "4:3", "3:4", "21:9", "9:21". |
| image_urls | array | Optional | Reference images for img2img mode. |
Nano-Banana
nano-banana-2, nano-banana-2-search, nano-banana-pro
| Parameter | Type | Required | Description |
|---|---|---|---|
| aspect_ratio | string | Optional | "1:1", "16:9", "9:16", "4:3". |
| resolution | string | Optional | "512", "1024", "2048". |
| image_urls | array | Optional | Reference images. |
Suno (music via /v1/images/generations)
suno-v4.5, suno-v5 — Suno historically routes through this endpoint. Native music API at /v1/audio/music is preferred for new code.
| Parameter | Type | Required | Description |
|---|---|---|---|
| custom | boolean | Optional | Switch from "auto" to fully custom mode. |
| instrumental | boolean | Optional | Suppress vocals. |
| style | string | Optional | Genre tag list, e.g. "EDM, Bass". |
发现能力
每个图像模型都暴露 image_caps 在 /v1/models 因此客户端可以在发送之前验证输入:
| Parameter | Type | Required | Description |
|---|---|---|---|
| image_caps.max_n | integer | Optional | Maximum n per request. |
| image_caps.aspect_ratios | array | Optional | Allowed aspect_ratio values. |
| image_caps.qualities | array | Optional | Allowed quality values. |
| image_caps.sizes | array | Optional | Allowed size values when applicable. |
| image_caps.max_input_images | integer | Optional | 0 = text-only model. Higher = supports reference images. |
| image_caps.price_per_image_cents | integer | Optional | Cost per generated image. Multiply by n for the total request cost. |