> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fish.audio/llms.txt
> Use this file to discover all available pages before exploring further.

# Test Voice Agent Custom LLM Endpoint

> Check that the custom LLM saved on the agent's draft works before you publish

Fish sends one streamed chat-completions turn to the endpoint saved in the agent's draft `llm.custom`, using its `base_url`, `model`, API key and headers, with the draft's system prompt and tools, and reports what came back. The request has no body.

The test reads the draft, so a change you save with [Update Voice Agent Draft Config](https://docs.fish.audio/api-reference/endpoint/agent/update-draft-config.md) can be tested right away. Calls use the published version, so [publish](https://docs.fish.audio/api-reference/endpoint/agent/publish-agent.md) once the test passes. To test a different endpoint, save it to `llm.custom` first. An agent with no custom LLM, or one saved without an API key, returns `422`, and so does a request body with any field.

A problem with your endpoint is not an HTTP error. An unreachable or blocked host, a timeout, a non-2xx reply, or a reply that isn't a server-sent-event stream all return `200`; read `error` and `status_code` to see what went wrong, not the HTTP status. To branch on the outcome, use `type` and `reason`. They take the same values as `llm_endpoint_errors` in [Get Voice Agent Session](https://docs.fish.audio/api-reference/endpoint/agent/get-agent-session.md), so an error you find here is the one you would see on a call. `error` is a readable explanation that can change, so don't match on its text.

The test sends one turn and doesn't retry. It waits up to 10 seconds for the response headers and 10 seconds for the first content, gives up after 20 seconds in total, reads at most 256 KB of the reply, and doesn't follow redirects. Your key and custom headers are never logged or returned; if your endpoint's reply quotes them, they are masked in `error`.

Each team can make 30 calls per minute to this endpoint. The 31st call within the same minute returns `429`, and the count starts again in the next minute.

For setup in the console and the `llm.custom` fields, see [Custom LLM](https://docs.fish.audio/agents/build/custom-llm.md).


## OpenAPI

````yaml post /v1/agent/agents/{agent_id}/llm/custom/test
openapi: 3.1.0
info:
  title: FishAudio OpenAPI
  version: '1'
servers:
  - description: Fish Audio API
    url: https://api.fish.audio
security: []
tags: []
paths:
  /v1/agent/agents/{agent_id}/llm/custom/test:
    post:
      tags:
        - Agents
      summary: Test Custom LLM Endpoint
      description: >-
        Check that the agent's saved custom LLM works. Fish sends one streamed

        chat-completions turn to the endpoint saved in the draft's `llm.custom`,

        using its `base_url`, `model`, API key and headers, with the draft's

        system prompt, a fixed user message and the draft's tools, and reports

        what came back. There is no request body.


        The test reads the draft, so a change saved with

        `PATCH /v1/agent/agents/{agent_id}/config` can be tested right away.
        Calls use the published version: publish once the

        test passes. To test a different endpoint, save it to `llm.custom`
        first.

        An agent with no custom LLM, or one saved without an API key, returns
        422.

        Any request body field also returns 422.


        Problems with your endpoint (unreachable or blocked host, timeout, a

        non-2xx status, a reply that is not a server-sent-event stream) are not

        HTTP errors: the call returns 200 and `error` says what went wrong. To

        branch on the outcome, read `type` and `reason`: they use the same
        values

        as `llm_endpoint_errors` in the session detail, so an error found here
        is

        the one you would see on a call. `error` stays as a readable
        explanation.


        The test itself has fixed limits. It sends one turn and does not retry.

        Fish waits up to 10 seconds for the response headers and up to 10
        seconds

        for the first content, and gives up after 20 seconds in total. It reads
        at

        most 256 KB of the response and does not follow redirects. The API key
        and

        your custom headers are never written to logs or echoed back; where your

        endpoint's reply quotes them, they are masked in `error`.


        Each team can make 30 of these calls per minute; the 31st within the
        same

        minute returns 429 and the count starts again the next minute.
      parameters:
        - in: path
          name: agent_id
          description: ''
          required: true
          schema:
            title: Agent Id
            type: string
          deprecated: false
      responses:
        '200':
          description: Request fulfilled, document follows
          headers: {}
          content:
            application/json:
              schema:
                description: >-
                  Result of testing a custom LLM endpoint. A problem with your
                  endpoint is

                  reported here, not as an HTTP error: `error` explains it and
                  `type` and

                  `reason` name it.
                properties:
                  status_code:
                    anyOf:
                      - type: integer
                      - type: 'null'
                    default: null
                    description: >-
                      HTTP status your endpoint returned; null when it was never
                      reached.
                    title: Status Code
                  streams_content:
                    default: false
                    description: >-
                      True when your endpoint streamed at least one chunk with
                      text or a tool call.
                    title: Streams Content
                    type: boolean
                  tools_sent:
                    default: 0
                    description: >-
                      Number of the agent's tools included in the request, in
                      OpenAI function format.
                    title: Tools Sent
                    type: integer
                  tool_calls_returned:
                    default: 0
                    description: Number of distinct tool calls your endpoint streamed back.
                    title: Tool Calls Returned
                    type: integer
                  ttft_ms:
                    anyOf:
                      - type: integer
                      - type: 'null'
                    default: null
                    description: >-
                      Milliseconds from sending the request to the first chunk
                      with text or a tool call; null when none arrived.
                    title: Ttft Ms
                  latency_ms:
                    description: Total test time in milliseconds.
                    title: Latency Ms
                    type: integer
                  error:
                    anyOf:
                      - type: string
                      - type: 'null'
                    default: null
                    description: >-
                      Readable explanation when the test failed; null on
                      success. It is written for people and may change, so
                      branch on `type` and `reason` instead.
                    title: Error
                  type:
                    anyOf:
                      - enum:
                          - http_error
                          - timeout
                          - connection_error
                          - invalid_response
                        type: string
                      - type: 'null'
                    default: null
                    description: >-
                      Kind of failure, with the same values as `type` in a
                      session's `llm_endpoint_errors`: `http_error` (your
                      endpoint answered with a non-2xx status), `timeout`,
                      `connection_error` (no answer) or `invalid_response` (a
                      2xx reply that was not usable). Null when the test
                      succeeded.
                    title: Type
                  reason:
                    anyOf:
                      - enum:
                          - dns_failed
                          - connection_refused
                          - connection_reset
                          - tls_failed
                          - address_not_allowed
                          - not_event_stream
                          - stream_incomplete
                          - empty_reply
                          - refused
                          - unknown
                        type: string
                      - type: 'null'
                    default: null
                    description: >-
                      Detail for `connection_error` and `invalid_response`, with
                      the same values as `reason` in `llm_endpoint_errors`. For
                      `connection_error`: `dns_failed`, `connection_refused`,
                      `connection_reset`, `tls_failed`, `address_not_allowed`
                      (an address Fish does not call) or `unknown`. For
                      `invalid_response`: `not_event_stream` (the reply was not
                      a stream), `empty_reply` (no text and no tool call) or
                      `unknown` (the stream carried an error). Null otherwise.
                    title: Reason
                required:
                  - latency_ms
                type: object
        '401':
          description: No permission -- see authorization schemes
          headers: {}
          content:
            application/json:
              schema:
                properties:
                  status:
                    title: Status
                    type: integer
                  message:
                    title: Message
                    type: string
                  reason:
                    anyOf:
                      - type: string
                      - type: 'null'
                    default: null
                    title: Reason
                required:
                  - status
                  - message
                type: object
        '404':
          description: Nothing matches the given URI
          headers: {}
          content:
            application/json:
              schema:
                properties:
                  status:
                    title: Status
                    type: integer
                  message:
                    title: Message
                    type: string
                  reason:
                    anyOf:
                      - type: string
                      - type: 'null'
                    default: null
                    title: Reason
                required:
                  - status
                  - message
                type: object
        '422':
          description: ''
          headers: {}
          content:
            application/json:
              schema:
                properties:
                  status:
                    title: Status
                    type: integer
                  message:
                    title: Message
                    type: string
                  reason:
                    anyOf:
                      - type: string
                      - type: 'null'
                    default: null
                    title: Reason
                required:
                  - status
                  - message
                type: object
        '429':
          description: >-
            The user has sent too many requests in a given amount of time ("rate
            limiting")
          headers: {}
          content:
            application/json:
              schema:
                properties:
                  status:
                    title: Status
                    type: integer
                  message:
                    title: Message
                    type: string
                  reason:
                    anyOf:
                      - type: string
                      - type: 'null'
                    default: null
                    title: Reason
                required:
                  - status
                  - message
                type: object
        '503':
          description: The server cannot process the request due to a high load
          headers: {}
          content:
            application/json:
              schema:
                properties:
                  status:
                    title: Status
                    type: integer
                  message:
                    title: Message
                    type: string
                  reason:
                    anyOf:
                      - type: string
                      - type: 'null'
                    default: null
                    title: Reason
                required:
                  - status
                  - message
                type: object
      security:
        - BearerAuth: []
      x-codeSamples:
        - lang: bash
          label: Test Custom LLM Endpoint
          source: |-
            curl --request POST \
              --url https://api.fish.audio/v1/agent/agents/<agent-id>/llm/custom/test \
              --header 'Authorization: Bearer <token>'
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.