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

# Responses API

> 使用 OpenAI Responses 格式调用文本模型

# Responses API

使用 OpenAI Responses 兼容格式调用文本模型。适合使用 `input` 组织请求，或需要携带模型专属参数的场景。

## 请求参数

<ParamField body="model" type="string" required>
  模型 ID。可通过 [模型列表](/llm-gateway/api/models) 查询
</ParamField>

<ParamField body="input" type="string | array" required>
  输入内容。可以是字符串，也可以是 Responses 格式的输入数组
</ParamField>

<ParamField body="stream" type="boolean">
  是否使用流式响应
</ParamField>

<ParamField body="temperature" type="number">
  采样温度
</ParamField>

<ParamField body="max_output_tokens" type="integer">
  最大输出 token 数
</ParamField>

<ParamField body="reasoning" type="object">
  推理相关参数，具体支持范围以模型为准
</ParamField>

## 响应参数

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

<ResponseField name="object" type="string">
  响应类型，通常为 `response`
</ResponseField>

<ResponseField name="status" type="string">
  响应状态，如 `completed`
</ResponseField>

<ResponseField name="model" type="string">
  实际调用的模型 ID
</ResponseField>

<ResponseField name="output" type="array">
  输出内容数组
</ResponseField>

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

## 代码示例

<CodeGroup>
  ```python Python theme={null}
  import requests

  url = "https://api.chenyu.cn/v1/responses"
  headers = {
      "Authorization": "Bearer your_api_key",
      "Content-Type": "application/json"
  }
  payload = {
      "model": "doubao-seed-2-0-lite-260428",
      "input": "用三句话说明 GPU 云服务适合哪些场景"
  }

  response = requests.post(url, headers=headers, json=payload)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const axios = require('axios');

  axios.post('https://api.chenyu.cn/v1/responses', {
    model: 'doubao-seed-2-0-lite-260428',
    input: '用三句话说明 GPU 云服务适合哪些场景'
  }, {
    headers: {
      Authorization: 'Bearer your_api_key',
      'Content-Type': 'application/json'
    }
  }).then((response) => {
    console.log(response.data);
  });
  ```

  ```curl cURL theme={null}
  curl -X POST "https://api.chenyu.cn/v1/responses" \
    -H "Authorization: Bearer your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "doubao-seed-2-0-lite-260428",
      "input": "用三句话说明 GPU 云服务适合哪些场景"
    }'
  ```
</CodeGroup>

## 模型专属参数

```json theme={null}
{
  "model": "doubao-seed-2-0-lite-260428",
  "input": "分析这个问题",
  "thinking": {"type": "enabled"},
  "reasoning": {"effort": "low"}
}
```

## 响应示例

```json theme={null}
{
  "id": "resp_xxx",
  "object": "response",
  "status": "completed",
  "model": "doubao-seed-2-0-lite-260428",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "GPU 云服务适合模型训练、推理部署和批量数据处理。"
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 18,
    "output_tokens": 16,
    "total_tokens": 34
  }
}
```
