Project structure
Before generating SDKs with Fern, 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.
Repository architecture
Fern recommends a multi-repository structure containing:
- Source repository with your API definitions and SDK generation configuration
- SDK repositories for each SDK (TypeScript, Python, Go, etc.)
This separation allows you to manage API definitions centrally while keeping each SDK in its own repository for independent versioning and distribution.
Examples
See Cohere’s fern folder and TypeScript and Python SDK repositories.
Core configuration files
The source repository contains a fern/ folder that is initialized with your API definitions and a top-level generators.yml file.
fern.config.json
The fern.config.json file stores your organization name and the Fern CLI version. Pinning the version provides deterministic builds.
When working with a locally installed CLI, set version to "*". See Install Fern CLI locally for details.
generators.yml
The generators.yml file specifies which SDKs to generate. For OpenAPI, it also points to the location of your spec. For Fern Definition, Fern automatically detects your spec when your definition/ folder is at the same level as generators.yml.
OpenAPI
Fern Definition
Examples
See Cohere’s generators.yml file and Vapi’s generators.yml file.
See the generators.yml reference page for complete configuration options.
API definition file
See Project structure (API Definitions) for details on organizing your API definition files and working with multiple APIs.
Setup instructions
- Create repositories: Set up your source repository, plus one repository for each SDK
- Install Fern GitHub App: Install the Fern GitHub App on all repositories
- Configure
generators.yml: In yourgenerators.yml, add a reference to each SDK repository.