foxora

Chat Completions API

/v1/models が返したモデル識別子を使い、OpenAI 互換の messages ペイロードを /v1/chat/completions へ送ります。

ターミナル
curl https://api.foxora.ai/v1/chat/completions \
  -H "Authorization: Bearer $FOXORA_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<model-id-from-v1-models>",
    "messages": [
      {"role": "user", "content": "Summarize this in three bullets."}
    ]
  }'
  1. プロバイダーモデルを固定せず、現在のモデル一覧を取得します。
  2. 空でない model と、順序付きの messages を送ります。
  3. アシスタント結果を choices、計測情報を usage から読みます。
  4. リクエスト失敗時は x-request-id を保全します。

クライアントが Server-Sent Events を処理し、途中で終わるストリームにも対応できる場合だけ stream: true を設定します。

期待される結果: HTTP 成功応答に、完了したリクエストのアシスタント選択肢と利用データが含まれます。