Display SDK snippets
If you use Fern to generate SDKs, you can display SDK code snippets in your API Reference. These snippets show examples using your actual SDK in TypeScript, Python, Go, and other supported languages.
Once configured, SDK snippets replace HTTP snippets.
By default, SDK snippets are dynamic code examples that allow users to modify parameters and see code examples update in real time across all supported languages.
Alternatively, you can disable dynamic snippets in your docs.yml and use static code examples.

Configuration
Fern needs to read request examples from your API definition to generate code snippets. For OpenAPI, follow Swagger’s examples documentation.
Then follow the steps for the file you generate SDKs with.
sdk-config.yml
generators.yml
With sdk-config.yml, Fern stores the snippets from each SDK build on its servers. fern generate --docs fetches them and adds them to your API Reference endpoints. This works for TypeScript, Python, Java, Go, Ruby, C#, and PHP SDKs.
Requires Fern CLI version 5.188.0 or later. Run fern upgrade to update.
Enable snippets in sdk-config.yml
Set docs.snippets.enabled to true at the top level, where every target inherits it, or in a single target’s docs block. Fern finds each SDK’s build by its sdkName, so the target needs an sdkName of its own or the top-level one.
Add the SDK version to docs.yml
Under your api: entry, add a snippets entry for each language you build, with the version you’re about to build. List only the languages you build.
Build the SDKs at that version
Run fern generate to build the SDKs with a new version that matches the version in docs.yml. Fern reads snippets only from a successful build made with snippets enabled, and uses the newest such build of each language with a matching sdkName and version.
Generate the docs
Run fern generate --docs. The output includes a line such as Loaded SDK snippets (python: 12, typescript: 12) with the number of endpoint snippets read for each language, and the snippets appear in the language dropdown on each endpoint. A code sample you wrote for an endpoint in the same language takes precedence over the generated snippet.
If Fern can’t find or read the snippets for a language, the CLI logs a warning and publishes the docs without them.
Additional options
Set default snippet language
Use the default-language key at the top indentation level of docs.yml. This setting applies to both SDK snippets and HTTP snippets.
Endpoint request and response snippets
Looking for information on generating API endpoint request and response snippets? See our documentation on Endpoint Request Snippets and Endpoint Response Snippets.