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

# Model APIs Tool Assisted Chat Completions

> Chat completions with built-in tool calling on Friendli Model APIs. The model automatically invokes tools like web search during generation.

Given a list of messages forming a conversation, the model generates a response. Additionally, the model can utilize built-in tools for tool calls, enhancing its capability to provide more comprehensive and actionable responses.

See available models at [this pricing table](/guides/model-apis/pricing#billing-methods).

To request successfully, it is mandatory to enter a **Personal API Key** (e.g. flp\_XXX) value in the **Bearer Token** field.
Refer to the [authentication section](/openapi/introduction#authentication) on our introduction page to learn how to acquire this variable and [visit here](https://friendli.ai/suite/~/setting/keys) to generate your API Key.

When streaming mode is used (i.e., `stream` option is set to `true`), the response is in MIME type `text/event-stream`. Otherwise, the content type is `application/json`.
You can view the schema of the streamed sequence of chunk objects in streaming mode [here](/openapi/model-apis/tool-assisted-chat-completions-chunk-object).

<Tip>You can explore examples on the [Friendli Model APIs](https://friendli.ai/get-started/model-apis) playground and adjust settings with just a few clicks.</Tip>

<Warning>Tool assisted chat completions does not fully support parallel tool calls now.</Warning>

<Info>
  This API is currently in **Beta**.
  While we strive to provide a stable and reliable experience, this feature is still under active development.
  As a result, you may encounter unexpected behavior or limitations.
  We encourage you to provide feedback to help us improve the feature before its official release.

  * [Feature request & feedback](mailto:support@friendli.ai)
  * [Contact support](mailto:support@friendli.ai)
</Info>


## OpenAPI

````yaml https://github.com/friendliai/friendli-openapi/raw/refs/heads/main/openapi.yaml post /serverless/tools/v1/chat/completions
openapi: 3.1.0
info:
  title: Friendli Suite API Reference
  description: This is an OpenAPI reference of Friendli Suite API.
  termsOfService: https://friendli.ai/terms-of-service
  contact:
    name: FriendliAI Support Team
    email: support@friendli.ai
  version: 0.1.0
servers:
  - url: https://api.friendli.ai
security: []
tags:
  - name: Serverless.Chat
  - name: Serverless.ToolAssistedChat
  - name: Serverless.Messages
  - name: Serverless.ChatRender
  - name: Serverless.Completions
  - name: Serverless.Token
  - name: Serverless.Audio
  - name: Serverless.Model
  - name: Serverless.Knowledge
  - name: Dedicated.Chat
  - name: Dedicated.Messages
  - name: Dedicated.ChatRender
  - name: Dedicated.Completions
  - name: Dedicated.Embeddings
  - name: Dedicated.TextClassification
  - name: Dedicated.Token
  - name: Dedicated.Image
  - name: Dedicated.Audio
  - name: Dedicated.Endpoint
  - name: Container.Chat
  - name: Container.Messages
  - name: Container.Completions
  - name: Container.TextClassification
  - name: Container.Token
  - name: Container.Image
  - name: Container.Audio
  - name: Cost
  - name: Dataset
  - name: File
paths:
  /serverless/tools/v1/chat/completions:
    post:
      tags:
        - Serverless.ToolAssistedChat
      summary: Tool assisted chat completions
      description: >-
        Given a list of messages forming a conversation, the model generates a
        response. Additionally, the model can utilize built-in tools for tool
        calls, enhancing its capability to provide more comprehensive and
        actionable responses.
      operationId: serverlessToolAssistedChatComplete
      parameters:
        - name: X-Friendli-Team
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: ID of team to run requests as (optional parameter).
            title: X-Friendli-Team
          description: ID of team to run requests as (optional parameter).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ServerlessToolAssistedChatCompletionBody'
      responses:
        '200':
          description: Successfully generated a tool assisted chat response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServerlessToolAssistedChatCompleteSuccess'
              examples:
                Example:
                  value:
                    id: chatcmpl-4b71d12c86d94e719c7e3984a7bb7941
                    model: zai-org/GLM-5.2
                    object: chat.completion
                    choices:
                      - index: 0
                        message:
                          role: assistant
                          content: The result is 9.
                        finish_reason: stop
                    usage:
                      prompt_tokens: 9
                      completion_tokens: 11
                      total_tokens: 20
                    created: 1735722153
        '422':
          description: Unprocessable Entity
      security:
        - token: []
components:
  schemas:
    ServerlessToolAssistedChatCompletionBody:
      properties:
        model:
          type: string
          title: Model
          description: >-
            Code of the model to use. See [available model
            list](https://friendli.ai/docs/guides/model-apis/pricing#billing-methods).
          examples:
            - zai-org/GLM-5.2
        messages:
          items:
            $ref: '#/components/schemas/Message'
          type: array
          title: Messages
          description: A list of messages comprising the conversation so far.
          examples:
            - - content: You are a helpful assistant.
                role: system
              - content: Hello!
                role: user
        chat_template_kwargs:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Chat Template Kwargs
          description: >-
            Additional keyword arguments supplied to the template renderer.
            These parameters will be available for use within the chat template.
        eos_token:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          title: Eos Token
          description: A list of endpoint sentence tokens.
        frequency_penalty:
          anyOf:
            - type: number
            - type: 'null'
          title: Frequency Penalty
          description: >-
            Number between -2.0 and 2.0. Positive values penalizes tokens that
            have been sampled, taking into account their frequency in the
            preceding text. This penalization diminishes the model's tendency to
            reproduce identical lines verbatim.
        logit_bias:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Logit Bias
          description: >-
            Accepts a JSON object that maps tokens to an associated bias value.
            Mathematically, the bias is added to the logits generated by the
            model prior to sampling. The exact effect will vary per model.
        logprobs:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Logprobs
          description: Whether to return log probabilities of the output tokens or not.
        max_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Tokens
          description: >-
            The maximum number of tokens to generate. For decoder-only models
            like GPT, the length of your input tokens plus `max_tokens` should
            not exceed the model's maximum length (e.g., 2048 for OpenAI GPT-3).
            For encoder-decoder models like T5 or BlenderBot, `max_tokens`
            should not exceed the model's maximum output length. This is similar
            to Hugging Face's
            [`max_new_tokens`](https://huggingface.co/docs/transformers/v4.26.0/en/main_classes/text_generation#transformers.GenerationConfig.max_new_tokens)
            argument.
        min_p:
          anyOf:
            - type: number
            - type: 'null'
          title: Min P
          description: >-
            A scaling factor used to determine the minimum token probability
            threshold. This threshold is calculated as `min_p` multiplied by the
            probability of the most likely token. Tokens with probabilities
            below this scaled threshold are excluded from sampling. Values range
            from 0.0 (inclusive) to 1.0 (inclusive). Higher values result in
            stricter filtering, while lower values allow for greater diversity.
            The default value of 0.0 disables filtering, allowing all tokens to
            be considered for sampling.
        'n':
          anyOf:
            - type: integer
            - type: 'null'
          title: 'N'
          description: >-
            The number of independently generated results for the prompt.
            Defaults to 1. This is similar to Hugging Face's
            [`num_return_sequences`](https://huggingface.co/docs/transformers/v4.26.0/en/main_classes/text_generation#transformers.GenerationConfig.num_return_sequences)
            argument.
        parallel_tool_calls:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Parallel Tool Calls
          description: Whether to enable parallel function calling.
        presence_penalty:
          anyOf:
            - type: number
            - type: 'null'
          title: Presence Penalty
          description: >-
            Number between -2.0 and 2.0. Positive values penalizes tokens that
            have been sampled at least once in the existing text.
        repetition_penalty:
          anyOf:
            - type: number
            - type: 'null'
          title: Repetition Penalty
          description: >-
            Penalizes tokens that have already appeared in the generated result
            (plus the input tokens for decoder-only models). Should be positive
            value (1.0 means no penalty). See [keskar et al.,
            2019](https://arxiv.org/abs/1909.05858) for more details. This is
            similar to Hugging Face's
            [`repetition_penalty`](https://huggingface.co/docs/transformers/v4.26.0/en/main_classes/text_generation#transformers.generationconfig.repetition_penalty)
            argument.
        reasoning_effort:
          anyOf:
            - type: string
              enum:
                - low
                - medium
                - high
            - type: 'null'
          title: Reasoning Effort
          description: >-
            Determines the amount of reasoning effort the model applies when
            generating a response. Higher values may produce more detailed and
            thoughtful outputs, but can increase response time. This parameter
            is only effective for reasoning models.
        reasoning_budget:
          anyOf:
            - type: integer
            - type: 'null'
          title: Reasoning Budget
          description: >-
            Specifies a positive integer that defines a limit on the number of
            tokens used for internal reasoning tokens. This parameter is only
            effective for reasoning models.
        seed:
          anyOf:
            - items:
                type: integer
              type: array
            - type: integer
            - type: 'null'
          title: Seed
          description: >-
            Seed to control random procedure. If nothing is given, random seed
            is used for sampling, and return the seed along with the generated
            result. When using the `n` argument, you can pass a list of seed
            values to control all of the independent generations.
        stop:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Stop
          description: >-
            When one of the stop phrases appears in the generation result, the
            API will stop generation. The stop phrases are excluded from the
            result. Defaults to empty list.
        stream:
          type: boolean
          title: Stream
          description: >-
            Whether to stream the generation result. When set to `true`, each
            token will be sent as [server-sent
            events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format)
            once generated.
          default: false
        stream_options:
          anyOf:
            - $ref: '#/components/schemas/StreamOptions'
            - type: 'null'
          description: |-
            Options related to stream.
            It can only be used when `stream: true`.
        parse_reasoning:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Parse Reasoning
          description: >-
            Parses model reasoning into `reasoning_content` while keeping the
            answer in `content`. Default value may vary between endpoints.


            For more detailed information, please refer
            [here](https://friendli.ai/docs/guides/reasoning#reasoning-parsing-with-friendli).
        include_reasoning:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Include Reasoning
          description: >-
            When `parse_reasoning=true`, include parsed reasoning
            (`reasoning_content`). Defaults to true.


            For more detailed information, please refer
            [here](https://friendli.ai/docs/guides/reasoning#reasoning-parsing-with-friendli).
        temperature:
          anyOf:
            - type: number
            - type: 'null'
          title: Temperature
          description: >-
            Sampling temperature. Smaller temperature makes the generation
            result closer to greedy, argmax (i.e., `top_k = 1`) sampling.
            Defaults to 1.0. This is similar to Hugging Face's
            [`temperature`](https://huggingface.co/docs/transformers/v4.26.0/en/main_classes/text_generation#transformers.generationconfig.temperature)
            argument.
        tool_choice:
          anyOf:
            - $ref: '#/components/schemas/ChatCompleteBodyToolChoice'
            - type: string
          title: Tool Choice
          description: >
            Determines the tool calling behavior of the model.

            When set to `none`, the model will bypass tool execution and
            generate a response directly.

            In `auto` mode (the default), the model dynamically decides whether
            to call a tool or respond with a message.

            Alternatively, setting `required` ensures that the model invokes at
            least one tool before responding to the user.

            You can also specify a particular tool by `{"type": "function",
            "function": {"name": "my_function"}}`.
        top_k:
          anyOf:
            - type: integer
            - type: 'null'
          title: Top K
          description: >-
            Limits sampling to the top k tokens with the highest probabilities.
            Values range from 0 (no filtering) to the model's vocabulary size
            (inclusive). The default value of 0 applies no filtering, allowing
            all tokens.
        top_logprobs:
          anyOf:
            - type: integer
            - type: 'null'
          title: Top Logprobs
          description: >-
            The number of most likely tokens to return at each token position,
            each with an associated log probability. `logprobs` must be set to
            true if this parameter is used.
        top_p:
          anyOf:
            - type: number
            - type: 'null'
          title: Top P
          description: >-
            Keeps only the smallest set of tokens whose cumulative probabilities
            reach `top_p` or higher. Values range from 0.0 (exclusive) to 1.0
            (inclusive). The default value of 1.0 includes all tokens, allowing
            maximum diversity.
        xtc_threshold:
          anyOf:
            - type: number
            - type: 'null'
          title: Xtc Threshold
          description: >-
            A probability threshold used to identify “top choice” tokens for
            exclusion in XTC (Exclude Top Choices) sampling. Tokens with
            probabilities at or above this threshold are considered viable
            candidates, and all but the least likely viable token are excluded
            from sampling. This option reduces the dominance of highly probable
            tokens while preserving some diversity by keeping the least
            confident “top choice.” Values range from 0.0 (inclusive) to 1.0
            (inclusive). Higher values make the filtering more selective by
            requiring higher probabilities to trigger exclusion, while lower
            values apply filtering more broadly. The default value of 0.0
            disables XTC filtering entirely.
        xtc_probability:
          anyOf:
            - type: number
            - type: 'null'
          title: Xtc Probability
          description: >-
            The probability that XTC (Exclude Top Choices) filtering will be
            applied for each sampling decision. When XTC is triggered,
            high-probability tokens above the `xtc_threshold` are excluded
            except for the least likely viable token. This stochastic activation
            allows for a balance between standard sampling and
            creativity-boosting exclusion filtering. Values range from 0.0
            (inclusive) to 1.0 (inclusive), where 0.0 means XTC is never
            applied, 1.0 means XTC is always applied when viable tokens exist,
            and intermediate values provide probabilistic activation. The
            default value of 0.0 disables XTC filtering.
        tools:
          anyOf:
            - items:
                $ref: '#/components/schemas/ToolAssistedChatTool'
              type: array
            - type: 'null'
          title: Tools
          description: >-
            A list of tools the model may call.

            A maximum of 128 functions is supported.

            Use this to provide a list of functions the model may generate JSON
            inputs for.

            For more detailed information about each tool, please refer
            [here](https://friendli.ai/docs/guides/model-apis/tool-assisted-api#built-in-tools).
        resume_generation:
          type: boolean
          title: Resume Generation
          description: >-
            Enable to continue text generation even after an error occurs during
            a tool call.


            Note that enabling this option may use more tokens, as the system
            generates additional content to handle errors gracefully.

            However, if the system fails more than 8 times, the generation will
            stop regardless.


            ***Tip***

            This is useful in scenarios where you want to maintain text
            generation flow despite errors, such as when generating long-form
            content.

            The user will not be interrupted by tool call issues, ensuring a
            smoother experience.
      type: object
      required:
        - model
        - messages
      title: ServerlessToolAssistedChatCompletionBody
      example:
        messages:
          - content: What is 3 + 6?
            role: user
        model: zai-org/GLM-5.2
        tools:
          - type: math:calculator
    ServerlessToolAssistedChatCompleteSuccess:
      $ref: '#/components/schemas/ChatResult'
      title: ServerlessToolAssistedChatCompleteSuccess
    Message:
      oneOf:
        - $ref: '#/components/schemas/SystemMessage'
          title: System
        - $ref: '#/components/schemas/UserMessage'
          title: User
        - $ref: '#/components/schemas/AssistantMessage'
          title: Assistant
        - $ref: '#/components/schemas/ToolMessage'
          title: Tool
      discriminator:
        propertyName: role
        mapping:
          assistant:
            $ref: '#/components/schemas/AssistantMessage'
          system:
            $ref: '#/components/schemas/SystemMessage'
          tool:
            $ref: '#/components/schemas/ToolMessage'
          user:
            $ref: '#/components/schemas/UserMessage'
    StreamOptions:
      properties:
        include_usage:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Include Usage
          description: >
            When set to `true`,

            the number of tokens used will be included at the end of the stream
            result in the form of

            `"usage": {"completion_tokens": number, "prompt_tokens": number,
            "total_tokens": number}`.
      type: object
      title: StreamOptions
    ChatCompleteBodyToolChoice:
      properties:
        type:
          type: string
          const: function
          title: Type
          description: The type of the tool. Currently, only `function` is supported.
        function:
          $ref: '#/components/schemas/ChatCompleteBodyToolChoiceFunction'
      type: object
      required:
        - type
        - function
      title: ChatCompleteBodyToolChoice
    ToolAssistedChatTool:
      oneOf:
        - $ref: '#/components/schemas/Tool'
          title: Function
        - $ref: '#/components/schemas/FriendliBuiltInTool'
          title: Friendli
        - $ref: '#/components/schemas/IntegratedBuiltInTool'
          title: Integrated
        - $ref: '#/components/schemas/FileBuiltInTool'
          title: File
      discriminator:
        propertyName: type
        mapping:
          code:python-interpreter:
            $ref: '#/components/schemas/FriendliBuiltInTool'
          file:text:
            $ref: '#/components/schemas/FileBuiltInTool'
          function:
            $ref: '#/components/schemas/Tool'
          linkup:search:
            $ref: '#/components/schemas/IntegratedBuiltInTool'
          math:calculator:
            $ref: '#/components/schemas/FriendliBuiltInTool'
          math:calendar:
            $ref: '#/components/schemas/FriendliBuiltInTool'
          math:statistics:
            $ref: '#/components/schemas/FriendliBuiltInTool'
          web:search:
            $ref: '#/components/schemas/FriendliBuiltInTool'
          web:url:
            $ref: '#/components/schemas/FriendliBuiltInTool'
    ChatResult:
      properties:
        id:
          type: string
          title: Id
          description: A unique ID of the chat completion.
        choices:
          items:
            $ref: '#/components/schemas/ChatChoice'
          type: array
          title: Choices
        usage:
          $ref: '#/components/schemas/ChatUsage'
        object:
          type: string
          const: chat.completion
          title: Object
          description: The object type, which is always set to `chat.completion`.
        created:
          type: integer
          title: Created
          description: The Unix timestamp (in seconds) for when the generation completed.
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
          description: >-
            The model to generate the completion. For dedicated endpoints, it
            returns the endpoint ID.
      type: object
      required:
        - id
        - choices
        - usage
        - object
        - created
      title: ChatResult
    SystemMessage:
      properties:
        role:
          type: string
          const: system
          title: Role
          description: The role of the messages author.
        content:
          type: string
          title: Content
          description: The content of system message.
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: >-
            The name for the participant to distinguish between participants
            with the same role.
      type: object
      required:
        - role
        - content
      title: SystemMessage
    UserMessage:
      properties:
        role:
          type: string
          const: user
          title: Role
          description: The role of the message's author.
        content:
          anyOf:
            - type: string
              description: >-
                The content of user message, which is plain text.


                For **multi-modal format**, use `object[]` type. Support for
                non-text input is currently in **Beta**.
            - items:
                $ref: '#/components/schemas/UserMessageContentMultiModal'
              type: array
              description: >-
                The content of user message.


                **Multi-modal format** can handle not just text, but also audio,
                image, and video content, allowing for more complex message
                structures. Support for non-text input is currently in **Beta**.
          title: Content
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: >-
            The name for the participant to distinguish between participants
            with the same role.
      type: object
      required:
        - role
        - content
      title: UserMessage
    AssistantMessage:
      properties:
        role:
          type: string
          const: assistant
          title: Role
          description: The role of the messages author.
        content:
          anyOf:
            - type: string
            - type: 'null'
          title: Content
          description: >-
            The content of assistant message. Required unless `tool_calls` is
            specified.
        reasoning_content:
          anyOf:
            - type: string
            - type: 'null'
          title: Reasoning Content
          description: The intermediate reasoning content of assistant message.
        reasoning:
          anyOf:
            - type: string
            - type: 'null'
          title: Reasoning
          description: >-
            The intermediate reasoning content of assistant message. This field
            is a compatible option for the 'reasoning_content' field.
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: >-
            The name for the participant to distinguish between participants
            with the same role.
        tool_calls:
          anyOf:
            - items:
                $ref: '#/components/schemas/AssistantMessageToolCall'
              type: array
            - type: 'null'
          title: Tool Calls
      type: object
      required:
        - role
      title: AssistantMessage
    ToolMessage:
      properties:
        role:
          type: string
          const: tool
          title: Role
          description: The role of the messages author.
        content:
          type: string
          title: Content
          description: >-
            The content of tool message that contains the result of tool
            calling.
        tool_call_id:
          type: string
          title: Tool Call Id
          description: The ID of tool call corresponding to this message.
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: An optional name of the tool call corresponding to this message.
      type: object
      required:
        - role
        - content
        - tool_call_id
      title: ToolMessage
    ChatCompleteBodyToolChoiceFunction:
      properties:
        name:
          type: string
          title: Name
          description: >-
            The name of the function to be called. Must be a-z, A-Z, 0-9, or
            contain underscores and dashes, with a maximum length of 64.
      type: object
      required:
        - name
      title: ChatCompleteBodyToolChoiceFunction
    Tool:
      properties:
        type:
          type: string
          const: function
          title: Type
          description: The type of the tool. Currently, only `function` is supported.
        function:
          $ref: '#/components/schemas/Function'
      type: object
      required:
        - type
        - function
      title: Tool
    FriendliBuiltInTool:
      properties:
        type:
          type: string
          enum:
            - math:calculator
            - math:statistics
            - math:calendar
            - web:search
            - web:url
            - code:python-interpreter
          title: Type
          description: The type of the built-in tool provided by Friendli.
      type: object
      required:
        - type
      title: FriendliBuiltInTool
    IntegratedBuiltInTool:
      properties:
        type:
          type: string
          const: linkup:search
          title: Type
          description: The type of the integrated third-party tool.
      type: object
      required:
        - type
      title: IntegratedBuiltInTool
    FileBuiltInTool:
      properties:
        type:
          type: string
          const: file:text
          title: Type
          description: >-
            The type of the file parser tool. Only .txt and .pdf files are
            supported.
        files:
          items:
            type: string
          type: array
          title: Files
          description: A List of file IDs. For now, only one file is supported.
      type: object
      required:
        - type
        - files
      title: FileBuiltInTool
    ChatChoice:
      properties:
        index:
          type: integer
          title: Index
          description: The index of the choice in the list of generated choices.
          examples:
            - 0
        logprobs:
          anyOf:
            - $ref: '#/components/schemas/ChatLogprobs'
            - type: 'null'
        message:
          $ref: '#/components/schemas/ChatChoiceMessage'
        finish_reason:
          type: string
          enum:
            - stop
            - length
            - tool_calls
          title: Finish Reason
          description: >-
            Termination condition of the generation. `stop` means the API
            returned the full chat completions generated by the model without
            running into any limits.

            `length` means the generation exceeded `max_tokens` or the
            conversation exceeded the max context length.

            `tool_calls` means the API has generated tool calls.
      type: object
      required:
        - index
        - message
        - finish_reason
      title: ChatChoice
    ChatUsage:
      properties:
        prompt_tokens:
          type: integer
          title: Prompt Tokens
          description: Number of tokens in the prompt.
          examples:
            - 5
        completion_tokens:
          type: integer
          title: Completion Tokens
          description: Number of tokens in the generated chat completions.
          examples:
            - 7
        total_tokens:
          type: integer
          title: Total Tokens
          description: >-
            Total number of tokens used in the request (`prompt_tokens` +
            `completion_tokens`).
          examples:
            - 12
        prompt_tokens_details:
          anyOf:
            - $ref: '#/components/schemas/PromptTokensDetails'
            - type: 'null'
          description: Breakdown of tokens used in the prompt.
      type: object
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
      title: ChatUsage
    UserMessageContentMultiModal:
      oneOf:
        - $ref: '#/components/schemas/TextContent'
          title: Text
        - $ref: '#/components/schemas/AudioContent'
          title: Audio
        - $ref: '#/components/schemas/ImageContent'
          title: Image
        - $ref: '#/components/schemas/VideoContent'
          title: Video
      discriminator:
        propertyName: type
        mapping:
          audio_url:
            $ref: '#/components/schemas/AudioContent'
          image_url:
            $ref: '#/components/schemas/ImageContent'
          text:
            $ref: '#/components/schemas/TextContent'
          video_url:
            $ref: '#/components/schemas/VideoContent'
    AssistantMessageToolCall:
      properties:
        id:
          type: string
          title: Id
          description: The ID of tool call.
        type:
          type: string
          const: function
          title: Type
          description: The type of tool call.
        function:
          $ref: '#/components/schemas/AssistantMessageToolCallFunction'
          description: The function specification
      type: object
      required:
        - id
        - type
        - function
      title: AssistantMessageToolCall
    Function:
      properties:
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: >-
            A description of what the function does, used by the model to choose
            when and how to call the function.
        name:
          type: string
          title: Name
          description: >-
            The name of the function to be called. Must be a-z, A-Z, 0-9, or
            contain underscores and dashes, with a maximum length of 64.
        parameters:
          additionalProperties: true
          type: object
          title: Parameters
          description: >
            The parameters the functions accepts, described as a JSON Schema
            object.

            To represent a function with no parameters, use the value `{"type":
            "object", "properties": {}}`.
      type: object
      required:
        - name
        - parameters
      title: Function
    ChatLogprobs:
      properties:
        content:
          anyOf:
            - items:
                $ref: '#/components/schemas/ChatLogprobsContent'
              type: array
            - type: 'null'
          title: Content
          description: A list of message content tokens with log probability information.
      type: object
      title: ChatLogprobs
    ChatChoiceMessage:
      properties:
        content:
          anyOf:
            - type: string
            - type: 'null'
          title: Content
          description: The contents of the assistant message.
        role:
          type: string
          title: Role
          description: Role of the generated message author, in this case `assistant`.
        tool_calls:
          anyOf:
            - items:
                $ref: '#/components/schemas/ToolCallResult'
              type: array
            - type: 'null'
          title: Tool Calls
      type: object
      required:
        - role
      title: ChatChoiceMessage
    PromptTokensDetails:
      properties:
        cached_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Cached Tokens
          description: Cached tokens present in the prompt.
      type: object
      title: PromptTokensDetails
    TextContent:
      properties:
        type:
          type: string
          const: text
          title: Type
          description: The type of the message content.
        text:
          type: string
          title: Text
          description: The text content of the message.
      type: object
      required:
        - type
        - text
      title: TextContent
    AudioContent:
      properties:
        type:
          type: string
          const: audio_url
          title: Type
          description: The type of the message content.
        audio_url:
          $ref: '#/components/schemas/AudioData'
          description: The audio URL data.
      type: object
      required:
        - type
        - audio_url
      title: AudioContent
    ImageContent:
      properties:
        type:
          type: string
          const: image_url
          title: Type
          description: The type of the message content.
        image_url:
          $ref: '#/components/schemas/ImageData'
          description: The image URL data.
      type: object
      required:
        - type
        - image_url
      title: ImageContent
    VideoContent:
      properties:
        type:
          type: string
          const: video_url
          title: Type
          description: The type of the message content.
        video_url:
          $ref: '#/components/schemas/VideoData'
          description: The video URL data.
      type: object
      required:
        - type
        - video_url
      title: VideoContent
    AssistantMessageToolCallFunction:
      properties:
        name:
          type: string
          title: Name
          description: The name of function
        arguments:
          type: string
          title: Arguments
          description: >-
            The arguments of function in JSON schema format to call the
            function.
      type: object
      required:
        - name
        - arguments
      title: AssistantMessageToolCallFunction
    ChatLogprobsContent:
      properties:
        token:
          type: string
          title: Token
          description: The token.
        logprob:
          type: number
          title: Logprob
          description: The log probability of this token.
        bytes:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          title: Bytes
          description: >-
            A list of integers representing the UTF-8 bytes representation of
            the token. Useful in instances where characters are represented by
            multiple tokens and their byte representations must be combined to
            generate the correct text representation. Can be `null` if there is
            no bytes representation for the token.
        top_logprobs:
          items:
            $ref: '#/components/schemas/ChatLogprobsContentTopLogprob'
          type: array
          title: Top Logprobs
          description: >-
            List of the most likely tokens and their log probability, at this
            token position.
      type: object
      required:
        - token
        - logprob
        - top_logprobs
      title: ChatLogprobsContent
    ToolCallResult:
      properties:
        type:
          type: string
          const: function
          title: Type
          description: The type of the tool.
        id:
          type: string
          title: Id
          description: The ID of the tool call.
        function:
          $ref: '#/components/schemas/FunctionResult'
      type: object
      required:
        - type
        - id
        - function
      title: ToolCallResult
    AudioData:
      properties:
        url:
          type: string
          title: Url
          description: The URL of the audio.
      type: object
      required:
        - url
      title: AudioData
    ImageData:
      properties:
        url:
          type: string
          title: Url
          description: The URL of the image.
      type: object
      required:
        - url
      title: ImageData
    VideoData:
      properties:
        url:
          type: string
          title: Url
          description: The URL of the video.
      type: object
      required:
        - url
      title: VideoData
    ChatLogprobsContentTopLogprob:
      properties:
        token:
          type: string
          title: Token
          description: The token.
        logprob:
          type: number
          title: Logprob
          description: The log probability of this token.
        bytes:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          title: Bytes
          description: >-
            A list of integers representing the UTF-8 bytes representation of
            the token. Useful in instances where characters are represented by
            multiple tokens and their byte representations must be combined to
            generate the correct text representation. Can be `null` if there is
            no bytes representation for the token.
      type: object
      required:
        - token
        - logprob
      title: ChatLogprobsContentTopLogprob
    FunctionResult:
      properties:
        arguments:
          type: string
          title: Arguments
          description: >-
            The arguments for calling the function, generated by the model in
            JSON format.

            Ensure to validate these arguments in your code before invoking the
            function since the model may not always produce valid JSON.
        name:
          type: string
          title: Name
          description: The name of the function to call.
      type: object
      required:
        - arguments
        - name
      title: FunctionResult
  securitySchemes:
    token:
      type: http
      description: >-
        When using Friendli Suite API for inference requests, you need to
        provide a **Personal API Key** for authentication and authorization
        purposes.


        For more detailed information, please refer
        [here](https://friendli.ai/docs/openapi/introduction#authentication).
      scheme: bearer

````