> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. # Quickstart > Generate a working CLI binary from an OpenAPI spec in five steps. #### Early access The CLI generator is in early access. [Reach out](https://buildwithfern.com/book-demo?type=cli) to get started. This guide walks through generating a CLI from an OpenAPI spec and running it via Fern's cloud generation. By the end you will have a compiled binary that [maps every API endpoint to a subcommand](/learn/cli-generator/get-started/openapi-extensions#command-structure), with [authentication](/learn/cli-generator/get-started/authentication), [output formatting](/learn/cli-generator/get-started/features#output-formatting), and [pagination](/learn/cli-generator/get-started/features#pagination) wired up from your spec. #### Generate a CLI Generate a CLI from an OpenAPI specification with Fern. Follow the [CLI Generator quickstart](https://buildwithfern.com/learn/cli-generator/get-started/quickstart.md) step by step. To generate entirely on your own machine without sending your spec to Fern, [run generation locally](/learn/cli-generator/get-started/local-generation) with `--local`. ## Prerequisites * [Fern CLI](https://www.npmjs.com/package/fern-api) v5.37.9 or later (`npm install -g fern-api`) * [Rust toolchain](https://rustup.rs/) (stable) * An OpenAPI 3.x spec with at least one endpoint ## Setup #### Initialize a Fern project ```bash mkdir my-api-config && cd my-api-config fern init --organization my-org ``` This creates a `fern/` directory containing the default configuration files. #### Add your OpenAPI spec Place your spec at `fern/openapi.yml` (or any path you reference in the next step). The spec must include at least one path, and any `securitySchemes` declared under `components` become the credentials the CLI [reads at runtime](/learn/cli-generator/get-started/authentication). #### Configure the generator Replace the contents of `fern/generators.yml`: **`fern/generators.yml`** ```yaml title="fern/generators.yml" api: specs: - openapi: openapi.yml default-group: cli groups: cli: generators: - name: fern-cli-generator version: 0.40.0 output: location: local-file-system path: ../my-cli config: binaryName: my-cli ``` The `path` is relative to the `fern/` directory, so this writes the generated Rust project to a sibling `my-cli/` directory. To ship the CLI to npm, Homebrew, or GitHub Releases instead of building it locally, configure a [publishing target](/learn/cli-generator/get-started/publishing). #### Generate the CLI ```bash fern generate --group cli ``` Fern reads the OpenAPI spec, runs the CLI generator, and writes a complete Rust project to the output path. #### Build and run ```bash cd ../my-cli cargo build ./target/debug/my-cli --help ``` The `--help` output shows the full command tree: top-level commands derived from OpenAPI tags with [help text](/learn/cli-generator/get-started/openapi-extensions#command-group-help) from their tag descriptions, subcommands from individual operations, and built-in utilities like `completion` and `man`. #### Customize the output * Rename commands, hide endpoints, or patch metadata without forking your spec by layering [overrides and overlays](/learn/cli-generator/get-started/customization#overrides-and-overlays) onto `generators.yml`. * Ship one binary that drives multiple APIs by listing them under `api.specs` with [multi-spec merging](/learn/cli-generator/get-started/customization#multi-spec-merging). * Add subcommands that don't map to an endpoint — login flows, config helpers, local utilities — with [custom commands](/learn/cli-generator/get-started/customization#custom-commands). ## Next steps #### [Publish your CLI](/learn/cli-generator/get-started/publishing) Ship to npm, Homebrew, and GitHub Releases with automated cross-platform builds and CI. #### [Self-hosted generation](/learn/cli-generator/get-started/local-generation) Generate on your own machine with Docker, keeping your spec off Fern's infrastructure. > Generate a working CLI binary from an OpenAPI spec in five steps.