> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gogogotoken.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Codex Responses 接口

> OpenAI Responses API 兼容格式，适用于 Codex CLI

使用 Responses API 调用 Codex 模型。Codex CLI 应使用 `/v1/responses`，不要配置为 `/v1/chat/completions`使用 Responses API 调用 Codex 模型。Codex CLI 应使用 `/v1/responses`，不要配置为 `/v1/chat/completions`。

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://gogogotoken.ai/v1/responses \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-5.2-codex",
      "input": "Refactor this function to use async/await.",
      "stream": false
    }'
  ```

  ```bash 流式 theme={null}
  curl -N -X POST https://gogogotoken.ai/v1/responses \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-5.2-codex",
      "input": "Explain this repository in three bullet points.",
      "stream": true
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "resp_abc123",
    "object": "response",
    "model": "gpt-5.2-codex",
    "status": "completed",
    "output": [
      {
        "type": "message",
        "role": "assistant",
        "content": [
          {
            "type": "output_text",
            "text": "Here is the refactored version..."
          }
        ]
      }
    ],
    "usage": {
      "input_tokens": 42,
      "output_tokens": 36,
      "total_tokens": 78
    }
  }
  ```

  ```text 流式 theme={null}
  data: {"type":"response.output_text.delta","delta":"Here"}

  data: {"type":"response.output_text.delta","delta":" is"}

  data: {"type":"response.completed","response":{"id":"resp_abc123","status":"completed"}}
  ```
</ResponseExample>

## 接口说明

Codex CLI 使用 Responses API 发起对话、工具调用与上下文管理。Base URL 只填写 `https://gogogotoken.ai`，客户端会自动拼接 `/v1/responses`。

<Warning>
  Codex CLI 必须使用 `/v1/responses`。如果误配为 `/v1/chat/completions`，客户端可能无法正常工作。
</Warning>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://gogogotoken.ai/v1/responses \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-5.2-codex",
      "input": "Refactor this function to use async/await.",
      "stream": false
    }'
  ```

  ```bash 流式 theme={null}
  curl -N -X POST https://gogogotoken.ai/v1/responses \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "gpt-5.2-codex",
      "input": "Explain this repository in three bullet points.",
      "stream": true
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "resp_abc123",
    "object": "response",
    "model": "gpt-5.2-codex",
    "status": "completed",
    "output": [
      {
        "type": "message",
        "role": "assistant",
        "content": [
          {
            "type": "output_text",
            "text": "Here is the refactored version..."
          }
        ]
      }
    ],
    "usage": {
      "input_tokens": 42,
      "output_tokens": 36,
      "total_tokens": 78
    }
  }
  ```

  ```text 流式 theme={null}
  data: {"type":"response.output_text.delta","delta":"Here"}

  data: {"type":"response.output_text.delta","delta":" is"}

  data: {"type":"response.completed","response":{"id":"resp_abc123","status":"completed"}}
  ```
</ResponseExample>

## 接口说明

Codex CLI 使用 Responses API 发起对话、工具调用与上下文管理。Base URL 只填写 `https://gogogotoken.ai`，客户端会自动拼接 `/v1/responses`。

<Warning>
  Codex CLI 必须使用 `/v1/responses`。如果误配为 `/v1/chat/completions`，客户端可能无法正常工作。
</Warning>

## 支持端点支持端点

| 端点                                                      | 用途           |
| ------------------------------------------------------- | ------------ |
| `POST /v1/responses`                                    | 对话、工具调用与任务执行 |
| [`POST /v1/responses/compact`](/overseas/codex-compact) | 上下文压缩        |

| 端点                                                      | 用途           |
| ------------------------------------------------------- | ------------ |
| `POST /v1/responses`                                    | 对话、工具调用与任务执行 |
| [`POST /v1/responses/compact`](/overseas/codex-compact) | 上下文压缩        |

## 请求头请求头

<ParamField header="Authorization" type="string" required>
  API Key 鉴权信息，格式为 `Bearer YOUR_API_KEY`。
</ParamField>

<ParamField header="Content-Type" type="string" required>
  固定为 `application/json`。
</ParamField>

## 请求体

<ParamField body="model" default="gpt-5.2-codex" type="string" required>
  Codex 模型 ID，例如 `gpt-5.2-codex`。完整列表以 `GET /v1/models` 与分组配置为准。
</ParamField>

<ParamField body="input" default="Explain this project in three bullet points." type="string" required>
  用户输入。简单调用可传字符串；复杂场景可传 Responses API 兼容的结构化输入。
</ParamField>

<ParamField body="stream" default={false} type="boolean">
  是否使用 SSE 流式返回，默认 `false`。
</ParamField>

<ParamField body="tools" type="object[]">
  工具定义。Codex CLI 的工具调用会按 Responses API 结构透传。
</ParamField>

<ParamField body="prompt_cache_key" type="string">
  可选的缓存键。网关可基于该字段保持同一会话上游路由稳定，提升缓存命中率。
</ParamField>

<ParamField body="store" default={false} type="boolean">
  网关会为 Codex 上游自动设置 `store: false`，一般无需手动配置。
</ParamField>

## 响应体

<ResponseField name="id" type="string">
  本次响应 ID。
</ResponseField>

<ResponseField name="status" type="string">
  响应状态，例如 `completed`、`in_progress`、`failed`。
</ResponseField>

<ResponseField name="output" type="object[]">
  模型输出数组。文本结果通常位于 `output[].content[].text`。
</ResponseField>

<ResponseField name="usage" type="object">
  token 用量统计。
</ResponseField>

## 错误码

| 状态码   | 含义               | 处理建议                    |
| ----- | ---------------- | ----------------------- |
| `401` | API Key 无效或未传    | 检查请求头与令牌状态              |
| `403` | 无权限访问目标 Codex 模型 | 检查 API Key 分组权限         |
| `404` | 路径配置错误           | 确认请求路径为 `/v1/responses` |
| `429` | 触发限速             | 降低请求频率或调整套餐             |
| `5xx` | 上游或网关异常          | 稍后重试，并查看控制台日志           |

<ParamField header="Authorization" type="string" required>
  API Key 鉴权信息，格式为 `Bearer YOUR_API_KEY`。
</ParamField>

<ParamField header="Content-Type" type="string" required>
  固定为 `application/json`。
</ParamField>

## 请求体

<ParamField body="model" default="gpt-5.2-codex" type="string" required>
  Codex 模型 ID，例如 `gpt-5.2-codex`。完整列表以 `GET /v1/models` 与分组配置为准。
</ParamField>

<ParamField body="input" default="Explain this project in three bullet points." type="string" required>
  用户输入。简单调用可传字符串；复杂场景可传 Responses API 兼容的结构化输入。
</ParamField>

<ParamField body="stream" default={false} type="boolean">
  是否使用 SSE 流式返回，默认 `false`。
</ParamField>

<ParamField body="tools" type="object[]">
  工具定义。Codex CLI 的工具调用会按 Responses API 结构透传。
</ParamField>

<ParamField body="prompt_cache_key" type="string">
  可选的缓存键。网关可基于该字段保持同一会话上游路由稳定，提升缓存命中率。
</ParamField>

<ParamField body="store" default={false} type="boolean">
  网关会为 Codex 上游自动设置 `store: false`，一般无需手动配置。
</ParamField>

## 响应体

<ResponseField name="id" type="string">
  本次响应 ID。
</ResponseField>

<ResponseField name="status" type="string">
  响应状态，例如 `completed`、`in_progress`、`failed`。
</ResponseField>

<ResponseField name="output" type="object[]">
  模型输出数组。文本结果通常位于 `output[].content[].text`。
</ResponseField>

<ResponseField name="usage" type="object">
  token 用量统计。
</ResponseField>

## 错误码

| 状态码   | 含义               | 处理建议                    |
| ----- | ---------------- | ----------------------- |
| `401` | API Key 无效或未传    | 检查请求头与令牌状态              |
| `403` | 无权限访问目标 Codex 模型 | 检查 API Key 分组权限         |
| `404` | 路径配置错误           | 确认请求路径为 `/v1/responses` |
| `429` | 触发限速             | 降低请求频率或调整套餐             |
| `5xx` | 上游或网关异常          | 稍后重试，并查看控制台日志           |
