> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiJmMTk2MjM4MS0xNmI5LTQxN2MtOGE4Ny0wZmYyNWI4N2M1YjMiLCJleHAiOjE3NzgyNTYzMzAsImlhdCI6MTc3ODI1NjAzMH0.3LOYiyDXVMnrvGZw-vnbASjWy6LKm-L0gv3MdZOLiJ4
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# AI 生成的示例

> 使用 Fern 的 AI 功能自动创建真实的 API 示例。根据需要自定义示例样式或禁用 AI 生成。

Fern 使用 AI 为您的 [API Reference](/learn/docs/api-references/overview) 文档自动生成真实的请求和响应示例。此功能默认为所有 API Reference 页面启用。您将获得反映端点属性和描述的可信数据，而不是像 `username: "string"` 这样的占位符值。示例会随着您的规范变化自动更新。

AI 示例与在 [`x-fern-examples`](/learn/api-definitions/openapi/extensions/request-response-examples) 中定义的手动示例一起工作，手动示例具有优先级。

<Tabs>
  <Tab title="之前">
    <Frame>
      <img src="https://files.buildwithfern.com/fern.docs.buildwithfern.com/learn/58a62c8ab09b5b2ecb168e458fe5f5b9ec2d0bbf049ac8eb51b6275005e735da/products/docs/pages/ai/ai-examples-before.png" alt="带有占位符字符串值的 API Reference" />
    </Frame>
  </Tab>

  <Tab title="之后">
    <Frame>
      <img src="https://files.buildwithfern.com/fern.docs.buildwithfern.com/learn/ce0a22df25ed3bb69c69cb4f273134541aa38f807462d9d83df364be2cc8241f/products/docs/pages/ai/ai-examples-after.png" alt="带有 AI 生成真实示例值的 API Reference" />
    </Frame>
  </Tab>
</Tabs>

## 配置

自定义生成示例的样式：

```yaml docs.yml
ai-examples:
  style: "Use names and emails that are inspired by plants."
```

或完全禁用此功能：

```yaml docs.yml
ai-examples:
  enabled: false
```

AI 生成的示例将写入 `ai_examples_override.yml`。编辑此文件以自定义特定示例。要在每次构建时重新生成示例，请将该文件添加到 `.gitignore`：

```txt .gitignore
**/ai_examples_override.yml
```

<Tip>
  要使 AI 生成的示例可移植到非 Fern OpenAPI 工具，请使用 [`fern api enrich`](/learn/cli-api-reference/cli-reference/commands#fern-api-enrich) 将它们合并到原生 OpenAPI 示例字段中。
</Tip>