Publish your public-facing Fern Python SDK to the PyPI registry. After following the steps on this page, you’ll have a versioned package published on PyPI.

This page assumes that you have:
fern folder, a GitHub repository for your Python SDK, and a Python generator group in generators.yml. See Generating an SDK (Python).You’ll need to update your generators.yml file to configure the package name, output location, and client naming for PyPi publishing. Your generators.yml should live in your source repository (or on your local machine), not the repository that contains your Python SDK code.
Configure output location
In the group for your Python SDK, change the output location in from local-file-system (the default) to pypi to indicate that Fern should publish your package directly to the PyPi registry:
Your package name must be unique in the PyPI repository, otherwise publishing your SDK to PyPI will fail.
Configure client-class-name
The client-class-name option controls the name of the generated client. This is the name customers use to import your SDK (import { your-client-name } from 'your-package-name';).
You can add publishing metadata to your PyPI package to improve discoverability and provide additional information to users. This metadata appears on your package’s PyPI page and includes keywords for PyPI search and discovery, documentation-link for your package documentation, and homepage-link for your project homepage.
You can additionally add general metadata for the SDK (description, contact email, author, license, etc.) at the individual SDK level or globally for all SDKs.
Optionally set the mode to control how Fern handles SDK publishing:
mode: release (default): Fern generates code, commits to the default branch (or the branch you specify), and tags a release automaticallymode: pull-request (recommended): Fern generates code and creates a PR for you to review before releasemode: push: Fern generates code and pushes to a branch you specify for you to review before releaseYou can also configure other settings, like the reviewers or license. Refer to the full github (generators.yml) reference for more information.
Decide how you want to publish your SDK to PyPi. You can use GitHub workflows for automated releases or publish directly via the CLI.
Set up a release workflow via GitHub Actions so you can trigger new SDK releases directly from your source repository.
Open your Fern repository in GitHub. Click on the Settings tab in your repository. Then, under the Security section, open Secrets and variables > Actions.

You can also use the url https://github.com/<your-repo>/settings/secrets/actions.
PYPI_TOKEN.
FERN_TOKEN.fern token. By default, the fern_token is generated for the
organization listed in fern.config.json.Set up a CI workflow that you can manually trigger from the GitHub UI. In your repository, navigate to Actions. Select New workflow, then Set up workflow yourself. Add a workflow that’s similar to this:
Navigate to the Actions tab, select the workflow you just created, specify a version number, and click Run workflow. This regenerates your SDK.

The rest of the release process depends on your chosen mode:
Release mode (default): If you didn’t specify a mode or set mode: release, no further action is required. Fern automatically tags the new release with your specified version number and initiates the publishing workflow in your SDK repository.
Pull request or push mode: If you set mode: pull-request or mode: push, Fern creates a pull request or pushes to a branch respectively. Review and merge the PR (pull-request) or branch (push), then tag a new release to initiate the publishing workflow in your SDK repository.
Once the workflow completes, you can view your new release by logging into PyPi and navigating to Your projects.
Regenerate your SDK, specifying the version:
The rest of the release process depends on your chosen mode:
Release mode (default): If you didn’t specify a mode or set mode: release, no further action is required. Fern automatically tags the new release with your specified version number and initiates the publishing workflow in your SDK repository.
Pull request or push mode: If you set mode: pull-request or mode: push, Fern creates a pull request or pushes to a branch respectively. Review and merge the PR (pull-request) or branch (push), then tag a new release to initiate the publishing workflow in your SDK repository.
Once the workflow completes, you can view your new release by logging into PyPi and navigating to Your projects.