> 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.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiJjODJmMzM2Mi0yZjgxLTQyZTgtODQ2MS00ZDIyNGMwY2ZkNjIiLCJleHAiOjE3NzgyNjM4MTgsImlhdCI6MTc3ODI2MzUxOH0.pL4IgqssQTdPvn5_RwCK8t47ZIwJNwD9hndlWe3dN6s
>
> 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.

# 下载 OpenAPI 规范

> Fern 从您的文档站点提供您的 OpenAPI 3.1 规范，以便 AI 工具和 LLM 可以通过编程方式发现并与您的 API 交互。

Fern 文档站点会自动提供您的原始 OpenAPI 3.1 规范，因此任何人——或任何工具——都可以下载它用于 SDK 生成、契约测试或导入到 Postman 等工具中。

该规范还从您站点的 [`llms.txt`](/learn/docs/ai-features/llms-txt) 中链接，因此 Cursor、Copilot 和 Claude 等 AI 编码助手可以发现并使用它来生成准确的 API 调用和构建集成。

## 可用端点

每个 Fern 文档站点都会在以下路径公开 OpenAPI 规范：

| 端点              | 格式   | Content-Type         |
| --------------- | ---- | -------------------- |
| `/openapi.json` | JSON | `application/json`   |
| `/openapi.yaml` | YAML | `application/x-yaml` |
| `/openapi.yml`  | YAML | `application/x-yaml` |

该规范包含所有端点及其请求/响应模式、身份验证方案（Bearer、Basic、API Key、OAuth）、webhook、作为组件模式的类型定义，以及来自您环境配置的服务器 URL。它基于为您的文档提供动力的相同 API 定义生成，因此始终保持最新。

## 使用方法

将端点附加到您的文档 URL 以下载规范：

```bash
# 下载为 JSON
curl https://your-docs-site.com/openapi.json

# 下载为 YAML
curl https://your-docs-site.com/openapi.yaml
```

如果您的文档站点包含多个 API 定义，端点会返回可用 API 的列表。使用 `api` 查询参数来选择特定的 API：

```bash
# 获取特定 API 的规范
curl https://your-docs-site.com/openapi.json?api=my-api-id
```