Structure your GitHub repositories

Before generating SDKs with Fern, you’ll need to set up the proper GitHub repository structure to house your API definitions and SDK code so it’s intuitive for you and your users to access, maintain, and update code.

1

Structuring your top-level repository

  1. Identify or create a top-level GitHub repository where you want all of your SDK and API code to live.
  2. Install the Fern GitHub App on the top-level repository and all SDK repositories. Select Configure, then scroll down to Repository Access. Select Only select repositories and in the dropdown select the repository for your SDK. Click Save.

For example, your basic GitHub file structure should look something like this:

├─ company-repo # Top-level repo for all SDKs
├─ fern/
├─ apis/
├─ sdks/
└── generators.yml # Contains settings for all SDKs

Your generators.yml file will contain a group for each of your SDKs. Each group points to the GitHub repository for the relevant SDK.

For example, the group for a TypeScript SDK might look like this:

generators.yml
1 ts-sdk:
2 generators:
3 - name: fernapi/fern-typescript-sdk
4 version: 2.6.3
5 github:
6 repository: your-organization/your-typescript-repo

For additional examples, see Cohere’s generators.yml file and Vapi’s generators.yml file.

You can also additionally configure the github section to whether Fern should commit and release, create a pull request, or push code to a branch when you make changes to your SDK code. See GitHub Configuration for more details.
2

Structuring SDK-specific repositories

  1. Create a new GitHub repository called company-<language> (or something similar) for each of your SDKs, if you haven’t done so already.
  2. Install the Fern GitHub App on the top-level repository and all SDK repositories. Select Configure, then scroll down to Repository Access. Select Only select repositories and in the dropdown select the repository for your SDK. Click Save.

The repository structure for a specific SDK should look similar to this:

1├─ company-repo # Top-level repo for all SDKs
2 ├─ fern/
3 ├─ apis/
4 ├─ sdks/
5 └── generators.yml # Contains settings for all SDKs
6 ├─ typescript-sdk-repo # Repository for a TypeScript SDK
7 ├─ .github/workflows/ # Contains GitHub Actions for publishing to package repositories, etc.
8 ├─ scripts/
9 ├─ src/
10 ├─ tests/
11 └── .fernignore # Lists files that Fern shouldn't modify
12 ├─ python-sdk-repo
13 └── go-sdk-repo

Fern generates most of the SDK files listed in this example repository (scripts/, src/, tests, .fernignore, etc.), including any custom code you added. You have to manually set up .github/workflows to execute actions, like publishing SDK versions to a package repository.

For additional examples, see Cohere’s Python SDK repository and Vapi’s TypeScript SDK repository.

3

Generate an SDK in your desired language

Once you’ve set up your GitHub repository structure, you can proceed with generating SDKs in your desired languages.