Configuring fern starts with the fern folder, which contains your API definitions,
SDK generators, and your CLI version.
Fern recommends a multi-repository structure with your fern folder in a source repository (containing your API definitions and generation configuration) and each generated SDK in its own separate repository.
When you run fern init --spec-type path/to/spec, your fern folder is initialized with the following files:
Beyond the core files, you can optionally use an overlays (OpenAPI) or overrides file to customize your API definition without modifying the original spec.
fern.config.jsonThe 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.ymlThe generators.yml file declares your API specification location. This also enables API Reference documentation.
For SDK generation, generators.yml is required. Add a groups section to configure which SDKs to generate. See the SDKs project structure for details.
For OpenAPI, AsyncAPI, OpenRPC, and gRPC, you’ll have a single self-contained specification file.
There are three common ways to manage your API definition:
fern api update CLI command or the sync-openapi GitHub Action.origin field in generators.yml so Fern can fetch it. This is useful when you want a single canonical definition that multiple consumers can reference.Fern supports two approaches for working with multiple API definitions. Both require an apis folder — this folder must use that exact name.
@company/user-api, @company/payments-api or versioned like @company/sdk-v1, @company/sdk-v2)client.users, client.payments or versioned like client.v1, client.v2)Use this approach when each API should generate its own independent set of SDKs. This works for both distinct APIs (e.g., user-api and payments-api) and versioned APIs where you want each version to be independently installable (e.g., @company/sdk-v1, @company/sdk-v2).
Place each API or version of an API into a separate subfolder of fern/apis/:
This feature is available only for the Enterprise plan. To get started, reach out to support@buildwithfern.com.
Use this approach when you want to merge multiple APIs into a single SDK package, with optional namespacing to organize them. This works for both distinct APIs and versioned APIs, though it increases package size as all APIs are bundled together.
For versioned APIs, namespacing lets you access different versions like client.v1 and client.v2 within the same package.
Place each API into a separate subfolder of fern/apis/:
Add namespace to handle overlapping schema names between APIs or to organize different API versions: