---
title: "Responses API（OpenAI 互換）"
description: "OpenAI-compatible /v1/responses。file_id dereference、reasoning controls、request fields。"
source: https://lazu.ai/docs/ja/endpoints/responses
updated: 2026-10-02
---

# Responses API

**POST** `/v1/responses`

Responses は reasoning models、multimodal input、Lazu file\_id dereferencing に適しています。uploaded files や新しい OpenAI response features が必要な場合に推奨します。

## リクエスト例

```bash
curl https://api.lazu.ai/v1/responses \
  -H "Authorization: Bearer $LAZU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6-luna",
    "input": [{
      "role": "user",
      "content": [
        {"type": "input_text", "text": "Say hi"}
      ]
    }]
  }'
```

## レスポンス例

```json
{
  "id": "resp_01ABCDEF",
  "model": "gpt-6-luna",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [{ "type": "output_text", "text": "Hi!" }]
    }
  ],
  "usage": { "input_tokens": 9, "output_tokens": 2 }
}
```

## 使い分け

- **Responses を使う** — uploaded files、reasoning controls、document workflows、server-side
  normalized multimodal inputs。
- **Chat completions を使う** — simple chat、SDK compatibility、tool calling、既存の
  `/v1/chat/completions` ベースのアプリ。

## Request body

- `model` `string` (必須) — `/api/models/catalog` の model ID。
  `supported_endpoints` に `/v1/responses` のパスを含む model
  を優先してください。
- `input` `string | object[]` (必須) — text input または response input messages array。
- `instructions` `string` (任意) — response の system-level instructions。
- `reasoning` `object` (任意) — supported models で reasoning effort を制御します。例：
  `{"effort":"medium"}`。
- `tools` `object[]` (任意) — OpenAI-compatible Responses shape の tool definitions。
- `stream` `boolean` (任意) — model が対応する場合、response events stream を返します。
- `max_output_tokens` `integer` (任意) — generated output tokens の上限。

## File dereferencing

[Files](https://lazu.ai/docs/ja/endpoints/files) で upload した `file_id` を参照できます。
dereference が発生した場合、Lazu は `X-Lazu-File-Dereference: 1` を付けます。

制限：

- single file purpose limit は引き続き適用されます。
- 1 回の Responses call で dereference される files は合計 64 MB 未満。
- Chat completions は `file_id` を自動 dereference しません。

## Stateless compatibility bridge

一部の catalog entry は lossless Chat bridge 経由で Responses を提供します。
`supported_endpoints[].mode` で確認できます。この route では
`store` 省略時は成功し
`X-Lazu-Warning: stateless_bridge` を返し、
`store: false` は warning なしで成功します。明示的な
`store: true`、保持できない state field、未知の cross-protocol
field は upstream call 前に `400 protocol_bridge_unsupported`
になります。標準 Responses body に Lazu 独自 field は追加しません。

## Response

- `id` `string` — Response ID。
- `output` `object[]` — output messages、reasoning items、tool calls、その他 response events。
- `usage.input_tokens` `integer` (任意) — upstream が usage を返す場合の input token count。
- `usage.output_tokens` `integer` (任意) — upstream が usage を返す場合の output token count。

完全な照合には同じ API Key で

`GET /api/usage/requests/{request_id}` を使ってください。

## ツール結果を含む完全な往復

キーのカタログから Responses と関数ツールに対応するモデルを選び、`LAZU_API_KEY` と `LAZU_MODEL` を設定します。ステートレスな継続では reasoning を含む全 output item を保持し、同じ `call_id` でツール結果を追加します。ブリッジで保持できない暗号化状態やプロバイダー固有状態はネイティブ経路が必要です。

```python
import json
import os
from openai import OpenAI, APIStatusError

client = OpenAI(
    api_key=os.environ["LAZU_API_KEY"],
    base_url=os.environ.get("LAZU_BASE_URL", "https://api.lazu.ai/v1"),
    max_retries=0,
)
model = os.environ["LAZU_MODEL"]
tools = [{"type": "function", "name": "add", "description": "Add two integers",
          "parameters": {"type": "object", "properties": {
              "a": {"type": "integer"}, "b": {"type": "integer"}},
              "required": ["a", "b"], "additionalProperties": False}}]
history = [{"role": "user", "content": "Use add to calculate 2 + 3."}]
try:
    first = client.responses.create(model=model, input=history, tools=tools,
        tool_choice={"type": "function", "name": "add"}, store=False,
        max_output_tokens=1024)
    history.extend(item.model_dump(exclude_unset=True) for item in first.output)
    for item in first.output:
        if item.type == "function_call":
            if item.name != "add":
                raise ValueError("Unexpected tool")
            args = json.loads(item.arguments)
            history.append({"type": "function_call_output", "call_id": item.call_id,
                            "output": json.dumps({"result": args["a"] + args["b"]})})
    final = client.responses.create(model=model, input=history, tools=tools,
        tool_choice="none", store=False, max_output_tokens=1024)
    print(final.output_text)
except APIStatusError as exc:
    print(exc.status_code, exc.response.headers.get("x-lazu-request-id"), exc.body)
    raise
```

出力を受信した後は自動再送しないでください。413 `request_body_too_large` はリクエストを縮小し、503 `gateway_overloaded` は時間を置いて再試行します。後者はプロバイダー障害を意味しません。部分用量はリクエスト詳細で照合できます。
