# 响应（Responses API）

OpenAI Responses API 兼容端点，透传至上游。支持流式（SSE）与非流式响应。

与 `/v1/chat/completions` 的区别：请求用 `input` 代替 `messages`、`max_output_tokens`
代替 `max_tokens`；流式为 typed events，以 `response.completed` 事件（含 `usage`）结束。

任意 chat 类模型均可调用；若上游不支持 Responses API，将透传上游错误并退费。
Codex 等仅支持 Responses API 的客户端可直接把 base_url 指向本网关。

## POST /v1/responses

> Response (Responses API)

OpenAI Responses API-compatible endpoint, passed through to the upstream. Supports both streaming (SSE) and non-streaming responses.

Differences from `/v1/chat/completions`: the request uses `input` instead of `messages` and `max_output_tokens` instead of `max_tokens`; the stream is typed events, ending with a `response.completed` event that carries `usage`.

Any chat model can be called; if the upstream does not support the Responses API, its error is passed through and the request is refunded.
Clients that only support the Responses API (e.g. Codex) can point their base_url directly at this gateway.

### Authentication

`Authorization: Bearer tr-xxx`

### Request Body

Content-Type: `application/json`

- **model** `string` **(required)**  
  Model ID; retrieve the available list via `GET /v1/models`
- **input** `string | object[]` **(required)**  
  Input content. Either a string, or an array of OpenAI Responses input items
- **stream** `boolean` (default: `false`)  
  Whether to enable streaming responses (SSE, typed events)
- **max_output_tokens** `integer`  
  Maximum number of output tokens

### Response

- **id** `string`  
  Response ID
- **object** `string`  
  
- **status** `string`  
  Status, e.g. `completed`
- **output** `object[]`  
  Array of output items (text, image generation calls, etc.)
- **usage** `object`  
  
- **usage.input_tokens** `integer`  
  Number of input tokens
- **usage.output_tokens** `integer`  
  Number of output tokens
- **usage.total_tokens** `integer`  
  Total number of tokens

### Error Codes

- `400`: 
- `401`: 
- `402`: 
- `429`: 
- `502`:
