> This page is for Docs.

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

# Endpoint schema snippet

> Reference an endpoint schema from your API Reference

The `<EndpointSchemaSnippet>` component displays endpoint schemas from your API Reference. By default, it renders the complete schema, or you can use the `selector` prop to display specific parts like request body, response, path parameters, or query parameters. When AI agents fetch the [Markdown version](/learn/docs/ai-features/markdown) of a page, Fern renders the schema — field names, types, and descriptions — as structured content in the Markdown output.

To display any type definition by name (not limited to endpoint schemas), use the [`<Schema>`](/learn/docs/writing-content/components/schema) component.

> **Note**
>
> Markdown-rich field descriptions aren't yet supported and will display as plain text. See the [Request path](#request-path) example below.

## Usage

### Schema

```yaml
openapi: 3.1.0
info:
  title: API
  version: 1.0.0
paths:
  /chat/{domain}:
    post:
      operationId: subpackageChat_post_chat_completion
      summary: Post Chat Completion
      tags:
        - subpackage_chat
      parameters:
        - name: domain
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostChatCompletionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostChatCompletionRequest'
tags:
  - name: subpackage_chat
servers:
  - url: https://fai.buildwithfern.com
    description: Production
  - url: https://fai-dev.buildwithfern.com
    description: Development
  - url: http://localhost:8080
    description: Local
components:
  schemas:
    LanguageModel:
      type: string
      enum:
        - claude-4-sonnet
        - claude-4.5-haiku
        - claude-4.5-sonnet
        - claude-4.6-sonnet
      title: LanguageModel
    ChatMessageRole:
      type: string
      enum:
        - user
        - assistant
      title: ChatMessageRole
    ChatMessage:
      type: object
      properties:
        role:
          $ref: '#/components/schemas/ChatMessageRole'
        content:
          type: string
      required:
        - role
        - content
      title: ChatMessage
    PostChatCompletionRequest:
      type: object
      properties:
        model:
          oneOf:
            - $ref: '#/components/schemas/LanguageModel'
            - type: 'null'
          description: The model to use for the chat completion
        max_tokens:
          type:
            - integer
            - 'null'
          minimum: 100
          maximum: 3500
          default: 3000
          description: >-
            The maximum number of tokens to generate. Note: setting a token
            count lower than 2000 may result in incomplete responses. You can
            add a custom system prompt to control the verbosity of the response.
        system_prompt:
          type:
            - string
            - 'null'
          description: The system prompt to use for the chat completion
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: The messages to use for the chat completion
        rewrite_query:
          type:
            - boolean
            - 'null'
          default: false
          description: Whether to rewrite the query using query decomposition
        user_is_authed:
          type: boolean
          default: false
          description: >-
            Whether the requesting user is authenticated. When true, authed
            chunks are included in results.
        allowed_roles:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Roles the authenticated user has. Used to filter chunks by
            role-based access control.
        source:
          type:
            - string
            - 'null'
          description: The origin of the request (e.g. 'web', 'slack', 'api').
        basepaths:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Restrict retrieval to pages under these URL path prefixes (e.g.
            ['/my-product']). Matches the scoping the Ask AI widget applies when
            embedded under a product path. Omit to search the whole site.
        skip_save_query:
          type: boolean
          default: false
          description: >-
            Set to true for test or eval traffic. The request is answered (and
            billed) normally but is excluded from usage analytics.
      required:
        - messages
      title: PostChatCompletionRequest
    ChatSource:
      type: object
      properties:
        url:
          type: string
          description: URL of the cited documentation page
        title:
          type: string
          description: Title of the cited documentation page
      required:
        - url
        - title
      title: ChatSource
    PostChatCompletionResponse:
      type: object
      properties:
        turns:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: The conversation turns in the chat completion
        citations:
          type: array
          items:
            type: string
          description: List of citation strings
        sources:
          type: array
          items:
            $ref: '#/components/schemas/ChatSource'
          description: Pages the answer was grounded in, one entry per cited page
      required:
        - turns
        - citations
      title: PostChatCompletionResponse
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError

```

**`Markdown`**

```jsx Markdown
<EndpointSchemaSnippet endpoint="POST /chat/{domain}" />

```

## Variants

### Full request

Passing `request` as the selector will only render the request schema.

### Schema (`request`)

```yaml
openapi: 3.1.0
info:
  title: API
  version: 1.0.0
paths:
  /chat/{domain}:
    post:
      operationId: subpackageChat_post_chat_completion
      summary: Post Chat Completion
      tags:
        - subpackage_chat
      parameters:
        - name: domain
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostChatCompletionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostChatCompletionRequest'
tags:
  - name: subpackage_chat
servers:
  - url: https://fai.buildwithfern.com
    description: Production
  - url: https://fai-dev.buildwithfern.com
    description: Development
  - url: http://localhost:8080
    description: Local
components:
  schemas:
    LanguageModel:
      type: string
      enum:
        - claude-4-sonnet
        - claude-4.5-haiku
        - claude-4.5-sonnet
        - claude-4.6-sonnet
      title: LanguageModel
    ChatMessageRole:
      type: string
      enum:
        - user
        - assistant
      title: ChatMessageRole
    ChatMessage:
      type: object
      properties:
        role:
          $ref: '#/components/schemas/ChatMessageRole'
        content:
          type: string
      required:
        - role
        - content
      title: ChatMessage
    PostChatCompletionRequest:
      type: object
      properties:
        model:
          oneOf:
            - $ref: '#/components/schemas/LanguageModel'
            - type: 'null'
          description: The model to use for the chat completion
        max_tokens:
          type:
            - integer
            - 'null'
          minimum: 100
          maximum: 3500
          default: 3000
          description: >-
            The maximum number of tokens to generate. Note: setting a token
            count lower than 2000 may result in incomplete responses. You can
            add a custom system prompt to control the verbosity of the response.
        system_prompt:
          type:
            - string
            - 'null'
          description: The system prompt to use for the chat completion
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: The messages to use for the chat completion
        rewrite_query:
          type:
            - boolean
            - 'null'
          default: false
          description: Whether to rewrite the query using query decomposition
        user_is_authed:
          type: boolean
          default: false
          description: >-
            Whether the requesting user is authenticated. When true, authed
            chunks are included in results.
        allowed_roles:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Roles the authenticated user has. Used to filter chunks by
            role-based access control.
        source:
          type:
            - string
            - 'null'
          description: The origin of the request (e.g. 'web', 'slack', 'api').
        basepaths:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Restrict retrieval to pages under these URL path prefixes (e.g.
            ['/my-product']). Matches the scoping the Ask AI widget applies when
            embedded under a product path. Omit to search the whole site.
        skip_save_query:
          type: boolean
          default: false
          description: >-
            Set to true for test or eval traffic. The request is answered (and
            billed) normally but is excluded from usage analytics.
      required:
        - messages
      title: PostChatCompletionRequest
    ChatSource:
      type: object
      properties:
        url:
          type: string
          description: URL of the cited documentation page
        title:
          type: string
          description: Title of the cited documentation page
      required:
        - url
        - title
      title: ChatSource
    PostChatCompletionResponse:
      type: object
      properties:
        turns:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: The conversation turns in the chat completion
        citations:
          type: array
          items:
            type: string
          description: List of citation strings
        sources:
          type: array
          items:
            $ref: '#/components/schemas/ChatSource'
          description: Pages the answer was grounded in, one entry per cited page
      required:
        - turns
        - citations
      title: PostChatCompletionResponse
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError

```

**`Markdown`**

```jsx Markdown
<EndpointSchemaSnippet endpoint="POST /chat/{domain}" selector="request" />
```

### Request path

### Schema (`request.path`)

```yaml
openapi: 3.1.0
info:
  title: API
  version: 1.0.0
paths:
  /chat/{domain}:
    post:
      operationId: subpackageChat_post_chat_completion
      summary: Post Chat Completion
      tags:
        - subpackage_chat
      parameters:
        - name: domain
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostChatCompletionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostChatCompletionRequest'
tags:
  - name: subpackage_chat
servers:
  - url: https://fai.buildwithfern.com
    description: Production
  - url: https://fai-dev.buildwithfern.com
    description: Development
  - url: http://localhost:8080
    description: Local
components:
  schemas:
    LanguageModel:
      type: string
      enum:
        - claude-4-sonnet
        - claude-4.5-haiku
        - claude-4.5-sonnet
        - claude-4.6-sonnet
      title: LanguageModel
    ChatMessageRole:
      type: string
      enum:
        - user
        - assistant
      title: ChatMessageRole
    ChatMessage:
      type: object
      properties:
        role:
          $ref: '#/components/schemas/ChatMessageRole'
        content:
          type: string
      required:
        - role
        - content
      title: ChatMessage
    PostChatCompletionRequest:
      type: object
      properties:
        model:
          oneOf:
            - $ref: '#/components/schemas/LanguageModel'
            - type: 'null'
          description: The model to use for the chat completion
        max_tokens:
          type:
            - integer
            - 'null'
          minimum: 100
          maximum: 3500
          default: 3000
          description: >-
            The maximum number of tokens to generate. Note: setting a token
            count lower than 2000 may result in incomplete responses. You can
            add a custom system prompt to control the verbosity of the response.
        system_prompt:
          type:
            - string
            - 'null'
          description: The system prompt to use for the chat completion
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: The messages to use for the chat completion
        rewrite_query:
          type:
            - boolean
            - 'null'
          default: false
          description: Whether to rewrite the query using query decomposition
        user_is_authed:
          type: boolean
          default: false
          description: >-
            Whether the requesting user is authenticated. When true, authed
            chunks are included in results.
        allowed_roles:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Roles the authenticated user has. Used to filter chunks by
            role-based access control.
        source:
          type:
            - string
            - 'null'
          description: The origin of the request (e.g. 'web', 'slack', 'api').
        basepaths:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Restrict retrieval to pages under these URL path prefixes (e.g.
            ['/my-product']). Matches the scoping the Ask AI widget applies when
            embedded under a product path. Omit to search the whole site.
        skip_save_query:
          type: boolean
          default: false
          description: >-
            Set to true for test or eval traffic. The request is answered (and
            billed) normally but is excluded from usage analytics.
      required:
        - messages
      title: PostChatCompletionRequest
    ChatSource:
      type: object
      properties:
        url:
          type: string
          description: URL of the cited documentation page
        title:
          type: string
          description: Title of the cited documentation page
      required:
        - url
        - title
      title: ChatSource
    PostChatCompletionResponse:
      type: object
      properties:
        turns:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: The conversation turns in the chat completion
        citations:
          type: array
          items:
            type: string
          description: List of citation strings
        sources:
          type: array
          items:
            $ref: '#/components/schemas/ChatSource'
          description: Pages the answer was grounded in, one entry per cited page
      required:
        - turns
        - citations
      title: PostChatCompletionResponse
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError

```

**`Markdown`**

```jsx Markdown
<EndpointSchemaSnippet endpoint="POST /chat/{domain}" selector="request.path" />
```

### Request query

### Schema (`request.query`)

```yaml
openapi: 3.1.0
info:
  title: API
  version: 1.0.0
paths:
  /chat/{domain}:
    post:
      operationId: subpackageChat_post_chat_completion
      summary: Post Chat Completion
      tags:
        - subpackage_chat
      parameters:
        - name: domain
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostChatCompletionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostChatCompletionRequest'
tags:
  - name: subpackage_chat
servers:
  - url: https://fai.buildwithfern.com
    description: Production
  - url: https://fai-dev.buildwithfern.com
    description: Development
  - url: http://localhost:8080
    description: Local
components:
  schemas:
    LanguageModel:
      type: string
      enum:
        - claude-4-sonnet
        - claude-4.5-haiku
        - claude-4.5-sonnet
        - claude-4.6-sonnet
      title: LanguageModel
    ChatMessageRole:
      type: string
      enum:
        - user
        - assistant
      title: ChatMessageRole
    ChatMessage:
      type: object
      properties:
        role:
          $ref: '#/components/schemas/ChatMessageRole'
        content:
          type: string
      required:
        - role
        - content
      title: ChatMessage
    PostChatCompletionRequest:
      type: object
      properties:
        model:
          oneOf:
            - $ref: '#/components/schemas/LanguageModel'
            - type: 'null'
          description: The model to use for the chat completion
        max_tokens:
          type:
            - integer
            - 'null'
          minimum: 100
          maximum: 3500
          default: 3000
          description: >-
            The maximum number of tokens to generate. Note: setting a token
            count lower than 2000 may result in incomplete responses. You can
            add a custom system prompt to control the verbosity of the response.
        system_prompt:
          type:
            - string
            - 'null'
          description: The system prompt to use for the chat completion
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: The messages to use for the chat completion
        rewrite_query:
          type:
            - boolean
            - 'null'
          default: false
          description: Whether to rewrite the query using query decomposition
        user_is_authed:
          type: boolean
          default: false
          description: >-
            Whether the requesting user is authenticated. When true, authed
            chunks are included in results.
        allowed_roles:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Roles the authenticated user has. Used to filter chunks by
            role-based access control.
        source:
          type:
            - string
            - 'null'
          description: The origin of the request (e.g. 'web', 'slack', 'api').
        basepaths:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Restrict retrieval to pages under these URL path prefixes (e.g.
            ['/my-product']). Matches the scoping the Ask AI widget applies when
            embedded under a product path. Omit to search the whole site.
        skip_save_query:
          type: boolean
          default: false
          description: >-
            Set to true for test or eval traffic. The request is answered (and
            billed) normally but is excluded from usage analytics.
      required:
        - messages
      title: PostChatCompletionRequest
    ChatSource:
      type: object
      properties:
        url:
          type: string
          description: URL of the cited documentation page
        title:
          type: string
          description: Title of the cited documentation page
      required:
        - url
        - title
      title: ChatSource
    PostChatCompletionResponse:
      type: object
      properties:
        turns:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: The conversation turns in the chat completion
        citations:
          type: array
          items:
            type: string
          description: List of citation strings
        sources:
          type: array
          items:
            $ref: '#/components/schemas/ChatSource'
          description: Pages the answer was grounded in, one entry per cited page
      required:
        - turns
        - citations
      title: PostChatCompletionResponse
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError

```

**`Markdown`**

```jsx Markdown
<EndpointSchemaSnippet endpoint="POST /chat/{domain}" selector="request.query" />
```

### Request body

### Schema (`request.body`)

```yaml
openapi: 3.1.0
info:
  title: API
  version: 1.0.0
paths:
  /chat/{domain}:
    post:
      operationId: subpackageChat_post_chat_completion
      summary: Post Chat Completion
      tags:
        - subpackage_chat
      parameters:
        - name: domain
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostChatCompletionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostChatCompletionRequest'
tags:
  - name: subpackage_chat
servers:
  - url: https://fai.buildwithfern.com
    description: Production
  - url: https://fai-dev.buildwithfern.com
    description: Development
  - url: http://localhost:8080
    description: Local
components:
  schemas:
    LanguageModel:
      type: string
      enum:
        - claude-4-sonnet
        - claude-4.5-haiku
        - claude-4.5-sonnet
        - claude-4.6-sonnet
      title: LanguageModel
    ChatMessageRole:
      type: string
      enum:
        - user
        - assistant
      title: ChatMessageRole
    ChatMessage:
      type: object
      properties:
        role:
          $ref: '#/components/schemas/ChatMessageRole'
        content:
          type: string
      required:
        - role
        - content
      title: ChatMessage
    PostChatCompletionRequest:
      type: object
      properties:
        model:
          oneOf:
            - $ref: '#/components/schemas/LanguageModel'
            - type: 'null'
          description: The model to use for the chat completion
        max_tokens:
          type:
            - integer
            - 'null'
          minimum: 100
          maximum: 3500
          default: 3000
          description: >-
            The maximum number of tokens to generate. Note: setting a token
            count lower than 2000 may result in incomplete responses. You can
            add a custom system prompt to control the verbosity of the response.
        system_prompt:
          type:
            - string
            - 'null'
          description: The system prompt to use for the chat completion
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: The messages to use for the chat completion
        rewrite_query:
          type:
            - boolean
            - 'null'
          default: false
          description: Whether to rewrite the query using query decomposition
        user_is_authed:
          type: boolean
          default: false
          description: >-
            Whether the requesting user is authenticated. When true, authed
            chunks are included in results.
        allowed_roles:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Roles the authenticated user has. Used to filter chunks by
            role-based access control.
        source:
          type:
            - string
            - 'null'
          description: The origin of the request (e.g. 'web', 'slack', 'api').
        basepaths:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Restrict retrieval to pages under these URL path prefixes (e.g.
            ['/my-product']). Matches the scoping the Ask AI widget applies when
            embedded under a product path. Omit to search the whole site.
        skip_save_query:
          type: boolean
          default: false
          description: >-
            Set to true for test or eval traffic. The request is answered (and
            billed) normally but is excluded from usage analytics.
      required:
        - messages
      title: PostChatCompletionRequest
    ChatSource:
      type: object
      properties:
        url:
          type: string
          description: URL of the cited documentation page
        title:
          type: string
          description: Title of the cited documentation page
      required:
        - url
        - title
      title: ChatSource
    PostChatCompletionResponse:
      type: object
      properties:
        turns:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: The conversation turns in the chat completion
        citations:
          type: array
          items:
            type: string
          description: List of citation strings
        sources:
          type: array
          items:
            $ref: '#/components/schemas/ChatSource'
          description: Pages the answer was grounded in, one entry per cited page
      required:
        - turns
        - citations
      title: PostChatCompletionResponse
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError

```

**`Markdown`**

```jsx Markdown
<EndpointSchemaSnippet endpoint="POST /chat/{domain}" selector="request.body" />
```

### Full response

Passing `response` as the selector will only render the response schema.

### Schema (`response`)

```yaml
openapi: 3.1.0
info:
  title: API
  version: 1.0.0
paths:
  /chat/{domain}:
    post:
      operationId: subpackageChat_post_chat_completion
      summary: Post Chat Completion
      tags:
        - subpackage_chat
      parameters:
        - name: domain
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostChatCompletionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostChatCompletionRequest'
tags:
  - name: subpackage_chat
servers:
  - url: https://fai.buildwithfern.com
    description: Production
  - url: https://fai-dev.buildwithfern.com
    description: Development
  - url: http://localhost:8080
    description: Local
components:
  schemas:
    LanguageModel:
      type: string
      enum:
        - claude-4-sonnet
        - claude-4.5-haiku
        - claude-4.5-sonnet
        - claude-4.6-sonnet
      title: LanguageModel
    ChatMessageRole:
      type: string
      enum:
        - user
        - assistant
      title: ChatMessageRole
    ChatMessage:
      type: object
      properties:
        role:
          $ref: '#/components/schemas/ChatMessageRole'
        content:
          type: string
      required:
        - role
        - content
      title: ChatMessage
    PostChatCompletionRequest:
      type: object
      properties:
        model:
          oneOf:
            - $ref: '#/components/schemas/LanguageModel'
            - type: 'null'
          description: The model to use for the chat completion
        max_tokens:
          type:
            - integer
            - 'null'
          minimum: 100
          maximum: 3500
          default: 3000
          description: >-
            The maximum number of tokens to generate. Note: setting a token
            count lower than 2000 may result in incomplete responses. You can
            add a custom system prompt to control the verbosity of the response.
        system_prompt:
          type:
            - string
            - 'null'
          description: The system prompt to use for the chat completion
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: The messages to use for the chat completion
        rewrite_query:
          type:
            - boolean
            - 'null'
          default: false
          description: Whether to rewrite the query using query decomposition
        user_is_authed:
          type: boolean
          default: false
          description: >-
            Whether the requesting user is authenticated. When true, authed
            chunks are included in results.
        allowed_roles:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Roles the authenticated user has. Used to filter chunks by
            role-based access control.
        source:
          type:
            - string
            - 'null'
          description: The origin of the request (e.g. 'web', 'slack', 'api').
        basepaths:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Restrict retrieval to pages under these URL path prefixes (e.g.
            ['/my-product']). Matches the scoping the Ask AI widget applies when
            embedded under a product path. Omit to search the whole site.
        skip_save_query:
          type: boolean
          default: false
          description: >-
            Set to true for test or eval traffic. The request is answered (and
            billed) normally but is excluded from usage analytics.
      required:
        - messages
      title: PostChatCompletionRequest
    ChatSource:
      type: object
      properties:
        url:
          type: string
          description: URL of the cited documentation page
        title:
          type: string
          description: Title of the cited documentation page
      required:
        - url
        - title
      title: ChatSource
    PostChatCompletionResponse:
      type: object
      properties:
        turns:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: The conversation turns in the chat completion
        citations:
          type: array
          items:
            type: string
          description: List of citation strings
        sources:
          type: array
          items:
            $ref: '#/components/schemas/ChatSource'
          description: Pages the answer was grounded in, one entry per cited page
      required:
        - turns
        - citations
      title: PostChatCompletionResponse
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError

```

**`Markdown`**

```jsx Markdown
<EndpointSchemaSnippet endpoint="POST /chat/{domain}" selector="response" />
```

### Response body

### Schema (`response.body`)

```yaml
openapi: 3.1.0
info:
  title: API
  version: 1.0.0
paths:
  /chat/{domain}:
    post:
      operationId: subpackageChat_post_chat_completion
      summary: Post Chat Completion
      tags:
        - subpackage_chat
      parameters:
        - name: domain
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostChatCompletionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostChatCompletionRequest'
tags:
  - name: subpackage_chat
servers:
  - url: https://fai.buildwithfern.com
    description: Production
  - url: https://fai-dev.buildwithfern.com
    description: Development
  - url: http://localhost:8080
    description: Local
components:
  schemas:
    LanguageModel:
      type: string
      enum:
        - claude-4-sonnet
        - claude-4.5-haiku
        - claude-4.5-sonnet
        - claude-4.6-sonnet
      title: LanguageModel
    ChatMessageRole:
      type: string
      enum:
        - user
        - assistant
      title: ChatMessageRole
    ChatMessage:
      type: object
      properties:
        role:
          $ref: '#/components/schemas/ChatMessageRole'
        content:
          type: string
      required:
        - role
        - content
      title: ChatMessage
    PostChatCompletionRequest:
      type: object
      properties:
        model:
          oneOf:
            - $ref: '#/components/schemas/LanguageModel'
            - type: 'null'
          description: The model to use for the chat completion
        max_tokens:
          type:
            - integer
            - 'null'
          minimum: 100
          maximum: 3500
          default: 3000
          description: >-
            The maximum number of tokens to generate. Note: setting a token
            count lower than 2000 may result in incomplete responses. You can
            add a custom system prompt to control the verbosity of the response.
        system_prompt:
          type:
            - string
            - 'null'
          description: The system prompt to use for the chat completion
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: The messages to use for the chat completion
        rewrite_query:
          type:
            - boolean
            - 'null'
          default: false
          description: Whether to rewrite the query using query decomposition
        user_is_authed:
          type: boolean
          default: false
          description: >-
            Whether the requesting user is authenticated. When true, authed
            chunks are included in results.
        allowed_roles:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Roles the authenticated user has. Used to filter chunks by
            role-based access control.
        source:
          type:
            - string
            - 'null'
          description: The origin of the request (e.g. 'web', 'slack', 'api').
        basepaths:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Restrict retrieval to pages under these URL path prefixes (e.g.
            ['/my-product']). Matches the scoping the Ask AI widget applies when
            embedded under a product path. Omit to search the whole site.
        skip_save_query:
          type: boolean
          default: false
          description: >-
            Set to true for test or eval traffic. The request is answered (and
            billed) normally but is excluded from usage analytics.
      required:
        - messages
      title: PostChatCompletionRequest
    ChatSource:
      type: object
      properties:
        url:
          type: string
          description: URL of the cited documentation page
        title:
          type: string
          description: Title of the cited documentation page
      required:
        - url
        - title
      title: ChatSource
    PostChatCompletionResponse:
      type: object
      properties:
        turns:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: The conversation turns in the chat completion
        citations:
          type: array
          items:
            type: string
          description: List of citation strings
        sources:
          type: array
          items:
            $ref: '#/components/schemas/ChatSource'
          description: Pages the answer was grounded in, one entry per cited page
      required:
        - turns
        - citations
      title: PostChatCompletionResponse
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError

```

**`Markdown`**

```jsx Markdown
<EndpointSchemaSnippet endpoint="POST /chat/{domain}" selector="response.body" />
```

## Properties

**`endpoint`** `string` — required

The endpoint to display, in the format `METHOD /path` (e.g., `POST /chat/{domain}`). If your API uses [namespaces](/learn/api-definitions/overview/project-structure#combined-sdks-from-multiple-apis), prefix with the namespace and `::` (e.g., `payments::POST /chat/{domain}`).

---

**`selector`** `string`

Selects a specific part of the endpoint schema to display. Supported values: `request`, `request.path`, `request.query`, `request.body`, `response`, `response.body`.

---