チャットの完了
1 つの API から 100 以上のモデルにわたるチャット応答を生成します。 OpenAI Chat Completions、Anthropic Messages、Anthropic Responses とのドロップイン互換性があります。
Airforce は同じモデル群に対して OpenAI Chat Completions と Anthropic Messages の両方の wire format を扱えます。すでに使っている SDK を選び、base URL を変えるだけで済みます — Claude 以外のモデルもどちらの surface の背後でも透過的に転送されます。
このページでは認証、両 surface の request と response の形、streaming、tool calling、vision、reasoning、prompt caching を扱います。はじめてですか?まずは下の基本的な例から、1 回の呼び出しを動かし、動いたら streaming や tool、caching を重ねていきましょう。
認証
すべてのリクエストにはベアラー トークン (Airforce API キー) が必要です。Anthropic x-api-key ヘッダーも受け入れられます /v1/messages SDKの互換性のために。
Authorization: Bearer sk-air-YOUR_API_KEY
# alt for /v1/messages:
x-api-key: sk-air-YOUR_API_KEYPOST /v1/chat/completions
OpenAI 互換のチャット補完。公式と連携してる openai SDKのオーバーライドによる base_url に https://api.airforce/v1.
https://api.airforce/v1/chat/completionsリクエストボディ
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | モデルID。 GET /v1/models を使用して、使用可能な ID を検出します。 |
| messages | array | Required | 会話履歴。各エントリには { role: "system" | "user" | "assistant" | "tool", content } があります。content は文字列またはコンテンツブロックの配列です(ビジョン、以下を参照)。 |
| max_tokens | integer | Optional | 生成するトークンの最大数。モデルの max_output_tokens に制限されます。 |
| temperature | float | Optional | サンプリング温度、0 ~ 2。低いほど決定的になります。デフォルトは上流のプロバイダーによって異なります。 |
| top_p | float | Optional | 核サンプリング。温度または top_p の両方ではなく、どちらかを使用してください。 |
| stream | boolean | Optional | true の場合、応答はサーバー送信イベントのストリームです。以下の「ストリーミング」を参照してください。 |
| models | array | Optional | Fallback models (max 3), e.g. ["deepseek-v3.2", "gpt-4o-mini"]. If every channel of the primary model fails, each candidate is tried in order. You are billed for — and response.model reports — the model that actually answered. Unknown or plan-gated candidates are skipped. With the OpenAI SDK pass it via extra_body. |
| transforms | array | Optional | Prompt transforms. Supported: ["middle-out"] — when the conversation overflows the model's context window, whole messages are dropped from the middle (system prompts, the first message and the most recent turns are kept), so long roleplay or agent histories keep working instead of erroring. Opt-in; off by default. |
| stream_options | object | Optional | { include_usage: boolean }。usage は常に最後のストリーミングチャンクに含まれます。このフィールドは OpenAI 互換性のために受け付けられますが、無効化はできません。 |
| stop | string | array | Optional | 最大 4 つの停止シーケンス。生成されるとすぐに生成が停止します。 |
| tools | array | Optional | モデルが呼び出す可能性のある関数定義。以下の「ツール呼び出し」を参照してください。 |
| tool_choice | string | object | Optional | 特定の呼び出しを強制するには、「auto」 (デフォルト)、「none」、または { type: "function", function: { name } } を使用します。 |
| response_format | object | Optional | { type: "json_object" } モデルが有効な JSON を出力するように強制します。対応していない機種の場合は無視されます。 |
| reasoning_effort | string | Optional | OpenAI o1/o3 スタイルの推論の深さ: 「低」 | 「中」 | "高い"。 「推論と思考」を参照してください。 |
| thinking | string | object | Optional | クロスプロバイダーの思考スイッチ。"on" | "off" | "auto"、または Anthropic 形式の { type: "enabled", budget_tokens: N }。「推論と思考」を参照してください。 |
| thinking_budget | integer | Optional | モデルの推論トレースのトークン キャップ (プロバイダーが公開する場合)。 |
| ignore_defaults | boolean | Optional | このリクエストでは、ユーザーが保存したモデルごとのデフォルト パラメーター (ダッシュボードで構成) をスキップします。 |
基本的な例
curl https://api.airforce/v1/chat/completions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.1-chat",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
"max_tokens": 200,
"temperature": 0.7
}'応答形状
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | Optional | 安定した完了 ID、例: 「chatcmpl-abc123」。 |
| object | string | Optional | 非ストリーミングの場合は「chat.completion」、ストリーミングの場合は「chat.completion.chunk」。 |
| created | integer | Optional | Unix タイムスタンプ (秒)。 |
| model | string | Optional | 要求されたモデル ID のエコー。 |
| choices | array | Optional | 補完候補の配列: [{ index, message: { role, content, tool_calls? }, finish_reason }]。 |
| choices[].finish_reason | string | Optional | 「停止」 | 「長さ」 | "ツールコール" | 「コンテンツフィルター」。 |
| usage | object | Optional | { prompt_tokens, completion_tokens, total_tokens, completion_tokens_details?, prompt_tokens_details?, cache_creation_input_tokens?, cache_creation? }。completion_tokens_details.reasoning_tokensはモデルが推論トレースを生成した場合に設定されます。キャッシュフィールドはupstreamがプロンプトキャッシュ情報を返した場合に表示されます: prompt_tokens_details.cached_tokensはキャッシュ読み取り(OpenAI標準)、cache_creation_input_tokensは書き込みの合計、cache_creation.ephemeral_5m_input_tokens / ephemeral_1h_input_tokensはTTL別の内訳を表します。 |
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1710000000,
"model": "gpt-5.1-chat",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 8,
"total_tokens": 28
}
}推論と思考
拡張推論をサポートするモデルは、通常の出力とともに思考トレースを公開します。 Airforce は、3 つの異なるアップストリーム規則を、どこでも機能する 1 つの標準パラメータのセットに正規化します。
チェック supports_reasoning: true のモデルで GET /v1/models どの ID がこれらのパラメータを受け入れるかを確認します。
推論サポート付きモデル
…· live正規パラメータ
| Parameter | Type | Required | Description |
|---|---|---|---|
| reasoning_effort | string | Optional | 「低い」 | 「中」 | "高い"。 OpenAI o1/o3、GPT-5 推論モデル、およびそれらにマッピングされるルーター。 |
| thinking | string | object | Optional | クイック切り替えには "on" | "off" | "auto"、Anthropic ネイティブ形式には { type: "enabled", budget_tokens: N } を使用します。Claude 拡張思考、Gemini 思考、DeepSeek 推論にマッピングされます。 |
| thinking_budget | integer | Optional | 可視出力を出力する前にモデルが推論に費やすことができる最大トークン。 Budget_token をミラーリングします。 |
推論の取り組み (OpenAI スタイル)
curl https://api.airforce/v1/chat/completions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "o3-mini",
"messages": [{"role": "user", "content": "Prove the Pythagorean theorem."}],
"reasoning_effort": "high"
}'拡張思考(Anthropic スタイル)
curl https://api.airforce/v1/chat/completions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4.6",
"messages": [{"role": "user", "content": "Plan a 7-day Italy trip."}],
"thinking": {"type": "enabled", "budget_tokens": 4000}
}'推理痕跡そのものは、 choices[0].message.reasoning (OpenAI 形状) または thinking のブロック content (Anthropic 形式)。推論トークンは、次のように請求および報告されます。 usage.completion_tokens_details.reasoning_tokens.
この completion_tokens_details.reasoning_tokens の内訳は、上流プロバイダーが報告した場合にのみ存在します。stream レスポンスでは、トレースは chunk ごとに delta.reasoning_content で届きます。
ビジョン&画像入力
搭載モデル supports_vision: true コンテンツ ブロックとして埋め込まれた画像を受け入れます。パブリック URL または Base64 データ URL のいずれかが機能します。サイズ制限は上流モデルによって異なります。
ビジョンサポート付きモデル
…· livecurl https://api.airforce/v1/chat/completions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.1-chat",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url", "image_url": {"url": "https://example.com/cat.jpg"}}
]
}]
}'ツール呼び出し
搭載モデル supports_tools: true 定義した関数を呼び出すことができます。モデルは次を返します。 tool_calls 配列;呼び出しを実行し、結果を tool メッセージ。
ツール呼び出しサポート付きモデル
…· liveリクエスト
curl https://api.airforce/v1/chat/completions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.1-chat",
"messages": [{"role": "user", "content": "What is the weather in Paris?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"]
}
}
}],
"tool_choice": "auto"
}'ツール呼び出しによる応答
{
"id": "chatcmpl-abc123",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [{
"id": "call_1",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\":\"Paris\"}"
}
}]
},
"finish_reason": "tool_calls"
}]
}ツールの結果によるフォローアップ
{
"model": "gpt-5.1-chat",
"messages": [
{"role": "user", "content": "What is the weather in Paris?"},
{
"role": "assistant",
"content": null,
"tool_calls": [{
"id": "call_1",
"type": "function",
"function": {"name": "get_weather", "arguments": "{\"location\":\"Paris\"}"}
}]
},
{"role": "tool", "tool_call_id": "call_1", "content": "{\"temp_c\": 14, \"sky\": \"cloudy\"}"}
]
}Structured outputs
Set response_format to make the model return JSON. Two modes are supported:
{ "type": "json_object" }— the response is a single valid JSON value.{ "type": "json_schema", "json_schema": { "name", "schema", "strict" } }— the model is steered to produce JSON that matches your JSON Schema.
curl https://api.airforce/v1/chat/completions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.1-chat",
"messages": [{"role": "user", "content": "Extract the city and country: I live in Paris, France."}],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "location",
"schema": {
"type": "object",
"properties": { "city": {"type": "string"}, "country": {"type": "string"} },
"required": ["city", "country"]
}
}
}
}'Reliability: even when a model wraps its answer in prose or a markdown code fence, Airforce extracts the JSON payload so you always receive parseable content. If no valid JSON can be recovered, the original text is returned unchanged — so the guarantee never makes a response worse. This applies to non-streamed responses; streamed responses are passed through unchanged.
ストリーミング
セット stream: true 部分的な完了をサーバー送信イベントとして受信します。各イベントは、非ストリーミング応答と同じ形式を持つ 1 つの JSON チャンクです。 message に置き換えられます delta. ストリームは次で終了します data: [DONE].
curl https://api.airforce/v1/chat/completions \
-H "Authorization: Bearer sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.1-chat",
"messages": [{"role": "user", "content": "Write a haiku about Berlin."}],
"stream": true,
"stream_options": {"include_usage": true}
}'ワイヤー形式
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1710000000,"model":"gpt-5.1-chat","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1710000000,"model":"gpt-5.1-chat","choices":[{"index":0,"delta":{"content":"Cold "},"finish_reason":null}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1710000000,"model":"gpt-5.1-chat","choices":[{"index":0,"delta":{"content":"stone "},"finish_reason":null}]}
…
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1710000000,"model":"gpt-5.1-chat","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":12,"completion_tokens":17,"total_tokens":29}}
data: [DONE]POST /v1/messages
Anthropic 互換のメッセージ API。公式と連携してる @anthropic-ai/sdk 設定により baseURL に https://api.airforce. 非Claudeモデルに対しては、OpenAI/Googleなどに透過的に転送します。
https://api.airforce/v1/messagesリクエストボディ
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Required | モデル ID (Anthropic 形式またはルーティングされたエイリアス)。 |
| messages | array | Required | 各エントリ: { role: "user" | "assistant", content: string | array }。 |
| max_tokens | integer | Required | Anthropic によって必要とされます。応答のトークンの上限。 |
| system | string | array | Optional | システムプロンプト。{ type: "text", text, cache_control? } ブロックの配列を渡して、キャッシュされるプレフィックスセグメントをマークします。「プロンプトキャッシュ」を参照してください。 |
| temperature | float | Optional | 0–1。 |
| top_p | float | Optional | 核サンプリング。 |
| top_k | integer | Optional | サンプリング プールを上位 K 個のトークンに制限します。 |
| stop_sequences | array | Optional | 最大 4 つの停止シーケンス。 |
| stream | boolean | Optional | true の場合、Anthropic スタイルの SSE イベント ストリームを出力します (「ストリーミング」を参照)。 |
| fallbacks | array | Optional | Fallback models (max 3) in Anthropic form: [{"model": "gpt-4o-mini"}]. If every channel of the primary model fails, each candidate is tried in order; you are billed for — and the response model field reports — the model that actually answered. A plain models string array is accepted too. |
| tools | array | Optional | Anthropic ツール定義: { name, description, input_schema }。応答には tool_use コンテンツブロックが含まれる場合があります。 |
| tool_choice | object | Optional | { type: "auto" | "any" | "tool", name? }。 |
| thinking | object | Optional | Anthropic 拡張思考: { type: "enabled", budget_tokens: N }。 |
例
curl https://api.airforce/v1/messages \
-H "x-api-key: sk-air-YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4.6",
"max_tokens": 256,
"system": "You are a helpful assistant.",
"messages": [
{"role": "user", "content": "Hello, Claude!"}
]
}'応答形状
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | Optional | メッセージ ID。例: 「msg_01ABCxyz」。 |
| type | string | Optional | いつも「メッセージ」。 |
| role | string | Optional | 常に「アシスタント」。 |
| content | array | Optional | コンテンツブロックの配列: { type: "text" | "tool_use" | "thinking", … }。 |
| model | string | Optional | リクエストされたモデルのエコー。 |
| stop_reason | string | Optional | "エンドターン" | "最大トークン" | "ストップシーケンス" | 「ツール_使用」。 |
| usage | object | Optional | { input_tokens, output_tokens, cache_read_input_tokens?, cache_creation_input_tokens?, cache_creation? }。キャッシュフィールドはプロンプトキャッシュが使用された場合に表示されます。cache_creation.ephemeral_5m_input_tokensとephemeral_1h_input_tokensはTTL別の書き込み内訳を表します。 |
ストリーミングイベント
Anthropic SSE は、1 回限りの JSON チャンクの代わりに名前付きイベントを使用します。各イベントには両方の機能があります event: 名前と data: JSON ペイロード。
event: message_start
data: {"type":"message_start","message":{"id":"msg_01","role":"assistant","content":[],"model":"claude-sonnet-4.6","stop_reason":null,"usage":{"input_tokens":12,"output_tokens":1}}}
event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
event: content_block_stop
data: {"type":"content_block_stop","index":0}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":17}}
event: message_stop
data: {"type":"message_stop"}POST /v1/messages/count_tokens
Anthropic-compatible token counting. Send the same system / messages / tools you would pass to /v1/messages and get an input-token estimate back without running the model — nothing is billed.
https://api.airforce/v1/messages/count_tokenscurl https://api.airforce/v1/messages/count_tokens \
-H "x-api-key: sk-air-YOUR_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4.6",
"system": "You are a helpful assistant.",
"messages": [{"role": "user", "content": "Hello, Claude!"}]
}'
# → {"input_tokens": 34}The count is a fast character-based estimate (about 4 characters per token) over system, messages and tools — close enough for context-budget checks, not an exact tokenizer run.
即時キャッシュ
の上 /v1/messages Claudeモデルの場合、次を渡すことでプレフィックスをキャッシュ済みとしてマークします。 system キャッシュされたセグメントが保持するブロックの配列として cache_control: { type: "ephemeral" }. 同じプレフィックスで始まる後続のリクエストでは、より安価なキャッシュ読み取りレートが課金されます。搭載モデル supports_caching: true で /v1/models これを支持します。
プロンプトキャッシュを備えたモデル
…· live{
"model": "claude-sonnet-4.6",
"max_tokens": 1024,
"system": [
{"type": "text", "text": "You are a senior staff engineer at Airforce."},
{
"type": "text",
"text": "<repository-snapshot>...</repository-snapshot>",
"cache_control": {"type": "ephemeral"}
}
],
"messages": [
{"role": "user", "content": "Where is rate limiting enforced?"}
]
}キャッシュカウントがレスポンスでどう報告されるか
キャッシュトークンカウントは各フォーマットのネイティブ形状で渡されるため、SDK(openai、@anthropic-ai/sdk、@google/genai)はカスタムコードなしで読み取れます。値がゼロの場合フィールドは省略され、キャッシュなしのレスポンスを軽量に保ちます。
/v1/chat/completions (OpenAI形式)
"usage": {
"prompt_tokens": 2104,
"completion_tokens": 147,
"total_tokens": 2251,
"prompt_tokens_details": { "cached_tokens": 1980 },
"cache_creation_input_tokens": 124,
"cache_creation": {
"ephemeral_5m_input_tokens": 124,
"ephemeral_1h_input_tokens": 0
}
}/v1/messages (Anthropic形式)
"usage": {
"input_tokens": 2104,
"output_tokens": 147,
"cache_read_input_tokens": 1980,
"cache_creation_input_tokens": 124,
"cache_creation": {
"ephemeral_5m_input_tokens": 124,
"ephemeral_1h_input_tokens": 0
}
}/v1beta/.../generateContent (Gemini形式)
"usageMetadata": {
"promptTokenCount": 2104,
"candidatesTokenCount": 147,
"totalTokenCount": 2251,
"cachedContentTokenCount": 1980
}キャッシュが適用される場所
明示的な cache_control マーカーは、Claude モデルでは /v1/messages と /v1/chat/completions で有効です。system または message のコンテンツブロックに付けてください。他の多くのプロバイダー(OpenAI 系、DeepSeek、Gemini)は自動でキャッシュします。マーカーを送らなくても、十分長いプレフィックスが再利用されると応答に cached_tokens が現れます。
キャッシュ期間:5 分または 1 時間
キャッシュされたプレフィックスは既定で 5 分間有効で、ヒットのたびにタイマーが更新されます。より長く保持するには、マーカーに ttl: "1h" を追加します。応答は各 TTL を cache_creation 配下で個別に報告します。
"cache_control": { "type": "ephemeral", "ttl": "1h" }実例:まず書き込み、次に読み取り
同じリクエストを 2 回送信します(上のキャッシュ例)。プレフィックスを最初に見た呼び出しは一度きりのキャッシュ書き込みを支払い、TTL 内の同一呼び出しははるかに安いキャッシュ読み取りを支払います。
1 回目の呼び出し — キャッシュ書き込み(usage 抜粋):
"usage": {
"input_tokens": 2104,
"output_tokens": 12,
"cache_creation_input_tokens": 1980,
"cache_read_input_tokens": 0
}TTL 内の 2 回目の同一呼び出し — キャッシュ読み取り:
"usage": {
"input_tokens": 2104,
"output_tokens": 12,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 1980
}制限とコスト
- Claude は最小のキャッシュ可能プレフィックス(約 1024 トークン。モデルによってはそれ以上)を必要とします。短いプレフィックスは単にキャッシュされません。
- 1 リクエストあたり最大 4 つのキャッシュ・ブレークポイント。キャッシュされるプレフィックスは呼び出し間でバイト単位まで同一でなければならず、1 文字でも変わるとキャッシュを外します。
- キャッシュ書き込みは通常の入力より高く(5m ≈ 1.25×、1h ≈ 2×)、読み取りははるかに安価です(≈ 0.1×)。各モデルのキャッシュ価格は料金ページを参照してください。
POST /v1/responses
ステートフルな会話のためのOpenAI Responses-APIサーフェス。同じBearer/x-api-key認証。キャッシュカウントはinput_tokens_details.cached_tokens(読み取り)とフラットなcache_creation_input_tokens + cache_creation.ephemeral_*(書き込み)として表示され、/v1/chat/completionsと同等です。
https://api.airforce/v1/responsesPOST /v1beta/models/{model}:generateContent
Google Gemini-compatible endpoint. Works with the official @google/genai SDK and the Gemini CLI by pointing the base URL at https://api.airforce/v1beta. Any routed model works — requests are translated to and from the native Gemini shape, and the model is taken from the URL path (not the body).
https://api.airforce/v1beta/models/{model}:generateContentAuthentication
Pass your Airforce API key any of the three ways Google clients use:
# 1) query parameter (Google default)
?key=sk-air-YOUR_API_KEY
# 2) header
x-goog-api-key: sk-air-YOUR_API_KEY
# 3) bearer token
Authorization: Bearer sk-air-YOUR_API_KEYRequest body
| Parameter | Type | Required | Description |
|---|---|---|---|
| contents | array | Required | Conversation turns. Each: { role: "user" | "model", parts: [...] }. A part is { text }, { functionCall: { name, args } }, or { functionResponse: { name, response } }. "model" is Gemini's term for the assistant role. |
| systemInstruction | object | Optional | System prompt: { parts: [{ text }] }. |
| generationConfig | object | Optional | { temperature, maxOutputTokens, topP, stopSequences } — mapped to the canonical sampling parameters. |
| tools | array | Optional | Tool definitions: [{ functionDeclarations: [{ name, description, parameters }] }]. functionDeclarations are flattened across entries. |
| toolConfig | object | Optional | Tool-choice control: { functionCallingConfig: { mode: "AUTO" | "ANY" | "NONE" } }. ANY forces a call, NONE disables tools. |
Example
curl "https://api.airforce/v1beta/models/gemini-3.1-pro:generateContent" \
-H "x-goog-api-key: sk-air-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{"role": "user", "parts": [{"text": "What is the capital of France?"}]}
],
"systemInstruction": {"parts": [{"text": "You are a helpful assistant."}]},
"generationConfig": {"temperature": 0.7, "maxOutputTokens": 256}
}'Response shape
| Parameter | Type | Required | Description |
|---|---|---|---|
| candidates | array | Optional | Generated turns: [{ content: { role: "model", parts }, finishReason, index }]. Only the first candidate is populated. |
| candidates[].finishReason | string | Optional | "STOP" | "MAX_TOKENS" | "SAFETY" | "OTHER". |
| usageMetadata | object | Optional | { promptTokenCount, candidatesTokenCount, totalTokenCount, cachedContentTokenCount? }. cachedContentTokenCount appears when the upstream reported a cache read. |
| modelVersion | string | Optional | Echo of the requested model. |
{
"candidates": [{
"content": {
"role": "model",
"parts": [{"text": "The capital of France is Paris."}]
},
"finishReason": "STOP",
"index": 0
}],
"usageMetadata": {
"promptTokenCount": 16,
"candidatesTokenCount": 8,
"totalTokenCount": 24
},
"modelVersion": "gemini-3.1-pro"
}POST /v1beta/models/{model}:streamGenerateContent
Streaming uses the :streamGenerateContent action and returns Server-Sent Events. Each data: line is a full Gemini-shaped chunk (not a delta object); the final chunk carries usageMetadata.
data: {"candidates":[{"content":{"role":"model","parts":[{"text":"The capital"}]},"index":0}],"modelVersion":"gemini-3.1-pro"}
data: {"candidates":[{"content":{"role":"model","parts":[{"text":" is Paris."}]},"index":0}],"modelVersion":"gemini-3.1-pro"}
data: {"candidates":[{"content":{"role":"model","parts":[]},"finishReason":"STOP","index":0}],"usageMetadata":{"promptTokenCount":16,"candidatesTokenCount":8,"totalTokenCount":24}}List models
The catalog is also exposed in Gemini Model-resource shape so Google clients can enumerate models.
curl https://api.airforce/v1beta/modelsNotes: the base URL is https://api.airforce/v1beta (or /v1), not Google's host. The model name comes from the URL path, not the request body. Only the first candidate is returned, and a subset of Gemini fields is translated — safetySettings and cachedContent are currently ignored. Billing, rate limits and smart routing apply exactly as on /v1/chat/completions.
エラー
Airforce は、両方のエンドポイントに対して標準の HTTP ステータス コードと均一のエラー エンベロープを返します。
| Parameter | Type | Required | Description |
|---|---|---|---|
| 400 | invalid_request_error | Optional | 不正な形式の JSON、必須フィールドが欠落している、不明なモデル。 |
| 401 | invalid_request_error / auth_required | Optional | API キーが欠落しているか無効です。 |
| 402 | insufficient_quota | Optional | このモデルには有効なサブスクリプションまたはプラスの Pay-as-you-Go 残高が必要です。 |
| 403 | model_access_denied / insufficient_scope | Optional | プランまたはキーごとのアクセス許可は、このリクエストを拒否します。 |
| 404 | model_not_found | Optional | 要求されたモデルは存在しないか、アクセス権がありません。 |
| 429 | rate_limit_error | Optional | リクエストレートまたは毎日のトークンの上限を超えました。 |
| 503 | api_error / moderation_unavailable | Optional | 要求されたプロバイダーのすべてのアップストリーム キーが失敗しました。 |
{
"error": {
"message": "The requested model does not exist or you do not have access to it.",
"type": "model_not_found",
"param": null,
"code": "404"
}
}説明用のスラッグは type にあります。code は文字列としての HTTP ステータス(例: "404")で、param はパラメータ範囲の検証エラーを除いて null です。エラー時には問題のあるパラメータ名が入ります。
モデルを発見する
モデル ID とその機能フラグ (ビジョン、ツール、推論、キャッシュ、コンテキストの長さなど) の完全なリストについては、次の URL を参照してください。 /docs/api/models.
curl https://api.airforce/v1/models \
-H "Authorization: Bearer sk-air-YOUR_API_KEY"