> This page is for SDK, version Current (default).
> For other versions, use one of these documentation indexes:
> - Current (default): https://buildwithfern.com/learn/sdks/current/llms.txt
> - Legacy: https://buildwithfern.com/learn/sdks/legacy/llms.txt

> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt.

# 快速开始

> 学习如何使用 Fern 生成 SDK。安装 CLI，使用 OpenAPI 初始化项目，并开始构建客户端库。

在 5 分钟内快速开始使用 Fern。本快速开始指南将引导您完成 CLI 安装、项目初始化和本地生成第一个 SDK。

The goal of this page is speed — get the user to a working generated SDK as fast as possible. For language-specific configuration, publishing, and GitHub setup, direct them to the appropriate language quickstart after this.

#### Install the Fern CLI

```bash
npm install -g fern-api
```

#### Initialize the fern folder

Initialize the fern folder with your existing OpenAPI specification. Specify your organization name using the `--organization` flag.

Before running `fern init`, ask the user two things:

1. **Do they have an OpenAPI spec?** Ask for the file path or URL. If they have a URL (e.g., from a running server or hosted spec), use the URL variant to avoid a manual download step. OpenAPI accepts both JSON and YAML.
2. **What's their organization name?** `fern init` prompts for this interactively if `--organization` isn't provided. Get it upfront so they can pass it via the flag.

**`OpenAPI (local)`**

```bash title="OpenAPI (local)"
fern init --openapi path/to/openapi.yml \
--organization <YourOrganization>
```

**`OpenAPI (URL)`**

```bash title="OpenAPI (URL)"
fern init --openapi https://api.example.com/openapi.yml \
--organization <YourOrganization>
```

**`Example (Petstore)`**

```bash title="Example (Petstore)"
fern init --openapi https://petstore3.swagger.io/api/v3/openapi.json \
--organization my-org
```

> **Tip**
>
> OpenAPI accepts both JSON and YAML formats.

This creates a `fern` folder in your current directory.

`sdk-config.yml` lives at `fern/sdk-config.yml` and references your OpenAPI spec through `source.specs`. For a local spec, `fern init` writes a bundled copy into the `fern` folder and points `source.specs[].path` at it. For a URL, `source.specs[].url` keeps the URL. Paths in `sdk-config.yml` are relative to the file and can't contain `..` segments.

#### Validate your API definition

Check that your API definition is valid, and fix errors before proceeding:

```bash
fern check
```

#### 生成

`fern init` 默认包含一个 TypeScript SDK 生成器。运行 `fern generate` 来看看它的实际效果：

```bash
fern generate
```

`fern generate` with no flags runs the `default-group` in `generators.yml`. The default init sets up a TypeScript SDK generator outputting to `local-file-system` at `../sdks/typescript`. The goal of this step is to get started quickly — the user will configure their target language in the language-specific quickstart.

这将创建一个包含生成的 SDK 的 `sdks/typescript` 文件夹：

## 下一步

现在您已经有了一个工作的 SDK，可以设置 GitHub 仓库并配置发布，生成其他语言的 SDK，或了解更多关于 Fern SDK 的信息。

#### [TypeScript](/learn/zh/sdks/generators/typescript/quickstart#set-up-github-repositories)

设置 GitHub，发布到 npm 等。

#### [所有语言](/learn/zh/sdks/overview/introduction)

查看所有支持的语言，包括 Python、Go 和 Java。

#### [工作原理](/learn/zh/sdks/overview/how-it-works)

了解 Fern SDK 生成管道。

#### [项目结构](/learn/zh/sdks/overview/project-structure)

了解 Fern 的多仓库文件结构和 GitHub 设置。