> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiJmZTkzYjhkZS1jZjE3LTQwOWQtYTVlNi0wNjI0Y2Q2NTdmNTYiLCJleHAiOjE3ODQzNTkxMzUsImlhdCI6MTc4NDM1ODgzNX0.1mTVJIqa8tnwPX0c9DkFe2QO_YXyigGmfKqqZOW9KqY
>
> 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.

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 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

```bash
mkdir my-api-config && cd my-api-config
fern init --organization my-org
```

This creates a `fern/` directory containing the default configuration files.

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).

Replace the contents of `fern/generators.yml`:

```yaml title="fern/generators.yml"
api:
  specs:
    - openapi: openapi.yml
default-group: cli
groups:
  cli:
    generators:go
      - name: fern-cli-generator
        version: 0.23.4
        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).

```bash
fern generate --group cli
```

Fern reads the OpenAPI spec, runs the CLI generator, and writes a complete Rust project to the output path.

```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, subcommands from individual operations, and built-in utilities like `completion` and `man`.

* 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

Ship to npm, Homebrew, and GitHub Releases with automated cross-platform builds and CI.

Generate on your own machine with Docker, keeping your spec off Fern's infrastructure.