> This page is for SDK, version Legacy.
> 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.

# Set up local SDK previews

> Learn how to set up local SDK previews with Fern's --preview flag. Test generated SDK code locally before publishing to iterate quickly.

> **You're viewing the legacy SDK docs**
>
> These pages cover SDK generation configured with `generators.yml`. New projects use `sdk-config.yml`, so see [the Current version of this page](/learn/sdks/deep-dives/local-previews) for up-to-date guidance. To move an existing project, follow the [SDK Config migration guide](/learn/sdks/legacy/generators/migration-guides/sdk-config), which walks through `fern sdk migrate`, and review the [`sdk-config.yml` reference](/learn/sdks/reference/sdk-config).

Once you configure your SDK, you can use the `--preview` flag to test generated
SDK code locally before publishing. This allows quick iteration on your SDK
as you develop:

```bash
# Preview all SDKs
fern generate --preview

# Preview SDK for a specific language
fern generate --group <language>-sdk --preview

```

`--preview` generates your SDK code into a local `.preview/` folder within your
`fern` folder. No changes are published to package managers or GitHub.

> **Tip**
>
> `--preview` preserves any custom code you added to your SDK.

## Example usage

Here's an example of how you can preview a Python SDK.

### Generator configuration

**`generators.yml`**

```yaml title="generators.yml" {4}
api: 
  path: ./path/to/openapi.yml
groups:
  python-sdk:
    generators:
      - name: fern-python-sdk
        version: 5.41.4
        output:
          location: pypi
          package-name: imdb
          token: ${PYPI_TOKEN}
        github:
          repository: imdb/imdb-python
        config:
          client_class_name: imdb
```

### Invoke the Fern CLI

```shell
fern generate --group python-sdk --preview
```

### Preview your SDK

The resulting folder structure will look like this: