Thông số phổ quát
Tiêu đề, sơ đồ xác thực, bao lỗi và quy ước áp dụng trên mọi điểm cuối.
Các quy ước được chia sẻ bởi mọi endpoint nằm ở đây: các header xác thực được chấp nhận, cấu trúc lỗi đồng nhất, và cách thương lượng content type của request và response.
Các tham số riêng cho một endpoint đơn lẻ được ghi trong trang của chính endpoint đó; trang này là tài liệu tham khảo xuyên suốt.
Xác thực
Tất cả các điểm cuối đều yêu cầu khóa API Airforce. Tạo một cái trong bảng điều khiển bên dưới Khóa API. Chìa khóa bắt đầu bằng sk-air-.
| Parameter | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Required | Bearer sk-air-YOUR_API_KEY. Accepted on every endpoint. |
| x-api-key | string | Optional | Alternative auth header. Accepted on /v1/messages and /v1/responses for Anthropic SDK compatibility. |
| anthropic-version | string | Optional | Required when using /v1/messages with the @anthropic-ai/sdk. Use "2023-06-01". |
| Content-Type | string | Optional | application/json for body posts. multipart/form-data for endpoints that accept file uploads (transcriptions, voice cloning, etc.). |
Ví dụ
# Standard
curl https://api.airforce/v1/chat/completions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
…
# Anthropic SDK style (only on /v1/messages, /v1/responses)
curl https://api.airforce/v1/messages \
-H "x-api-key: sk-air-YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
…
# Multipart upload (file endpoints)
curl https://api.airforce/v1/audio/transcriptions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-F "[email protected]" \
-F "model=whisper-1"Tiêu đề yêu cầu tùy chọn
| Parameter | Type | Required | Description |
|---|---|---|---|
| User-Agent | string | Optional | Helpful for debugging. Logged with every request. |
Tiêu đề phản hồi
| Parameter | Type | Required | Description |
|---|---|---|---|
| Content-Type | string | Optional | application/json for JSON, text/event-stream for streams, or the media MIME (audio/mpeg, image/png, …) for binary endpoints. |
Mức sử dụng và chi phí không được trả về dưới dạng các header tùy chỉnh X-*. Số lượng token được trả về trong đối tượng usage của phần thân phản hồi trên /v1/chat/completions và /v1/messages (các lần trúng prompt-cache của Anthropic cũng xuất hiện ở đó, ví dụ cache_read_input_tokens). Chi phí mỗi request được ghi lại trong nhật ký sử dụng trên dashboard của bạn, và các tác vụ media bất đồng bộ mang theo trường cost_cents trong phản hồi trạng thái của chúng.
Lý luận và suy nghĩ (điểm cuối)
Mô hình với supports_reasoning: true chấp nhận các tham số chuẩn giống nhau ở mọi nơi chúng xuất hiện (hiện tại /v1/chat/completions Và /v1/messages).
| Parameter | Type | Required | Description |
|---|---|---|---|
| reasoning_effort | string | Optional | "low" | "medium" | "high". OpenAI o-series / GPT-5 reasoning models only — has no effect on Claude. Use `thinking_budget` for Anthropic budget control. |
| thinking | string | object | Optional | "on" / "off" / "auto" for a quick toggle, or { type: "enabled", budget_tokens: N } Anthropic shape. Both forms accepted, both normalised to the upstream's native shape. |
| thinking_budget | integer | Optional | Maximum tokens spent reasoning before visible output starts. Maps to budget_tokens (Anthropic) and thinking_budget (Gemini). |
| ignore_defaults | boolean | Optional | Bypass your saved per-model defaults for this single request. Useful when a saved default (e.g. thinking on) is overriding the value you sent. |
Các mô hình có hỗ trợ lý luận
…· liveNhìn thấy Hoàn thành trò chuyện → Lý do để biết ví dụ đầy đủ.
Quy ước phát trực tuyến
Điểm cuối chấp nhận stream: true đáp lại với Content-Type: text/event-stream và phát ra các Sự kiện do Máy chủ gửi. Định dạng dây phụ thuộc vào điểm cuối:
| Parameter | Type | Required | Description |
|---|---|---|---|
| /v1/chat/completions | OpenAI SSE | Optional | data: {…JSON chunk…}, terminated by data: [DONE]. |
| /v1/messages | Anthropic SSE | Optional | Named events: message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop. |
| /v1/images/generations (sse: true) | OpenAI-shape SSE | Optional | Single data: event with the full response, then [DONE]. Useful for long-running image jobs to keep the connection alive. |
| /v1/video/tasks/:id/stream | progress SSE | Optional | Periodic { progress, status } events for in-flight video tasks. Stream closes once the task is done. |
phong bì lỗi
Mọi phản hồi lỗi đều sử dụng cùng một hình dạng JSON. Mã trạng thái HTTP phản ánh loại lỗi.
| Parameter | Type | Required | Description |
|---|---|---|---|
| error.message | string | Optional | Human-readable message safe to display. |
| error.type | string | Optional | Machine-readable category. See table below. |
| error.code | string | Optional | Specific identifier when applicable, e.g. "model_not_found". |
| error.param | string | Optional | Field name that failed validation, when relevant. |
| Parameter | Type | Required | Description |
|---|---|---|---|
| 400 | invalid_request | Optional | Malformed JSON, unknown field, validation failed. |
| 401 | authentication_error | Optional | Missing or invalid API key. |
| 403 | permission_error | Optional | Plan or per-key restriction blocks this request. |
| 404 | not_found | Optional | Unknown resource (model, task ID, voice ID). |
| 413 | payload_too_large | Optional | Upload exceeds size limit (200 MB for voice samples, etc.). |
| 429 | rate_limit | Optional | Per-second throttle, daily token cap, or balance exhausted. |
| 500 | internal_error | Optional | Unexpected. Quote the X-Request-ID when reporting. |
| 503 | upstream_error | Optional | Every key for the requested provider is failing right now. Retry with a different model or wait. |
{
"error": {
"message": "Model 'gpt-99' not found.",
"type": "invalid_request",
"param": "model",
"code": "model_not_found"
}
}Giới hạn tỷ lệ và số lần thử lại
Các giới hạn được thực thi trên mỗi khóa API. Vượt quá bất kỳ lợi nhuận nào trong số đó 429:
- Per-second request throttle (plan-dependent).
- Daily token cap on free / pay-as-you-go plans.
- Hạn mức tín dụng cho mỗi khóa khi bạn đặt trong bảng điều khiển.
- Concurrent video tasks (typically 4 in flight).
Retry with exponential backoff on 429 and 503. Don't retry on 4xx other than 429.
sự bình thường
Điểm cuối thế hệ (trò chuyện, hình ảnh, âm thanh, video) không bình thường — mỗi cuộc gọi sẽ tạo ra phản hồi mới và được tính phí độc lập. Để có kết quả xác định, hãy đặt hạt giống cố định ở nơi được hỗ trợ (hình ảnh/âm thanh/một số mô hình trò chuyện). Điểm cuối không đồng bộ chạy dài (/v1/video/thế hệ) trả về task_id mà bạn có thể thăm dò lại một cách an toàn.
Bản đồ điểm cuối
Mọi điểm cuối công khai trong nháy mắt.
| Parameter | Type | Required | Description |
|---|---|---|---|
| POST /v1/chat/completions | chat | Optional | OpenAI Chat Completions. See /docs/api/chat. |
| POST /v1/messages | chat | Optional | Anthropic Messages. See /docs/api/chat. |
| POST /v1/responses | chat | Optional | Anthropic Responses (stateful). See /docs/api/chat. |
| GET /v1/models | models | Optional | List available models. See /docs/api/models. |
| POST /v1/images/generations | image | Optional | Generate / edit images. See /docs/api/media. |
| POST /v1/audio/speech | audio | Optional | Text-to-speech. See /docs/api/audio. |
| POST /v1/audio/music | audio | Optional | Music generation. |
| POST /v1/audio/sound-effects | audio | Optional | SFX generation. |
| POST /v1/audio/transcriptions | audio | Optional | Speech-to-text. |
| POST /v1/audio/audio-isolation | audio | Optional | Voice isolation / noise removal. |
| POST /v1/audio/voice-changer | audio | Optional | Speech-to-speech voice conversion. |
| POST /v1/audio/dubbing | audio | Optional | Async multi-language dubbing. |
| GET /v1/audio/voices | audio | Optional | Catalog of TTS voices. |
| POST /v1/voices/clone | voice | Optional | Clone a custom voice. See /docs/api/audio#voice-cloning. |
| GET /v1/voices/library | voice | Optional | List your cloned voices. |
| POST /v1/video/generations | video | Optional | Async video generation. See /docs/api/video. |
| GET /v1/video/tasks/:id | video | Optional | Poll a video task. |