# 多种响应 (/zh/api-playground/multiple-responses)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 273 · updated: 2026-07-30 -->
Related: [操作台](/zh/api-playground/overview.md), [OpenAPI 设置](/zh/api-playground/openapi-setup.md), [复杂数据类型](/zh/api-playground/complex-data-types.md), [添加 SDK 示例](/zh/api-playground/adding-sdk-examples.md), [管理页面可见性](/zh/api-playground/managing-page-visibility.md), [手动创建 API 文档页面](/zh/api-playground/mdx-setup.md)

如果你的 API 会根据输入参数、用户上下文或请求的其他条件返回不同的响应，你可以使用 `examples` 属性来记录多个响应示例。

将此属性添加到任意响应中。它具有以下架构。

```yaml
responses:
  "200":
    description: 成功响应
    content:
      application/json:
        schema:
          $ref: "#/components/schemas/YourResponseSchema"
        examples:
          us:
            summary: 美国的响应
            value:
              countryCode: "US"
              currencyCode: "USD"
              taxRate: 0.0825
          gb:
            summary: 英国的响应
            value:
              countryCode: "GB"
              currencyCode: "GBP"
              taxRate: 0.20
```

Playground 还会根据内容类型，以不同方式处理非 JSON 响应。

<div id="audio-response-examples">
  ## 音频响应示例 [#音频响应示例]
</div>

对于返回音频文件的端点，请将响应内容类型设置为 `audio/*`，并提供音频文件的 URL 作为示例值。playground 显示的是交互式音频播放器，而不是代码片段。

```yaml
responses:
  "200":
    description: Audio file generated successfully
    content:
      audio/mpeg:
        schema:
          type: string
          format: binary
        examples:
          sample:
            summary: Sample audio output
            value: "https://example.com/sample-audio.mp3"
```
