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

# OpenAI Responses API 示例

> 使用 OpenAI Responses API 的统一接入示例。

## 推荐 endpoint

* [OpenAI /v1/responses](/api-reference/endpoints/openai/responses)

## 最小请求

```json theme={null}
{
  "model": "gpt-4.1",
  "input": "总结 ApiGo 文档的核心价值，用 3 个要点回答。"
}
```

## cURL 示例

```bash theme={null}
curl https://api-vip.apigo.ai/v1/responses \
  -H "Authorization: Bearer $YOUR API KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4.1",
    "input": "总结 ApiGo 文档的核心价值，用 3 个要点回答。"
  }'
```

## Python 示例

```python theme={null}
from openai import OpenAI

client = OpenAI(
    base_url="https://api-vip.apigo.ai/v1",
    api_key="<YOUR API KEY>",
)

response = client.responses.create(
    model="gpt-4.1",
    input="总结 ApiGo 文档的核心价值，用 3 个要点回答。",
)

print(response.output_text)
```

## Node.js 示例

```js theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api-vip.apigo.ai/v1",
  apiKey: process.env.YOUR API KEY,
});

const response = await client.responses.create({
  model: "gpt-4.1",
  input: "总结 ApiGo 文档的核心价值，用 3 个要点回答。"
});

console.log(response.output_text);
```

## 最佳实践

* 新接入优先考虑 `responses`，因为它更适合统一文本、工具和多模态输入
* 多轮对话尽量复用 `previous_response_id`，不要每轮都回传完整历史
* 如果后面要接结构化输出或工具调用，先围绕 `output[]` 和 `output_text` 设计解析层
