FriendliAI Serverless.ToolAssistedChat API
The Serverless.ToolAssistedChat API from FriendliAI — 2 operation(s) for serverless.toolassistedchat.
The Serverless.ToolAssistedChat API from FriendliAI — 2 operation(s) for serverless.toolassistedchat.
openapi: 3.1.0
info:
title: Friendli Suite API Reference Container.Audio Serverless.ToolAssistedChat API
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
tags:
- name: Serverless.ToolAssistedChat
paths:
/serverless/tools/v1/chat/completions:
post:
tags:
- Serverless.ToolAssistedChat
summary: Tool assisted chat completions
description: Generate a model response from a list of messages comprising a conversation. Compatible with the OpenAI Chat Completions API, with support for streaming, tool calls, and structured outputs. Additionally, the model can utilize built-in tools for tool calls, enhancing its capability to provide more comprehensive and actionable responses.
operationId: serverlessToolAssistedChatComplete
security:
- token: []
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
x-speakeasy-name-override: complete
x-speakeasy-ignore: true
x-mint:
metadata:
title: Model APIs Tool Assisted Chat Completions
sidebarTitle: Tool Assisted Chat Completions
og:title: Model APIs Tool Assisted Chat Completions
description: Generate a model response from a list of messages comprising a conversation. Compatible with the OpenAI Chat Completions API, with support for streaming, tool calls, and structured outputs. Additionally, the model can utilize built-in tools for tool calls, enhancing its capability to provide more comprehensive and actionable responses.
og:description: Generate a model response from a list of messages comprising a conversation. Compatible with the OpenAI Chat Completions API, with support for streaming, tool calls, and structured outputs. Additionally, the model can utilize built-in tools for tool calls, enhancing its capability to provide more comprehensive and actionable responses.
tag: Beta
href: /openapi/model-apis/tool-assisted-chat-completions
content: 'Generate a model response from a list of messages comprising a conversation. Compatible with the OpenAI Chat Completions API, with support for streaming, tool calls, and structured outputs. 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>'
/serverless/tools/v1/chat/completions#stream:
post:
tags:
- Serverless.ToolAssistedChat
summary: Stream tool assisted chat completions
description: Generate a model response from a list of messages comprising a conversation. Compatible with the OpenAI Chat Completions API, with support for streaming, tool calls, and structured outputs. Additionally, the model can utilize built-in tools for tool calls, enhancing its capability to provide more comprehensive and actionable responses.
operationId: serverlessToolAssistedChatStream
security:
- token: []
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/ServerlessToolAssistedChatCompletionStreamBody'
responses:
'200':
description: Successfully generated a tool assisted chat response.
content:
text/event-stream:
x-speakeasy-sse-sentinel: '[DONE]'
examples:
Example:
value: 'event: tool_status
data: {"tool_call_id":"call_3QrfStXSU6fGdOGPcETocIAq","name":"math:calculator","status":"STARTED","parameters":[{"name":"expression","value":"150 * 1.60934"}],"result":null,"files":null,"message":null,"error":null,"usage":null,"timestamp":1726277121}
event: tool_status
data: {"tool_call_id":"call_3QrfStXSU6fGdOGPcETocIAq","name":"math:calculator","status":"ENDED","parameters":[{"name":"expression","value":"150 * 1.60934"}],"result":""{\"result\": \"150 * 1.60934=241.401000000000\"}"","files":null,"message":null,"error":null,"usage":null,"timestamp":1726277121}
data: {"id":"chatcmpl-4b71d12c86d94e719c7e3984a7bb7941","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":"To"},"finish_reason":null,"logprobs":null}],"created":1726277121}
...
data: {"id":"chatcmpl-4b71d12c86d94e719c7e3984a7bb7941","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant","content":"."},"finish_reason":null,"logprobs":null}],"created":1726277121}
data: {"id":"chatcmpl-4b71d12c86d94e719c7e3984a7bb7941","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop","logprobs":null}],"created":1726277121}
data: [DONE]
'
schema:
$ref: '#/components/schemas/ServerlessToolAssistedChatCompletionStreamSuccess'
'422':
description: Unprocessable Entity
x-speakeasy-name-override: stream
x-speakeasy-ignore: true
x-mint:
metadata:
title: Model APIs Tool Assisted Stream Chat Completions
sidebarTitle: Stream Tool Assisted Chat Completions
og:title: Model APIs Tool Assisted Stream Chat Completions
description: Generate a model response from a list of messages comprising a conversation. Compatible with the OpenAI Chat Completions API, with support for streaming, tool calls, and structured outputs. Additionally, the model can utilize built-in tools for tool calls, enhancing its capability to provide more comprehensive and actionable responses.
og:description: Generate a model response from a list of messages comprising a conversation. Compatible with the OpenAI Chat Completions API, with support for streaming, tool calls, and structured outputs. Additionally, the model can utilize built-in tools for tool calls, enhancing its capability to provide more comprehensive and actionable responses.
tag: Beta
content: 'Generate a model response from a list of messages comprising a conversation. Compatible with the OpenAI Chat Completions API, with support for streaming, tool calls, and structured outputs. 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>'
components:
schemas:
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
ToolStatusError:
properties:
type:
type: string
title: Type
description: The type of error encountered during the tool's execution.
msg:
type: string
title: Msg
description: The message of error.
type: object
required:
- type
- msg
title: ToolStatusError
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
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
StreamedToolCallResult:
properties:
type:
type: string
const: function
title: Type
description: The type of the tool.
id:
anyOf:
- type: string
- type: 'null'
title: Id
description: The ID of the tool call.
index:
type: integer
title: Index
description: The index of the tool call being generated.
function:
$ref: '#/components/schemas/StreamedFunctionResult'
type: object
required:
- type
- index
- function
title: StreamedToolCallResult
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
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
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
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
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
StreamedToolAssistedChatToken:
properties:
event:
type: string
const: token
title: Event
description: The type of the event.
data:
$ref: '#/components/schemas/StreamedChatData'
type: object
required:
- event
- data
title: StreamedToolAssistedChatToken
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
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: '#/components/schemas/AssistantMessage'
system: '#/components/schemas/SystemMessage'
tool: '#/components/schemas/ToolMessage'
user: '#/components/schemas/UserMessage'
PromptTokensDetails:
properties:
cached_tokens:
anyOf:
- type: integer
- type: 'null'
title: Cached Tokens
description: Cached tokens present in the prompt.
type: object
title: PromptTokensDetails
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
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
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
ServerlessToolAssistedChatCompleteSuccess:
$ref: '#/components/schemas/ChatResult'
title: ServerlessToolAssistedChatCompleteSuccess
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
StreamedFunctionResult:
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:
anyOf:
- type: string
- type: 'null'
title: Name
description: The name of the function to call.
type: object
required:
- arguments
title: StreamedFunctionResult
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
AudioData:
properties:
url:
type: string
title: Url
description: The URL of the audio.
type: object
required:
- url
title: AudioData
ToolStatusData:
properties:
tool_call_id:
type: string
title: Tool Call Id
description: The ID of the tool call.
name:
type: string
enum:
- linkup:search
- math:calculator
- math:statistics
- math:calendar
- web:search
- web:url
- code:python-interpreter
- file:text
title: Name
description: The name of the built-in tool.
status:
type: string
enum:
- STARTED
- UPDATING
- ENDED
- ERRORED
title: Status
description: Indicates the current execution status of the tool.
parameters:
items:
$ref: '#/components/schemas/ToolStatusParameter'
type: array
title: Parameters
result:
anyOf:
- type: string
- type: 'null'
title: Result
description: The output from the tool's execution.
files:
anyOf:
- items:
$ref: '#/components/schemas/ToolStatusFile'
type: array
- type: 'null'
title: Files
message:
anyOf:
- type: string
- type: 'null'
title: Message
description: Message generated by the tool's execution.
error:
anyOf:
- $ref: '#/components/schemas/ToolStatusError'
- type: 'null'
timestamp:
type: number
title: Timestamp
description: The Unix timestamp (in seconds) for when the event occurred.
type: object
required:
- tool_call_id
- name
- status
- parameters
- timestamp
title: ToolStatusData
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
ToolStatusParameter:
properties:
name:
type: string
title: Name
description: The name of the tool's function parameter.
value:
type: string
title: Value
description: The value of the tool's function parameter.
type: object
required:
- name
- value
title: ToolStatusParameter
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
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: '#/components/schemas/AudioContent'
image_url: '#/components/schemas/ImageContent'
text: '#/components/schemas/TextContent'
video_url: '#/components/schemas/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
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:
- minimal
- low
- medium
- high
- xhigh
- max
- ultracode
- type: 'null'
title: Reasoning Effort
description: Sets how much reasoning the model does before answering. Higher values give more thorough responses but take longer. This affects reasoning models only, and the available options depend on the model.
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
# --- truncated at 32 KB (65 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/friendliai/refs/heads/main/openapi/friendliai-serverless-toolassistedchat-api-openapi.yml