For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
预约演示登录免费开始
  • 概览
    • 什么是 API 定义?
    • 项目结构
      • 概览
      • 覆盖层(Overlays)
      • 覆盖(Overrides)
      • 身份验证
      • 服务器
      • 同步您的规范
      • OpenAPI generators.yml 参考
Checking status...
SOC2Soc 2 Type II
© 2026 Fern • Birch Solutions, Inc., a Postman company

Documentation

SDKsDocsAsk FernCLI Reference

API Definitions

OpenAPIAsyncAPIOpenRPCgRPC

Resources

BlogSupportPricing

Company

Brand KitPrivacy PolicyTerms of Service
LogoLogo
预约演示登录免费开始
在本页
  • 命名您的服务器
  • 单个 API 的多个基础 URL
OpenAPI

服务器

定义服务器 URL 和环境以帮助用户连接到您的 API。

||以 Markdown 格式查看|
此页面是否有帮助?
在仪表板中编辑
上一个

身份验证

下一个

同步您的 OpenAPI 规范

OpenAPI 允许您在 servers 键下指定一个或多个基础 URL。

openapi.yml
1servers:
2 - url: https://api.yourcompany.com/
3 - url: https://api.eu.yourcompany.com/

指定服务器对 SDK 和文档都很有价值:

  • 对于 SDK,您的用户无需在客户端实例化时手动指定 baseURL
  • 对于文档,您的 API 调试工具将自动连接到正确的服务器

命名您的服务器

如果您有多个服务器,我们建议指定 x-fern-server-name 来为服务器命名。

openapi.yml
1servers:
2 - x-fern-server-name: Production
3 url: https://api.yourcompany.com/
4 - x-fern-server-name: Production_EU
5 url: https://api.eu.yourcompany.com/

单个 API 的多个基础 URL

如果您采用微服务架构,可能会有不同的端点托管在不同的 URL 上。例如,您的 AI 端点可能托管在 ai.yourcompany.com,而其余端点可能托管在 api.yourcompany.com。

要指定这种情况,您需要在 generators.yml 和 OpenAPI 规范中都添加配置。下面的代码片段显示了如何在 generators.yml 中配置具有多个 URL 的环境。

generators.yml
1api:
2 default-environment: Production
3 default-url: api
4 environments:
5 Production:
6 api: api.yourcompany.com
7 ai: ai.yourcompany.com
8 specs:
9 - openapi: ./path/to/your/openapi
10 overrides: ./path/to/your/overrides # optional

一旦您在 generators.yml 中指定了环境,就可以使用 x-fern-server-name 扩展来指定操作所属的服务器。

openapi.yml
1paths:
2 /chat:
3 post:
4 x-fern-server-name: ai

如果您有多个环境,如开发或测试环境,也可以在 generators.yml 中建模。

generators.yml
1api:
2 default-environment: Production
3 default-url: api
4 environments:
5 Production:
6 api: api.yourcompany.com
7 ai: ai.yourcompany.com
8 Staging:
9 api: api.staging.yourcompany.com
10 ai: ai.staging.yourcompany.com
11 Dev:
12 api: api.dev.yourcompany.com
13 ai: ai.dev.yourcompany.com
要查看生产环境中的示例,请查看 Chariot generators.yml