Api.Airforce
API REFERENCE

Tạo hình ảnh

Tạo và chỉnh sửa hình ảnh qua một điểm cuối tương thích OpenAI. Cùng một dạng yêu cầu tiếp cận mọi mô hình hình ảnh trong danh mục.

Một endpoint hình ảnh tương thích OpenAI phân nhánh đến Flux, Nano-Banana, Wan và các nhà cung cấp khác. Hãy gửi cùng một cấu trúc request bất kể upstream nào; các tùy chọn riêng của nhà cung cấp được truyền qua và được xác thực theo khả năng của từng model.

Khám phá các model hình ảnh bằng cách liệt kê endpoint models và giữ lại những model có output modalities bao gồm image.

POST /v1/images/generations

Hỗ trợ thả vào tương thích với OpenAI images.generate SDK. Các tham số dành riêng cho nhà cung cấp hoạt động cùng với các tham số tiêu chuẩn — phần phụ trợ chuyển tiếp những gì mỗi mô hình hiểu được.

POSThttps://api.airforce/v1/images/generations

Mô hình hình ảnh

…· live

Thông số chung

ParameterTypeRequiredDescription
modelstringRequiredImage model ID. Find them on /v1/models: image models carry media_type: "image" and an image_caps block.
promptstringRequiredImage description.
nintegerOptionalNumber of variations to generate per request. Capped by the model's image_caps.max_n.
sizestringOptionalOpenAI-style WxH, e.g. "1024x1024". Provider-specific values pass through.
aspect_ratiostringOptionalAlternative to size. "16:9", "1:1", "9:16", … Validated against image_caps.aspect_ratios.
qualitystringOptional"standard" | "hd" (OpenAI) or model-specific labels. Validated.
response_formatstringOptional"url" (default) or "b64_json".
seedintegerOptionalReproducibility seed. Same prompt + same seed = same image (where the upstream supports it).
input_imagesarrayOptional[{ url? } | { b64_json? }] for image-to-image / reference / first-frame.
ssebooleanOptionalWhen 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.

Ví dụ cơ bản

curl https://api.airforce/v1/images/generations \
  -H "Authorization: Bearer sk-air-YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nano-banana-2",
    "prompt": "A cute baby sea otter floating on its back",
    "n": 1,
    "response_format": "url"
  }'

Hình dạng phản hồi

ParameterTypeRequiredDescription
createdintegerOptionalUnix timestamp.
dataarrayOptionalGenerated assets.
data[].urlstringOptionalImage URL when response_format is "url" (default). The image is re-hosted to a file host and the link ends in /image.jpeg; null if the re-host fails.
data[].b64_jsonstringOptionalBase64-encoded image bytes when response_format is "b64_json". The format follows the upstream provider (often JPEG), not necessarily PNG.
{
  "created": 1715000000,
  "data": [{
    "url": "https://.../image.jpeg"
  }]
}

Biến thể phát trực tuyến

Vượt qua sse: true khi ủy quyền thông qua phần mềm trung gian có thời gian chờ nhàn rỗi chặt chẽ. Phản hồi là một sự kiện SSE có JSON hoàn chỉnh, sau đó [DONE].

data: {"created":1715000000,"data":[{"url":"https://.../image.jpeg"}]}

data: [DONE]

Hình ảnh thành hình ảnh & tài liệu tham khảo

Mô hình với image_caps.max_input_images > 0 chấp nhận hình ảnh tham khảo. Chuyển URL hoặc dữ liệu được mã hóa base64.

curl https://api.airforce/v1/images/generations \
  -H "Authorization: Bearer sk-air-YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nano-banana-2",
    "prompt": "Same character, now in a snowy forest",
    "aspect_ratio": "16:9",
    "input_images": [
      {"url": "https://example.com/character.jpg"}
    ]
  }'

Chỉnh sửa ảnh

Endpoint chỉnh sửa tương thích OpenAI. Gửi ảnh nguồn dưới dạng tệp multipart, giống cách SDK OpenAI làm với images.edit, hoặc gửi body JSON ở trên kèm input_images. Nó đi cùng đường với /v1/images/generations: cùng mô hình, giá và định dạng phản hồi.

POSThttps://api.airforce/v1/images/edits
ParameterTypeRequiredDescription
modelstringRequiredAn image model with image_caps.max_input_images > 0 (see Discovering capabilities below).
promptstringRequiredWhat to change or create from the input image(s).
imagefileRequiredThe source image. Repeat as image[] for several references; images, images[] and input_images are accepted too, as files or as image URLs.
maskfileOptionalForwarded as is, but no listed model declares mask support, so the serving model may ignore it.
nintegerOptionalNumber of images to generate.
sizestringOptionalOutput size, e.g. "1024x1024", where the model supports it.
aspect_ratiostringOptionalOutput aspect ratio, e.g. "16:9", where the model supports it.
qualitystringOptionalModel-specific quality level.
response_formatstringOptional"url" or "b64_json", as on /v1/images/generations.
curl https://api.airforce/v1/images/edits \
  -H "Authorization: Bearer sk-air-YOUR_API_KEY" \
  -F "model=nano-banana-2" \
  -F "prompt=Same character, now in a snowy forest" \
  -F "[email protected]" \
  -F "aspect_ratio=16:9"
from openai import OpenAI

client = OpenAI(base_url="https://api.airforce/v1", api_key="sk-air-YOUR_API_KEY")

with open("character.png", "rb") as image:
    result = client.images.edit(
        model="nano-banana-2",
        image=image,
        prompt="Same character, now in a snowy forest",
    )
print(result.data[0].url)

Tối đa 16 ảnh đầu vào mỗi yêu cầu, mỗi ảnh 25 MB; giới hạn riêng của mô hình nằm ở image_caps.max_input_images. Yêu cầu không có ảnh đầu vào bị từ chối với mã 400 thay vì trở thành lệnh tạo ảnh từ văn bản. Mỗi ảnh đầu vào có thể làm tăng giá, như trên trang mô hình.


Thông số dành riêng cho mô hình

Ngoài các thông số chung ở trên, các dòng mô hình riêng lẻ còn chấp nhận các tính năng bổ sung. Các tham số không xác định được chuyển tiếp lên thượng nguồn theo nguyên trạng, do đó, mọi nút điều chỉnh dành riêng cho nhà cung cấp trong tương lai cũng hoạt động mà không cần cập nhật SDK.

Nano-Banana

nano-banana-2, nano-banana-pro

ParameterTypeRequiredDescription
aspect_ratiostringOptional"1:1", "16:9", "9:16", "4:3".
resolutionstringOptional"512", "1024", "2048".
image_urlsarrayOptionalReference images.

Suno (music)

suno-v4.5, suno-v5 và suno-v5.5 từng được chấp nhận tại endpoint này. Giờ chúng thuộc API nhạc gốc tại /v1/audio/music — các lệnh gọi ở đây bị từ chối với `wrong_endpoint`.


Khám phá khả năng

Mỗi mẫu hình ảnh lộ ra image_caps TRÊN /v1/models để khách hàng có thể xác thực thông tin đầu vào trước khi gửi:

ParameterTypeRequiredDescription
image_caps.max_nintegerOptionalMaximum n per request.
image_caps.aspect_ratiosarrayOptionalAllowed aspect_ratio values.
image_caps.qualitiesarrayOptionalAllowed quality values.
image_caps.max_input_imagesintegerOptional0 = text-only model. Higher = supports reference images.
image_caps.supports_url_inputbooleanOptionalWhether input_images may be passed as URLs (vs base64).
image_caps.supports_seedbooleanOptionalWhether the model honours a seed value (most scraping-proxy upstreams ignore it).

Giá hình ảnh không nằm ở image_caps — hãy dùng các trường giá của model trên /v1/models để biết chi phí.