メインコンテンツへスキップ

OpenAPI 3.1

カスタマー API リファレンス

このページでは、サポート対象のカスタマー向け推論リクエストとレスポンスについて説明します。ツール連携には、機械可読な OpenAPI ドキュメントをダウンロードしてください。

OpenAPI JSON をダウンロード

モデル別APIリクエスト例

公開済みのモデル識別子、APIプロトコル、言語を選んでリクエスト例を確認できます。顧客用APIキーは信頼できるサーバー上で管理してください。

プロトコル要件

OpenAI互換リクエストでは、設定済みの顧客用APIベースURL(既定値は https://fusionpointai.com/api/v1)に POST /chat/completions を送信します。推論権限のある顧客用キーを Authorization: Bearer で指定してください。既定の完全なURLは https://fusionpointai.com/api/v1/chat/completions です。

対応機能

現在の OpenAI 互換チャットエンドポイントが扱うのは、同期型のテキストメッセージです。このエンドポイントはストリーミングとツール呼び出しに対応していません。

クライアントのインストール

Python用とNode.js用のクライアントは、別々のパッケージとしてインストールします。

Python: pip install openai anthropic

Node.js: npm install openai @anthropic-ai/sdk

cURL
curl 'https://fusionpointai.com/api/v1/chat/completions' \
  -H "Authorization: Bearer $FUSIONPOINTAI_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
    "model": "Astra 6",
    "messages": [
        {
            "role": "user",
            "content": "Summarize this in one sentence."
        }
    ],
    "temperature": 0.7,
    "max_tokens": 300
}'

リクエストのパターン

APIキーを安全に設定する

推論権限を付与した顧客用APIキーを作成し、シークレット管理ツールまたは環境変数を通じてサーバープロセスに渡します。

  1. サーバー環境に FUSIONPOINTAI_API_KEY を設定します。キーをブラウザー側のコードに埋め込んだり、ソース管理にコミットしたりしないでください。
  2. HTTPSを使用し、キーの利用範囲をアカウントとアプリケーションに必要な推論権限に限定します。
  3. ログ、トレース、サポートへの問い合わせでは Authorization と x-api-key ヘッダーを伏せてください。漏えいの可能性がある場合はキーを失効させます。
Bash
export FUSIONPOINTAI_API_KEY="YOUR_CUSTOMER_API_KEY"

正確なモデル識別子を選ぶ

model フィールドは表示名ではなく、リクエストの振り分けに使う値です。公開中のモデルカタログに掲載された識別子を選んでください。

  1. 推論に利用可能と示された有効なモデルまたはレガシーモデルを選びます。
  2. 句読点やバージョン接尾辞も含め、識別子をそのままコピーします。モデル名からIDを推測しないでください。
  3. 識別子が公開されていない場合は、推測した値で代用せず、カタログへの掲載を待ってください。
Python
model_id = "Astra 6"
# Use this exact identifier with either protocol.

システム指示と複数ターンのメッセージを送る

会話の順序を保ち、選択したプロトコルとモデルでサポートされるロールおよびコンテンツ形式だけを使用してください。

  1. OpenAI互換リクエストでは、system、user、assistant の各メッセージを、文字列コンテンツを持つ順序付きの項目として送信します。
  2. Claude Messages では、プロトコル固有のフィールドを使い、サポート対象の system 指示と user/assistant の各ターンを順番どおりに送ります。
  3. アプリケーションに必要な会話履歴だけを保持し、選択したモデルのコンテキスト上限を守ってください。
Python
response = client.messages.create(
    model="Astra 6",
    max_tokens=512,
    system="Answer in clear, concise German.",
    messages=[
        {"role": "user", "content": "What is an API?"},
        {"role": "assistant", "content": "An API lets software exchange requests and responses."},
        {"role": "user", "content": "Give a practical example."},
    ],
)
for block in response.content:
    if block.type == "text":
        print(block.text)

JSON形式の応答を要求する

アプリケーションで構造化出力が必要な場合は、利用する前に応答が所定のスキーマに適合するか検証してください。

  1. 選択したプロトコルと上流モデルがサポートする構造化出力の設定を使います。
  2. 生成されたJSONは信頼できない入力として扱います。解析後、必須フィールドと型を検証し、不正な出力にも対処してください。
  3. モデルのドキュメントに明記されていない限り、そのモデルとプロトコルの組み合わせがJSONモードに対応すると想定しないでください。
Python
import json

# JSON is generated content, not trusted application input.
response = client.messages.create(
    model="Astra 6", max_tokens=256,
    messages=[{"role": "user", "content": 'Return only JSON with a string field named "summary". Explain an API in one sentence.'}],
)
text = "".join(block.text for block in response.content if block.type == "text")
try:
    result = json.loads(text)
    if not isinstance(result, dict) or not isinstance(result.get("summary"), str):
        raise ValueError("Unexpected response schema")
    print(result["summary"])
except (json.JSONDecodeError, ValueError) as error:
    print("Handle invalid model output:", error)

SSEで出力を逐次受信する

ストリーミングの挙動は選択したプロトコルと上流モデルによって異なります。通常のJSON応答はストリームではありません。

  1. 現在の OpenAI 互換チャットは同期型のテキストを返し、ストリーミングには対応していません。
  2. Claude Messages では、選択した上流モデルが対応する場合に stream モードを使います。プロキシはネイティブのサーバー送信イベントを転送します。
  3. イベントを順次処理し、完了またはエラー時に適切に停止します。途中までの出力を完成した回答として扱わないでください。
Python
# client is the Anthropic client configured above.
with client.messages.stream(
    model="Astra 6", max_tokens=512,
    messages=[{"role": "user", "content": "Explain API authentication."}],
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)
    final_message = stream.get_final_message()
print("\nStop reason:", final_message.stop_reason)

ツール、コンテンツブロック、エラーを扱う

プロトコル固有のデータ構造を保ち、ツール呼び出し、マルチモーダルコンテンツ、失敗時のアプリケーション動作を明確に定義してください。

  1. 現在の OpenAI 互換チャットは、ツール呼び出しにもテキスト以外のコンテンツブロックにも対応していません。
  2. Claude は、選択した上流モデルが対応する場合、ネイティブのコンテンツブロックとツール使用/結果データを保持します。実行前にツール名と引数を検証してください。
  3. HTTPステータスと応答本文を確認し、認証、権限、入力検証、レート制限によるエラーを区別します。一時的なエラーはバックオフを入れて再試行してください。
Python
import json
from datetime import datetime, timezone
from anthropic import APIError

messages = [{"role": "user", "content": "What time is it in UTC?"}]
tools = [{
    "name": "current_utc_time", "description": "Read the current UTC time.",
    "input_schema": {"type": "object", "properties": {}, "additionalProperties": False},
}]
try:
    reply = client.messages.create(model="Astra 6", max_tokens=256, messages=messages, tools=tools)
    results = []
    for block in reply.content:
        if block.type == "tool_use":
            if block.name != "current_utc_time" or block.input != {}:
                raise ValueError("Unapproved tool request")
            results.append({"type": "tool_result", "tool_use_id": block.id,
                            "content": json.dumps({"utc": datetime.now(timezone.utc).isoformat()})})
    if results:
        messages.append({"role": "assistant", "content": reply.content})
        messages.append({"role": "user", "content": results})
        reply = client.messages.create(model="Astra 6", max_tokens=256, messages=messages, tools=tools)
    print("".join(block.text for block in reply.content if block.type == "text"))
except APIError as error:
    # Log status only; never log keys or private prompts.
    print("API request failed:", getattr(error, "status_code", None))

よくある質問

リクエストにモデルの表示名を使えますか?

推論用に公開された正確な識別子だけを使用してください。表示名は振り分け用の値ではありません。未公開の識別子を推測してはいけません。

顧客用キーを設定する環境変数はどれですか?

どちらのプロトコルでも FUSIONPOINTAI_API_KEY を使用します。値は信頼できるサーバー環境で管理し、クライアント側のコードやログには含めないでください。

OpenAIクライアントにはどのURLを指定しますか?

設定済みの顧客用APIベースURLを指定します。既定値は https://fusionpointai.com/api/v1 です。チャット補完のエンドポイントには /chat/completions が追加されます。

Claude SDKとcURLでベースURLが異なるのはなぜですか?

Anthropic SDKは /v1/messages を追加するため、ベースURLには https://fusionpointai.com/api を指定します。HTTPで直接リクエストする場合は、/api/v1/messages まで含む完全なURLを使います。

OpenAI互換チャットはストリーミングやツールに対応していますか?

いいえ。現在のエンドポイントが対応するのは同期型のテキストメッセージのみで、ストリーミングとツール呼び出しは利用できません。

Claudeのすべてのモデルでブロック、ツール、ストリーミングを利用できますか?

いいえ。これらのネイティブ機能が使えるのは、選択した上流モデルが対応している場合です。モデルの機能を確認し、未対応のリクエストも適切に処理してください。

Claude Messages · POST /messages

Claude Messages リクエストでは POST /api/v1/messages を送信します。顧客用キーを x-api-key で送り、anthropic-version に 2023-06-01 を設定してください。Anthropic SDK は /v1/messages を追加するため、ベースURLには https://fusionpointai.com/api を指定します。Bearer 認証も利用できます。

Claude Messages プロキシは、選択した上流モデルが対応する場合、ネイティブのコンテンツブロック、ツールデータ、実際のサーバー送信イベント(SSE)ストリーミングをそのまま扱います。

フィールド型必須制約
model string はい {"minLength":1,"maxLength":160}
max_tokens integer はい {"minimum":1,"maximum":100000}
messages array はい {"minItems":1,"maxItems":100,"items":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["user","assistant"]},"content":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"object","required":["type"],"properties":{"type":{"type":"string","maxLength":80}},"additionalProperties":true}}]}}}}
system string | array いいえ {"oneOf":[{"type":"string"},{"type":"array","items":{"type":"object","required":["type","text"],"properties":{"type":{"const":"text"},"text":{"type":"string"}},"additionalProperties":true}}]}
stream boolean いいえ {"default":false}
temperature number いいえ {"minimum":0,"maximum":1}
top_p number いいえ {"minimum":0,"maximum":1}
top_k integer いいえ {"minimum":0,"maximum":100000}
stop_sequences array いいえ {"items":{"type":"string"}}
tools array いいえ {"items":{"type":"object","additionalProperties":true}}
tool_choice object いいえ {"additionalProperties":true}
thinking object いいえ {"additionalProperties":true}
metadata object いいえ {"additionalProperties":true}
output_config object いいえ {"additionalProperties":true}
service_tier string いいえ []
Claude Messages · 例
{
    "id": "msg_example",
    "type": "message",
    "role": "assistant",
    "model": "Astra 6",
    "content": [
        {
            "type": "text",
            "text": "A concise answer to the supplied question."
        }
    ],
    "stop_reason": "end_turn",
    "stop_sequence": null,
    "usage": {
        "input_tokens": 12,
        "output_tokens": 10
    }
}
{"type":"error","error":{"type":"authentication_error","message":"Invalid or missing API key."}}

SDK クイックスタート

本番環境のベース URL と、互換性のある Python または Node.js クライアントを使用するか、同じ JSON リクエストを cURL で送信してください。

API ベース URL: https://fusionpointai.com/api/v1

Authorization: Bearer ヘッダーにカスタマー API キーを指定してください。キーには ai:inference スコープと、このサービスに対するアカウントアクセス権が必要です。キーは信頼できるサーバー上で管理してください。

Shell
# Install the client for your application language.
# Python:
python -m pip install openai
# Node.js:
npm install openai

# Bash: enter the key without storing it in shell history.
read -rs -p 'FusionPointAI API key: ' FUSIONPOINTAI_API_KEY
export FUSIONPOINTAI_API_KEY
printf '\n'
# After finishing:
# unset FUSIONPOINTAI_API_KEY
cURL
curl 'https://fusionpointai.com/api/v1/chat/completions' \
  -H "Authorization: Bearer $FUSIONPOINTAI_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
    "model": "Jurassic-2",
    "messages": [
        {
            "role": "user",
            "content": "Summarize this in one sentence."
        }
    ],
    "temperature": 0.7,
    "max_tokens": 300
}'
Python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["FUSIONPOINTAI_API_KEY"],
    base_url="https://fusionpointai.com/api/v1",
)

response = client.chat.completions.create(
    model="Jurassic-2",
    messages=[{"role": "user", "content": "Summarize this in one sentence."}],
    temperature=0.7,
    max_tokens=300,
)
print(response.choices[0].message.content)
Node.js
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.FUSIONPOINTAI_API_KEY,
  baseURL: "https://fusionpointai.com/api/v1",
});

const response = await client.chat.completions.create({
  model: "Jurassic-2",
  messages: [{ role: "user", content: "Summarize this in one sentence." }],
  temperature: 0.7,
  max_tokens: 300,
});
console.log(response.choices[0].message.content);

OpenAI · リクエストフィールド

model の値には、推論用として現在公開されている登録済み識別子をそのまま指定してください。識別子が公開されていない場合は、リクエストを送る前にプロバイダーカタログを確認してください。

フィールド型必須制約
modelstringはい最大 160 文字。公開済みの識別子を正確に指定してください。
messagesarrayはい1~100 件のメッセージを送信順に指定します。
messages[].rolestringはいsystem、user、assistant のいずれかです。
messages[].contentstringはい各メッセージにつき最大 100,000 文字です。
temperaturenumberいいえ0~2 の範囲です。
max_tokensintegerいいえ1~100,000 の範囲です。モデル側の上限がこれより低い場合があります。

成功時のレスポンス

成功時の JSON レスポンスには id、object (chat.completion)、created、model、choices が含まれます。choice には index、assistant message、finish_reason が含まれます。トークン使用量が返される場合もあります。

例 · JSON
{
    "id": "chatcmpl_example",
    "object": "chat.completion",
    "created": 1700000000,
    "model": "Jurassic-2",
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "A concise summary of the supplied text."
            },
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 12,
        "completion_tokens": 10,
        "total_tokens": 22
    }
}
フィールド型意味
idstringcompletion を一意に識別する ID です。
objectstringレスポンスの種類: chat.completion。
createdinteger作成時刻を Unix タイムスタンプで示します。
modelstringcompletion の生成に使用したモデル識別子です。
choicesarrayassistant message と終了理由を含む completion の候補です。
usageobject返される場合はトークン数を含みます。

レート制限とエラー

本番のカスタマーサブスクリプションでは、リクエスト数やトークン使用量はクォータとして計上されません。サンドボックスキーには公開済みの月間利用枠が適用されます。モデルのコンテキストウィンドウ、出力上限、一時的なトラフィック制御は引き続き適用されます。Chat Completionsは同期型テキストです。Claude Messagesでは、対応するネイティブのコンテンツブロック、ツール、SSEが利用できます。リクエストを送る前に、操作ごとの仕様を確認してください。

chat 操作の検証エラーとプロバイダーエラーは、エラーオブジェクトで返されます。認証およびスコープのミドルウェアは、トップレベルの message フィールドを返す場合があります。どのレイヤーがリクエストを拒否したかによって、ステータスとレスポンス形式が異なります。

HTTP ステータス意味
200completion が正常に作成されました。
400リクエストボディまたはパラメーターが無効です。
401Bearer API キーがないか、無効です。
403必要なキーのスコープまたはアカウントアクセス権がありません。
429アプリケーション制限または一時的な上流トラフィック制御が適用されました。間隔を空けて再試行してください。
500利用可能な completion をサービスから返せませんでした。
OpenAPI JSON をダウンロード
{
    "openapi": "3.1.0",
    "info": {
        "title": "FusionPointAI Customer API",
        "version": "1.0.0",
        "description": "OpenAI-compatible synchronous text Chat Completions and native Claude Messages. Use https://fusionpointai.com/api/v1 as the production HTTP base URL. Claude SDKs use the base without /v1 because they append /v1/messages. Model capabilities, subscription permissions and technical limits still apply. Native streaming and content blocks belong to the Messages operation, not Chat Completions."
    },
    "servers": [
        {
            "url": "https://fusionpointai.com/api/v1",
            "description": "FusionPointAI Production API"
        }
    ],
    "security": [
        {
            "bearerAuth": []
        }
    ],
    "tags": [
        {
            "name": "Inference",
            "description": "Synchronous JSON chat completion"
        }
    ],
    "x-rateLimitPolicy": {
        "type": "unmetered_subscription",
        "summary": "Live subscriptions do not meter request or token usage against a quota; sandbox keys use their published monthly allowance.",
        "technical_constraints": "Model context windows, maximum output sizes, and temporary traffic controls may still apply according to the selected model or upstream provider."
    },
    "x-errorReference": [
        {
            "status": 200,
            "description": "The completion was created successfully."
        },
        {
            "status": 400,
            "description": "The request body or one of its parameters is invalid."
        },
        {
            "status": 401,
            "description": "The bearer API key is missing or invalid."
        },
        {
            "status": 403,
            "description": "The key lacks the required inference scope or account access."
        },
        {
            "status": 429,
            "description": "The request was limited by application throttling or an upstream provider."
        },
        {
            "status": 500,
            "description": "The service could not complete the request."
        }
    ],
    "paths": {
        "/chat/completions": {
            "post": {
                "tags": [
                    "Inference"
                ],
                "summary": "Create a chat completion",
                "operationId": "createChatCompletion",
                "description": "Create a synchronous JSON completion. Messages support system, user, and assistant roles with string content. Use the separate Messages operation for native Claude content blocks and SSE.",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "x-codeSamples": [
                    {
                        "lang": "cURL",
                        "label": "cURL",
                        "source": "curl 'https://fusionpointai.com/api/v1/chat/completions' \\\n  -H \"Authorization: Bearer $FUSIONPOINTAI_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  --data '{\n    \"model\": \"Jurassic-2\",\n    \"messages\": [\n        {\n            \"role\": \"user\",\n            \"content\": \"Summarize this in one sentence.\"\n        }\n    ],\n    \"temperature\": 0.7,\n    \"max_tokens\": 300\n}'"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "import os\nfrom openai import OpenAI\n\nclient = OpenAI(\n    api_key=os.environ[\"FUSIONPOINTAI_API_KEY\"],\n    base_url=\"https://fusionpointai.com/api/v1\",\n)\n\nresponse = client.chat.completions.create(\n    model=\"Jurassic-2\",\n    messages=[{\"role\": \"user\", \"content\": \"Summarize this in one sentence.\"}],\n    temperature=0.7,\n    max_tokens=300,\n)\nprint(response.choices[0].message.content)"
                    },
                    {
                        "lang": "Node.js",
                        "label": "Node.js",
                        "source": "import OpenAI from \"openai\";\n\nconst client = new OpenAI({\n  apiKey: process.env.FUSIONPOINTAI_API_KEY,\n  baseURL: \"https://fusionpointai.com/api/v1\",\n});\n\nconst response = await client.chat.completions.create({\n  model: \"Jurassic-2\",\n  messages: [{ role: \"user\", content: \"Summarize this in one sentence.\" }],\n  temperature: 0.7,\n  max_tokens: 300,\n});\nconsole.log(response.choices[0].message.content);"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ChatCompletionRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Completion created",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ChatCompletionResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "$ref": "#/components/responses/BadRequest"
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthorised"
                    },
                    "403": {
                        "$ref": "#/components/responses/Forbidden"
                    },
                    "429": {
                        "$ref": "#/components/responses/RateLimited"
                    },
                    "500": {
                        "$ref": "#/components/responses/ServerError"
                    }
                }
            }
        },
        "/messages": {
            "post": {
                "tags": [
                    "Inference"
                ],
                "summary": "Create a Claude Messages response",
                "operationId": "createMessage",
                "description": "Native Messages format. The model must support the requested content blocks, tools and streaming options. The gateway forwards provider-native JSON or real SSE without translating it into Chat Completions. A configured native upstream is required. Maximum JSON request size: 12 MiB.",
                "security": [
                    {
                        "claudeApiKey": []
                    },
                    {
                        "bearerAuth": []
                    }
                ],
                "parameters": [
                    {
                        "in": "header",
                        "name": "anthropic-version",
                        "schema": {
                            "type": "string",
                            "maxLength": 64
                        },
                        "example": "2023-06-01"
                    },
                    {
                        "in": "header",
                        "name": "anthropic-beta",
                        "schema": {
                            "type": "string",
                            "maxLength": 512
                        }
                    }
                ],
                "x-codeSamples": [
                    {
                        "lang": "cURL",
                        "label": "cURL",
                        "source": "curl 'https://fusionpointai.com/api/v1/messages' \\\n  -H \"x-api-key: $FUSIONPOINTAI_API_KEY\" \\\n  -H \"anthropic-version: 2023-06-01\" \\\n  -H \"Content-Type: application/json\" \\\n  --data '{\n    \"model\": \"Jurassic-2\",\n    \"max_tokens\": 300,\n    \"messages\": [\n        {\n            \"role\": \"user\",\n            \"content\": \"Summarize this in one sentence.\"\n        }\n    ]\n}'"
                    },
                    {
                        "lang": "Python",
                        "label": "Python",
                        "source": "import os\nfrom anthropic import Anthropic\n\nclient = Anthropic(\n    api_key=os.environ[\"FUSIONPOINTAI_API_KEY\"],\n    base_url=\"https://fusionpointai.com/api\",\n)\n\nresponse = client.messages.create(\n    model=\"Jurassic-2\",\n    max_tokens=300,\n    messages=[{\"role\": \"user\", \"content\": \"Summarize this in one sentence.\"}],\n)\nprint(response.content)"
                    },
                    {
                        "lang": "Node.js",
                        "label": "Node.js",
                        "source": "import Anthropic from \"@anthropic-ai/sdk\";\n\nconst client = new Anthropic({\n  apiKey: process.env.FUSIONPOINTAI_API_KEY,\n  baseURL: \"https://fusionpointai.com/api\",\n});\n\nconst response = await client.messages.create({\n  model: \"Jurassic-2\",\n  max_tokens: 300,\n  messages: [{ role: \"user\", content: \"Summarize this in one sentence.\" }],\n});\nconsole.log(response.content);"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ClaudeMessagesRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Native message or incremental native SSE events.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ClaudeMessage"
                                }
                            },
                            "text/event-stream": {
                                "schema": {
                                    "type": "string",
                                    "description": "message_start, content_block_start/delta/stop, message_delta/stop and provider error events as delivered upstream."
                                }
                            }
                        }
                    },
                    "201": {
                        "description": "Invalid JSON, message structure, field type or bounds.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ClaudeError"
                                }
                            }
                        }
                    },
                    "202": {
                        "description": "Missing, invalid, conflicting or query-string credentials.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ClaudeError"
                                }
                            }
                        }
                    },
                    "203": {
                        "description": "Scope, account or training-reference permission denied.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ClaudeError"
                                }
                            }
                        }
                    },
                    "204": {
                        "description": "Request exceeds 12 MiB.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ClaudeError"
                                }
                            }
                        }
                    },
                    "205": {
                        "description": "Application or upstream rate limit.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ClaudeError"
                                }
                            }
                        }
                    },
                    "206": {
                        "description": "Inference provider or service failure.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ClaudeError"
                                }
                            }
                        }
                    },
                    "207": {
                        "description": "Inference provider or service failure.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ClaudeError"
                                }
                            }
                        }
                    },
                    "208": {
                        "description": "Native upstream or server credentials are not configured.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ClaudeError"
                                }
                            }
                        }
                    },
                    "209": {
                        "description": "Upstream overloaded.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ClaudeError"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "API key"
            },
            "claudeApiKey": {
                "type": "apiKey",
                "in": "header",
                "name": "x-api-key"
            }
        },
        "schemas": {
            "ChatCompletionRequest": {
                "type": "object",
                "required": [
                    "model",
                    "messages"
                ],
                "properties": {
                    "model": {
                        "type": "string",
                        "maxLength": 160,
                        "enum": [
                            "Jurassic-2",
                            "Claude Fable 5.1",
                            "claude-opus-5-5",
                            "claude-sonnet-5-5",
                            "claude-haiku-5-5",
                            "Claude Opus 5",
                            "Claude Fable 5",
                            "Claude Mythos 5",
                            "Claude Sonnet 5",
                            "Claude Opus 4.8",
                            "Claude Haiku 4.5",
                            "command-a-plus-05-2026",
                            "command-a-reasoning-08-2025",
                            "command-a-vision-07-2025",
                            "command-a-translate-08-2025",
                            "embed-v5.0-pro",
                            "embed-v5.0-fast",
                            "rerank-v5.0-pro",
                            "rerank-v5.0-fast",
                            "Command R",
                            "Command R+",
                            "Embed",
                            "Rerank",
                            "deepseek-flash",
                            "DeepSeek V4",
                            "GLM-5.3",
                            "glm-5.3-flashx",
                            "GLM-5.3 Flash",
                            "GLM-4.7",
                            "kimi-k3.1-pro",
                            "kimi-k3.1-pro-highspeed",
                            "Kimi K3",
                            "Kimi K2.7 Code",
                            "Kimi K2.6",
                            "Kimi K2.5",
                            "Astra 6",
                            "gpt-6.1-sol",
                            "gpt-6.1-terra",
                            "gpt-6-luna",
                            "GPT-5.6 Sol",
                            "GPT-5.6 Terra",
                            "GPT-5.6 Luna",
                            "GPT-5.5",
                            "GPT-5.4",
                            "GPT-5.4 mini",
                            "GPT-5.4 nano",
                            "qwen3.8-max",
                            "qwen3.8-flash",
                            "qwen3.8-omni-flash",
                            "qwen3.7-plus",
                            "Qwen3.8",
                            "Qwen3 Coder Next",
                            "Qwen3-VL"
                        ],
                        "description": "An exact registered model identifier currently published for inference."
                    },
                    "messages": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 100,
                        "items": {
                            "$ref": "#/components/schemas/ChatMessage"
                        }
                    },
                    "temperature": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 2
                    },
                    "max_tokens": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 100000,
                        "description": "The selected model may impose a lower output limit."
                    }
                }
            },
            "ChatMessage": {
                "type": "object",
                "required": [
                    "role",
                    "content"
                ],
                "properties": {
                    "role": {
                        "type": "string",
                        "enum": [
                            "system",
                            "user",
                            "assistant"
                        ]
                    },
                    "content": {
                        "type": "string",
                        "maxLength": 100000
                    }
                }
            },
            "ChatCompletionResponse": {
                "type": "object",
                "required": [
                    "id",
                    "object",
                    "model",
                    "choices"
                ],
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "object": {
                        "type": "string",
                        "example": "chat.completion"
                    },
                    "created": {
                        "type": "integer"
                    },
                    "model": {
                        "type": "string"
                    },
                    "choices": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/ChatChoice"
                        }
                    },
                    "usage": {
                        "$ref": "#/components/schemas/TokenUsage"
                    }
                }
            },
            "ChatChoice": {
                "type": "object",
                "properties": {
                    "index": {
                        "type": "integer"
                    },
                    "message": {
                        "$ref": "#/components/schemas/ChatMessage"
                    },
                    "finish_reason": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "TokenUsage": {
                "type": "object",
                "properties": {
                    "prompt_tokens": {
                        "type": "integer"
                    },
                    "completion_tokens": {
                        "type": "integer"
                    },
                    "total_tokens": {
                        "type": "integer"
                    }
                }
            },
            "Error": {
                "oneOf": [
                    {
                        "$ref": "#/components/schemas/OperationError"
                    },
                    {
                        "$ref": "#/components/schemas/MiddlewareError"
                    }
                ]
            },
            "OperationError": {
                "type": "object",
                "required": [
                    "error"
                ],
                "properties": {
                    "error": {
                        "type": "object",
                        "required": [
                            "message",
                            "type",
                            "code"
                        ],
                        "properties": {
                            "message": {
                                "type": "string"
                            },
                            "type": {
                                "type": "string"
                            },
                            "code": {
                                "type": [
                                    "string",
                                    "integer",
                                    "null"
                                ]
                            },
                            "details": {
                                "type": "object",
                                "additionalProperties": {
                                    "type": "array",
                                    "items": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "MiddlewareError": {
                "type": "object",
                "required": [
                    "message"
                ],
                "properties": {
                    "message": {
                        "type": "string"
                    }
                },
                "additionalProperties": true
            },
            "ClaudeMessagesRequest": {
                "type": "object",
                "required": [
                    "model",
                    "max_tokens",
                    "messages"
                ],
                "properties": {
                    "model": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 160,
                        "enum": [
                            "Jurassic-2",
                            "Claude Fable 5.1",
                            "claude-opus-5-5",
                            "claude-sonnet-5-5",
                            "claude-haiku-5-5",
                            "Claude Opus 5",
                            "Claude Fable 5",
                            "Claude Mythos 5",
                            "Claude Sonnet 5",
                            "Claude Opus 4.8",
                            "Claude Haiku 4.5",
                            "command-a-plus-05-2026",
                            "command-a-reasoning-08-2025",
                            "command-a-vision-07-2025",
                            "command-a-translate-08-2025",
                            "embed-v5.0-pro",
                            "embed-v5.0-fast",
                            "rerank-v5.0-pro",
                            "rerank-v5.0-fast",
                            "Command R",
                            "Command R+",
                            "Embed",
                            "Rerank",
                            "deepseek-flash",
                            "DeepSeek V4",
                            "GLM-5.3",
                            "glm-5.3-flashx",
                            "GLM-5.3 Flash",
                            "GLM-4.7",
                            "kimi-k3.1-pro",
                            "kimi-k3.1-pro-highspeed",
                            "Kimi K3",
                            "Kimi K2.7 Code",
                            "Kimi K2.6",
                            "Kimi K2.5",
                            "Astra 6",
                            "gpt-6.1-sol",
                            "gpt-6.1-terra",
                            "gpt-6-luna",
                            "GPT-5.6 Sol",
                            "GPT-5.6 Terra",
                            "GPT-5.6 Luna",
                            "GPT-5.5",
                            "GPT-5.4",
                            "GPT-5.4 mini",
                            "GPT-5.4 nano",
                            "qwen3.8-max",
                            "qwen3.8-flash",
                            "qwen3.8-omni-flash",
                            "qwen3.7-plus",
                            "Qwen3.8",
                            "Qwen3 Coder Next",
                            "Qwen3-VL"
                        ]
                    },
                    "max_tokens": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 100000
                    },
                    "messages": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 100,
                        "items": {
                            "type": "object",
                            "required": [
                                "role",
                                "content"
                            ],
                            "properties": {
                                "role": {
                                    "type": "string",
                                    "enum": [
                                        "user",
                                        "assistant"
                                    ]
                                },
                                "content": {
                                    "oneOf": [
                                        {
                                            "type": "string"
                                        },
                                        {
                                            "type": "array",
                                            "items": {
                                                "type": "object",
                                                "required": [
                                                    "type"
                                                ],
                                                "properties": {
                                                    "type": {
                                                        "type": "string",
                                                        "maxLength": 80
                                                    }
                                                },
                                                "additionalProperties": true
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "system": {
                        "oneOf": [
                            {
                                "type": "string"
                            },
                            {
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "required": [
                                        "type",
                                        "text"
                                    ],
                                    "properties": {
                                        "type": {
                                            "const": "text"
                                        },
                                        "text": {
                                            "type": "string"
                                        }
                                    },
                                    "additionalProperties": true
                                }
                            }
                        ]
                    },
                    "stream": {
                        "type": "boolean",
                        "default": false
                    },
                    "temperature": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 1
                    },
                    "top_p": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 1
                    },
                    "top_k": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 100000
                    },
                    "stop_sequences": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "tools": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "additionalProperties": true
                        }
                    },
                    "tool_choice": {
                        "type": "object",
                        "additionalProperties": true
                    },
                    "thinking": {
                        "type": "object",
                        "additionalProperties": true
                    },
                    "metadata": {
                        "type": "object",
                        "additionalProperties": true
                    },
                    "output_config": {
                        "type": "object",
                        "additionalProperties": true
                    },
                    "service_tier": {
                        "type": "string"
                    }
                },
                "additionalProperties": true
            },
            "ClaudeMessage": {
                "type": "object",
                "required": [
                    "type",
                    "content"
                ],
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "type": {
                        "const": "message"
                    },
                    "role": {
                        "const": "assistant"
                    },
                    "content": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "required": [
                                "type"
                            ],
                            "properties": {
                                "type": {
                                    "type": "string",
                                    "maxLength": 80
                                }
                            },
                            "additionalProperties": true
                        }
                    },
                    "model": {
                        "type": "string"
                    },
                    "stop_reason": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "usage": {
                        "type": "object",
                        "properties": {
                            "input_tokens": {
                                "type": "integer"
                            },
                            "output_tokens": {
                                "type": "integer"
                            }
                        },
                        "additionalProperties": true
                    }
                },
                "additionalProperties": true
            },
            "ClaudeError": {
                "type": "object",
                "required": [
                    "type",
                    "error"
                ],
                "properties": {
                    "type": {
                        "const": "error"
                    },
                    "error": {
                        "type": "object",
                        "required": [
                            "type",
                            "message"
                        ],
                        "properties": {
                            "type": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        },
        "responses": {
            "BadRequest": {
                "description": "Invalid request body or parameter.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "Unauthorised": {
                "description": "Missing or invalid bearer API key.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "Forbidden": {
                "description": "The key lacks the required inference scope or account access.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "RateLimited": {
                "description": "Application throttle or temporary upstream traffic control.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            },
            "ServerError": {
                "description": "The service could not return a usable completion.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/Error"
                        }
                    }
                }
            }
        }
    }
}