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

# Responses

> PipeLLM 上的 OpenAI 兼容 Responses API

认证和模型列表请参考 [概述](/api-reference/openai/overview)。

## 端点

```
POST https://api.pipellm.ai/v1/responses
```

<Note>
  这条 free route 只接受 OpenAI Responses 格式请求，并只路由到 OpenAI 兼容
  平台。Responses API 目前还不支持跨协议 converter 路由。如果你今天就需要跨
  协议调用，请先使用 [OpenAI Format Converter](/converter/openai-format.zh)
  对应的 Chat Completions 路由。
</Note>

## 代码示例

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl https://api.pipellm.ai/v1/responses \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $PIPELLM_API_KEY" \
      -d '{
        "model": "gpt-4.1",
        "input": "用一句话解释为什么天空是蓝色的。"
      }'
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import os
    from openai import OpenAI

    client = OpenAI(
      api_key=os.getenv("PIPELLM_API_KEY"),
      base_url="https://api.pipellm.ai/v1"
    )

    response = client.responses.create(
      model="gpt-4.1",
      input="用一句话解释为什么天空是蓝色的。"
    )

    print(response.output_text)
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    import OpenAI from "openai";

    const client = new OpenAI({
      apiKey: process.env.PIPELLM_API_KEY,
      baseURL: "https://api.pipellm.ai/v1",
    });

    const response = await client.responses.create({
      model: "gpt-4.1",
      input: "用一句话解释为什么天空是蓝色的。",
    });

    console.log(response.output_text);
    ```
  </Tab>
</Tabs>

## 常见请求字段

| 字段                  | 类型             | 必需 | 说明                    |
| ------------------- | -------------- | -- | --------------------- |
| `model`             | string         | 是  | OpenAI 兼容模型 ID        |
| `input`             | string 或 array | 是  | 文本输入，或结构化输入项数组        |
| `instructions`      | string         | 否  | developer 或 system 指令 |
| `stream`            | boolean        | 否  | 是否启用流式输出              |
| `tools`             | array          | 否  | 内置工具或自定义工具            |
| `temperature`       | number         | 否  | 采样温度                  |
| `max_output_tokens` | integer        | 否  | 最大输出 token 数          |

## 响应结构

```json theme={null}
{
  "id": "resp_123",
  "object": "response",
  "model": "gpt-4.1",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "大气层对蓝光的散射比红光更强。"
        }
      ]
    }
  ]
}
```

## 相关文档

<Columns cols={3}>
  <Card title="路由与协议" icon="route" href="/guides/routing-protocols.zh">
    先理解原生路由的协议限制
  </Card>

  <Card title="OpenAI 总览" icon="bolt" href="/api-reference/openai/overview.zh">
    PipeLLM 上的 OpenAI 兼容端点
  </Card>

  <Card title="OpenAI 迁移指南" icon="book" href="https://platform.openai.com/docs/guides/responses-vs-chat-completions">
    官方 Responses 与 Chat Completions 对比
  </Card>
</Columns>
