fern generate

Use fern generate to run the Fern compiler for creating SDKs or documentation for your API. By default, Fern runs generators in the cloud in isolated, containerized environments.

Command flags

For SDKs

SDK Generation Command
$fern generate [--group <group>] [--version <version>] [--local] [--keepDocker] [--log-level debug]

For Documentation

Documentation Generation Command
$fern generate [--docs <instance-url>] [--preview] [--log-level debug]

Command flags explained


Type: string Description: Filter to a specific group within generators.yml. Required unless you have a default-group declared in generators.yml.


$$ fern generate --group internal


Type: string Description: Specify a version for SDKs and documentation. Adherance to semantic versioning is advised.


$$ fern generate --version


Requirement: Docker Desktop must be installed and running on your machine.

Type: boolean Description: Use the --local option to generate code locally. This downloads the Docker Image and runs it on your machine.

$fern generate --local

Running a Docker locally supports outputting files. It does not support publishing to package managers.

Keep Docker

Requirement: Docker Desktop should be ready on your local machine.

Type: boolean Description: Use the --keepDocker option to keep the Docker container running after the generation is complete. This is useful for debugging.

$fern generate --local --keepDocker

Instance URL

Type: string Description: Use the instance option to specify an instance URL to generate documentation for. This is useful if you have multiple instances of your API.

$fern generate --docs --instance instance


Type: string Description: Use the preview option along with the --docs flag to preview updates to your documentation before publishing changes to your production site.

$fern generate --docs --preview

Debugging logs

Type: choices “debug”, “info”, “warn”, “error” Default: info

To see more information about what Fern is doing, use the --log-level option.

$fern generate --log-level debug
  • info: Informational messages, warnings, and errors are logged.
  • debug: Debug messages, informational messages, warnings, and errors are logged.
  • error: Only error messages are logged.
  • warn: Warning messages and above (i.e., warnings and errors) are logged.