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.
预约演示登录免费开始
  • 使用 SDK
    • SDK 概述
    • SDK 如何工作
    • Quickstart
    • Customer showcase
  • 使用 SDK
    • 项目结构
    • 添加自定义代码
    • Migrating to Replay
    • 功能特性
  • 参考
      • Generating an SDK
      • 发布到 PyPI
      • Python 配置
      • 添加自定义代码
      • 动态身份验证
      • aiohttp 支持
      • 变更日志
      • Customer showcase
  • 资源
    • 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
预约演示登录免费开始
参考Python

生成 SDK

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

February 11, 2024

下一个

发布到 PyPI

按照本页面的说明生成 Python SDK。

1

Install the Fern CLI

$npm install -g fern-api
2

Initialize the fern folder

Initialize the fern folder with your existing OpenAPI specification. Specify your organization name using the --organization flag.

$fern init --openapi path/to/openapi.yml \
>--organization <YourOrganization>

OpenAPI accepts both JSON and YAML formats.

This creates a fern folder in your current directory.

fern
fern.config.json# root-level configuration
api# your API
generators.yml# generators you're using
openapi
openapi.yml# API-level configuration
3

Validate your API definition

Check that your API definition is valid, and fix errors before proceeding:

$fern check
4

添加 SDK 生成器

运行以下命令将 Python SDK 生成器添加到 generators.yml:

$fern add fern-python-sdk --group {{GROUP_NAME}}

此命令将以下 group 添加到 generators.yml:

generators.yml
1 python-sdk: # 组名称
2 generators:
3 - name: fernapi/fern-python-sdk
4 version: 5.10.0
5 output:
6 location: local-file-system
7 path: ../sdks/python
5

生成 SDK

运行以下命令生成您的 SDK:

$fern generate --group python-sdk

如果您有多个 API,请使用 --api 标志 指定要生成的 API:

$fern generate --group python-sdk --api your-api-name

This creates a sdks folder in your current directory. The resulting folder structure looks like this:

fern# 由 fern init 创建
sdks# 由 fern generate --group python-sdk 创建
python
__init__.py
client.py
core
imdb# 或您的 API 名称
errors
types
一些文件,包括 pyproject.toml 和 README.md,仅在付费计划中生成。 要获取完整生成的 SDK,请安排 演示 或 发邮件给我们。
6

Set up GitHub repositories

Fern uses a multi-repo structure: your source repository contains the fern/ folder, and each SDK gets its own separate repository.

  1. Create a source repository for your fern/ folder if you don’t have one already (e.g., your-org/your-api-definitions).
  2. Create an SDK repository for your SDK (e.g., your-org/your-api-python-sdk).
  3. Install the Fern GitHub App on both repositories.
7

发布到 PyPI

按照 发布到 PyPI 指南配置您的包并通过 GitHub Actions 设置自动发布。