POST/v1/responses

レスポンスを作成

OpenAI Responses APIです。最後のターンから30日間、どのゲートウェイサーバーでもprevious_response_idで会話を続けられます。状態は組織がプロンプトを保存している間のみ保持されます。不明、期限切れ、または保存されていないIDは400 previous_response_not_foundとなり、会話全体の再送を求めます。

ゼロデータ保持ルーティングでは、組織がオプトインしない限り継続は拒否されます(zdr_continuation_disabled)。同じパスはWebSocketへのアップグレード(Codex CLIが使うトランスポート)も受け付けます。

認証: AuthorizationヘッダーにBearer形式のAPIキー

ヘッダー

  • Idempotency-Keystring

    同じリクエスト(再試行を含む)ごとに一意な文字列。同じキーとボディで再試行すると、再実行せずに最初の結果をそのまま返します。同じキーでボディが異なる場合は409を返します。キーを指定したレスポンスにはusage.costが含まれません(再送する結果をバイト単位で同一にするため)。

リクエストボディ

  • modelstring必須

    GET /v1/modelsで取得したスラッグ。

  • inputstring | array<object>必須

    文字列、または入力項目(メッセージ、関数呼び出し、関数呼び出しの出力、推論項目)のリスト。

  • instructionsstring

    システム指示。

  • previous_response_idstring

    以前のレスポンスから続けます。最後のターンから30日間、組織がプロンプトを保存している間のみ保持されます。

  • streamboolean
    既定値: false
  • max_output_tokensinteger
  • temperaturenumber
  • top_pnumber
  • toolsarray<object>

    関数ツール、web_search、およびdefer_loadingを指定したツールと組み合わせるtool_search。

  • tool_choicestring | object
  • textobject

    text.formatにjson_schemaまたはjson_objectを指定すると構造化出力になります。

  • reasoningobject

    {"effort": "..."}と{"summary": "..."}。

  • includearray<string>

    ["reasoning.encrypted_content"]を指定すると暗号化された推論項目が返され、サーバー側に状態を保持せずに後続のターンで再利用できます。

  • prompt_cache_optionsobject

    {"ttl": "12h"}を指定すると、モデルが対応している場合に12時間のプロンプトキャッシュを要求します。

  • storeboolean
  • metadataobject
  • providerobject

    OpenRouterのルーティング設定オブジェクトで、モデル自身のプロバイダールートに対して解決されます。組織のポリシーを厳しくすることはあっても、緩めることはありません。

    provider
    • zdrboolean

      trueの場合、このリクエストはゼロデータ保持のルートのみで提供されます。満たせない場合は除外されたプロバイダーを示す403で拒否されます。

    • onlyarray<string>

      これらのプロバイダーのみを使います。

    • ignorearray<string>

      これらのプロバイダーを除外します。

    • orderarray<string>

      これらのプロバイダーを順に優先し、残りはフォールバックとして使います。

    • allow_fallbacksboolean

      orderとともにfalseを指定すると一覧のプロバイダーのみで提供します。orderがない場合は最初の対象ルートのみです。

  • gatewayobject

    リクエストごとの再試行とルーティングの上限。プロバイダーには送信されません。SDKではextra_bodyで送信します。

    gateway
    • retryobject
      retry
      • max_attempts_per_routeinteger

        ルートごとの呼び出し回数(初回を含む)。既定値は2。

      • max_total_attemptsinteger

        再試行とフォールバックを含む呼び出しの合計回数。既定値は8。

      • backoffobject

        {"type": "none"}または{"type": "exponential", "base_delay_ms", "max_delay_ms", "multiplier"}(既定値は500、8000、2)。

    • routingobject
      routing
      • allow_fallbacksboolean

        falseの場合は最初の対象ルートを維持し、フェイルオーバーしません。

        既定値: true
      • route_idstring

        不透明なハンドル(route_ + 16進数64桁)でルートを固定します。ハンドルはGET /api/models/{slug}/providersから取得します。

レスポンス

  • 200

    レスポンス。streamを設定した場合は、response.completedで終わるResponsesイベント。

    レスポンス
    • idstring

      続けるにはprevious_response_idとして渡します。

    • objectstring
    • created_atinteger
    • statusenum
      "completed""incomplete""failed""in_progress"
    • modelstring
    • providerstring

      Experientialの拡張。このリクエストを処理したプロバイダー。

    • outputarray<object>
    • usageany
      usage
      • input_tokensinteger
      • input_tokens_detailsobject
        input_tokens_details
        • cached_tokensinteger
      • output_tokensinteger
      • output_tokens_detailsobject
        output_tokens_details
        • reasoning_tokensinteger
      • total_tokensinteger
      • costnumber

        このリクエストでクレジットから実際に課金されたUSD(浮動小数点数、プロモーションとプランの割引の適用後)。独自キーの場合は0。

      • is_byokboolean

        お客様自身のプロバイダーキー(独自キー)で実行された場合はtrue。独自キーの呼び出しはプラットフォームが課金しません。

      • cost_detailsobject

        次の2つの場合にのみ含まれます。upstream_inference_cost(USD。独自キーの場合に、プロバイダーが定価でお客様に請求する額)、またはlist_cost(USD。プラットフォーム負担の呼び出しが定価未満で課金された場合に、本来かかった額)。

        cost_details
        • upstream_inference_costnumber
        • list_costnumber
  • 400

    不正なリクエスト。paramはフィールド名を、codeは理由(invalid_parameter、unsupported_parameter、unsupported_capability、refusal、previous_response_not_found)を示します。課金されません。

    レスポンス
    • errorobject
      error
      • messagestring

        問題の内容と解決方法。

      • typestring

        例:invalid_request_error、authentication_error、permission_error、rate_limit_error、insufficient_quota、api_error。

      • codestring

        安定したエラーコード。

      • paramstring | null

        該当する場合、問題のあるリクエストフィールド。

      • refusal_reasonenum

        code: refusalの場合にのみ含まれます。

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"
  • 401

    キーがないか、形式が不正か、期限切れか、取り消されています。

    レスポンス
    • errorobject
      error
      • messagestring

        問題の内容と解決方法。

      • typestring

        例:invalid_request_error、authentication_error、permission_error、rate_limit_error、insufficient_quota、api_error。

      • codestring

        安定したエラーコード。

      • paramstring | null

        該当する場合、問題のあるリクエストフィールド。

      • refusal_reasonenum

        code: refusalの場合にのみ含まれます。

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"
  • 402

    組織での対応が先に必要です(card_required、email_unverified、org_under_review、free_tier_requires_payment、promotion_ended)。メッセージに手順が示されます。再試行しても解決しません。

    レスポンス
    • errorobject
      error
      • messagestring

        問題の内容と解決方法。

      • typestring

        例:invalid_request_error、authentication_error、permission_error、rate_limit_error、insufficient_quota、api_error。

      • codestring

        安定したエラーコード。

      • paramstring | null

        該当する場合、問題のあるリクエストフィールド。

      • refusal_reasonenum

        code: refusalの場合にのみ含まれます。

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"
  • 403

    model_not_granted(GET /v1/modelsのIDを使ってください)、model_location_not_supported、またはどのルートも満たせないゼロデータ保持の要求。

    レスポンス
    • errorobject
      error
      • messagestring

        問題の内容と解決方法。

      • typestring

        例:invalid_request_error、authentication_error、permission_error、rate_limit_error、insufficient_quota、api_error。

      • codestring

        安定したエラーコード。

      • paramstring | null

        該当する場合、問題のあるリクエストフィールド。

      • refusal_reasonenum

        code: refusalの場合にのみ含まれます。

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"
  • 409

    Idempotency-Keyが異なるボディで再利用されたか、元の結果がすでにありません。新しいキーを使ってください。

    レスポンス
    • errorobject
      error
      • messagestring

        問題の内容と解決方法。

      • typestring

        例:invalid_request_error、authentication_error、permission_error、rate_limit_error、insufficient_quota、api_error。

      • codestring

        安定したエラーコード。

      • paramstring | null

        該当する場合、問題のあるリクエストフィールド。

      • refusal_reasonenum

        code: refusalの場合にのみ含まれます。

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"
  • 429

    insufficient_quota(クレジット不足、支出上限の超過、またはモデルに購入が必要)とpromo_credits_now(無料プロモーションの使い切り):クレジットを追加してください。メッセージに手順が示されます。rate_limit_exceeded、free_limit_reached、admission_capacity_exceeded:Retry-Afterの秒数だけ待って再試行してください。

    レスポンス
    • errorobject
      error
      • messagestring

        問題の内容と解決方法。

      • typestring

        例:invalid_request_error、authentication_error、permission_error、rate_limit_error、insufficient_quota、api_error。

      • codestring

        安定したエラーコード。

      • paramstring | null

        該当する場合、問題のあるリクエストフィールド。

      • refusal_reasonenum

        code: refusalの場合にのみ含まれます。

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"
  • 502

    出力前にすべてのプロバイダールートが失敗しました(all_routes_failed)。バックオフを入れて再試行してください。

    レスポンス
    • errorobject
      error
      • messagestring

        問題の内容と解決方法。

      • typestring

        例:invalid_request_error、authentication_error、permission_error、rate_limit_error、insufficient_quota、api_error。

      • codestring

        安定したエラーコード。

      • paramstring | null

        該当する場合、問題のあるリクエストフィールド。

      • refusal_reasonenum

        code: refusalの場合にのみ含まれます。

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"
  • 503

    gateway_unavailable、gateway_draining、unavailable_route、deadline_exceededのいずれか。バックオフを入れて再試行し、Retry-Afterがある場合はそれに従ってください。

    レスポンス
    • errorobject
      error
      • messagestring

        問題の内容と解決方法。

      • typestring

        例:invalid_request_error、authentication_error、permission_error、rate_limit_error、insufficient_quota、api_error。

      • codestring

        安定したエラーコード。

      • paramstring | null

        該当する場合、問題のあるリクエストフィールド。

      • refusal_reasonenum

        code: refusalの場合にのみ含まれます。

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"

リクエスト

curl https://api.experientiallabs.ai/v1/responses \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-6-luna", "input": "Name three prime numbers."}'

レスポンス

{
  "id": "resp_8a41c2e09f7b4d3a9c6e1f2b5d8a0c47",
  "object": "response",
  "created_at": 1795132800,
  "status": "completed",
  "model": "gpt-6-luna",
  "provider": "openai",
  "output": [
    {
      "id": "msg_8a41c2e09f7b4d3a9c6e1f2b5d8a0c47",
      "type": "message",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "2, 3 and 5.",
          "annotations": []
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 12,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 8,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 20,
    "cost": 0.0000052,
    "is_byok": false
  }
}

https://api.experientiallabs.ai/v1/responses