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/docs/api-references/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiJjMzAzMTI0Ny0xYzFiLTRjYmQtYTI3MC03OGM1YWJlM2RiZjYiLCJleHAiOjE3NzY3MTMxOTksImlhdCI6MTc3NjcxMjg5OX0.1wgJN70z-Thk2jpj-rTma_FM7ydeOQxKD9q5m9BlCk4

---

***

title: Generate WebSocket Reference
description: Use Fern Docs to generate WebSocket Reference documentation from an AsyncAPI spec or Fern Definition.
---------------------

For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

Fern generates WebSocket Reference documentation from an [AsyncAPI specification](/learn/api-definitions/asyncapi/overview) or [Fern Definition](/learn/api-definitions/ferndef/websockets).

<Frame caption={<a href="https://developers.deepgram.com/reference/text-to-speech/speak-streaming">Example of how a WebSocket API Reference renders in Fern</a>}>
  <img src="https://files.buildwithfern.com/fern.docs.buildwithfern.com/learn/cbf139902e8f0409a80fdef4b4da17073b1f691a59767f11f743052f4d01019a/products/docs/pages/api-references/websocket-deepgram.png" alt="WebSocket API Reference Example" />
</Frame>

## Configuration

<Steps>
  <Step title="Set up your project structure">
    For **AsyncAPI**: Add your specification file to your `/fern` directory and create a `generators.yml` that references it:

    ```yaml generators.yml
    api:
      path: asyncapi.yml
      origin: https://github.com/your-org/your-repo/blob/main/asyncapi.yml # optional
    ```

    For **Fern Definition**: Add your WebSocket definition files to a `definition/` directory (Fern auto-detects this).
  </Step>

  <Step title="Add the WebSocket Reference to your navigation">
    Add `- api: API Reference` to your navigation in `docs.yml`:

    ```yml docs.yml
    navigation:
      - api: API Reference
    ```
  </Step>

  <Step title="Customize the layout">
    For a full list of configuration options and layout customizations, see [Customize API Reference layout](/learn/docs/api-references/customize-api-reference-layout).
  </Step>
</Steps>

### Include more than one WebSocket Reference

To include multiple WebSocket definitions in your documentation, use the `api-name` property. The `api-name` corresponds to the folder name containing your WebSocket definition.

<Files>
  <Folder name="fern" defaultOpen>
    <File name="fern.config.json" />

    <File name="docs.yml" />

    <Folder name="streaming-api" defaultOpen>
      <File name="asyncapi.yml" comment="Streaming WebSocket AsyncAPI spec" />

      <File name="generators.yml" />
    </Folder>

    <Folder name="realtime-api" defaultOpen>
      <File name="asyncapi.yml" comment="Realtime WebSocket AsyncAPI spec" />

      <File name="generators.yml" />
    </Folder>
  </Folder>
</Files>

```yaml title="docs.yml"
navigation:
  - api: Streaming API
    api-name: streaming-api
  - api: Realtime API
    api-name: realtime-api
```