> ## 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.

# 创建响应

> 使用 OpenAI Responses API 创建模型响应。

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

## 端点

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

<Note>
  这条 free route 只接受 OpenAI Responses 格式请求，并只路由到 OpenAI 兼容
  平台。要用 Responses 格式调用 Anthropic 或 Gemini 模型，请使用
  [Responses 格式转换器](/zh/converter/responses-format)。该转换器是无状态的，
  不支持 `previous_response_id`、响应存储、托管工具和结构化输出格式。
</Note>

## 代码示例

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

  <Tab title="Python">
    ```python theme={"dark"}
    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-5",
      input="用一句话解释为什么天空是蓝色的。"
    )

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

  <Tab title="TypeScript">
    ```typescript theme={"dark"}
    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-5",
      input: "用一句话解释为什么天空是蓝色的。",
    });

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

## 请求参数

<ParamField body="model" type="string" required>
  OpenAI 兼容模型 ID，从 [`GET /v1/models`](/zh/api-reference/list-models) 选取。
</ParamField>

<ParamField body="input" type="string | array" required>
  文本输入，或结构化输入项。
</ParamField>

<ParamField body="instructions" type="string">
  developer 或 system 指令。
</ParamField>

<ParamField body="stream" type="boolean">
  为 `true` 时流式返回。
</ParamField>

<ParamField body="tools" type="array">
  内置工具或自定义工具。
</ParamField>

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

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

## 响应结构

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

## 相关文档

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

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

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.