FriendliAI Container.Messages API
The Container.Messages API from FriendliAI — 2 operation(s) for container.messages.
The Container.Messages API from FriendliAI — 2 operation(s) for container.messages.
openapi: 3.1.0
info:
title: Friendli Suite API Reference Container.Audio Container.Messages 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: Container.Messages
paths:
/v1/messages:
servers:
- url: http://localhost:8000
post:
tags:
- Container.Messages
summary: Messages
description: Generate a model response from a conversation using the Anthropic Messages API format. Supports streaming, function tool calls, and extended thinking.
operationId: containerMessages
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ContainerMessagesBody'
required: true
responses:
'200':
description: Successfully generated a Messages-style response. For streaming (`text/event-stream`) event and chunk details, see [Messages chunk object](/openapi/container/messages-chunk-object).
content:
application/json:
schema:
$ref: '#/components/schemas/ContainerMessagesSuccess'
examples:
Example:
value:
id: msg_4b71d12c86d94e719c7e3984a7bb7941
type: message
role: assistant
content:
- type: text
text: I can answer questions, generate text, and help with coding tasks.
stop_reason: end_turn
usage:
input_tokens: 17
output_tokens: 14
cache_read_input_tokens: 0
model: zai-org/GLM-5.2
'422':
description: Unprocessable Entity
content:
application/json:
schema:
$ref: '#/components/schemas/MessagesErrorResponse'
examples:
Invalid request error:
value:
type: error
error:
type: invalid_request_error
message: '...'
request_id: req_...
x-speakeasy-name-override: messages
x-mint:
metadata:
title: Container Messages
sidebarTitle: Messages
og:title: Container Messages
description: Generate a model response from a conversation using the Anthropic Messages API format. Supports streaming, function tool calls, and extended thinking.
og:description: Generate a model response from a conversation using the Anthropic Messages API format. Supports streaming, function tool calls, and extended thinking.
tag: Beta
href: /openapi/container/messages
content: 'Generate a model response from a conversation using the Anthropic Messages API format. Supports streaming, function tool calls, and extended thinking.
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/container/messages-chunk-object).
<Warning>Server-side tools are not supported in the Messages API. In `tools`, only custom/client function tools are used; non-`custom` tool types are ignored.</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>'
/v1/messages#stream:
servers:
- url: http://localhost:8000
post:
tags:
- Container.Messages
summary: Stream messages
description: Generate a model response from a conversation using the Anthropic Messages API format. Supports streaming, function tool calls, and extended thinking.
operationId: containerMessagesStream
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ContainerMessagesStreamBody'
required: true
responses:
'200':
description: Successfully generated a streamed Messages-style response.
content:
text/event-stream:
examples:
Example:
value: 'event: message_start
data: {"type":"message_start","message":{"id":"msg_4b71d12c86d94e719c7e3984a7bb7941","type":"message","role":"assistant","content":[],"stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":0,"output_tokens":0,"cache_read_input_tokens":0}}}
event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":", how can I help?"}}
event: content_block_stop
data: {"type":"content_block_stop","index":0}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null},"usage":{"output_tokens":11}}
event: message_stop
data: {"type":"message_stop"}
'
schema:
$ref: '#/components/schemas/ContainerMessagesStreamSuccess'
'422':
description: Unprocessable Entity
content:
application/json:
schema:
$ref: '#/components/schemas/MessagesErrorResponse'
examples:
Invalid request error:
value:
type: error
error:
type: invalid_request_error
message: '...'
request_id: req_...
x-speakeasy-name-override: stream
x-mint:
metadata:
title: Container Stream Messages
sidebarTitle: Stream Messages
og:title: Container Stream Messages
description: Generate a model response from a conversation using the Anthropic Messages API format. Supports streaming, function tool calls, and extended thinking.
og:description: Generate a model response from a conversation using the Anthropic Messages API format. Supports streaming, function tool calls, and extended thinking.
tag: Beta
href: /openapi/container/messages
content: 'Generate a model response from a conversation using the Anthropic Messages API format. Supports streaming, function tool calls, and extended thinking.
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/container/messages-chunk-object).
<Warning>Server-side tools are not supported in the Messages API. In `tools`, only custom/client function tools are used; non-`custom` tool types are ignored.</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:
MessagesResponseTextBlock:
properties:
type:
type: string
const: text
title: Type
description: Content block type.
text:
type: string
title: Text
description: Assistant-generated text for this block.
type: object
required:
- type
- text
title: MessagesResponseTextBlock
MessagesUsage:
properties:
input_tokens:
type: integer
minimum: 0.0
title: Input Tokens
description: Number of billed input tokens for this request.
output_tokens:
type: integer
minimum: 0.0
title: Output Tokens
description: Number of billed output tokens generated by the model.
cache_read_input_tokens:
anyOf:
- type: integer
minimum: 0.0
- type: 'null'
title: Cache Read Input Tokens
description: Number of input tokens served from cache, when cache reads are applicable.
type: object
required:
- input_tokens
- output_tokens
title: MessagesUsage
MessagesCompatibilityBlock:
properties:
type:
type: string
enum:
- document
- search_result
- redacted_thinking
- server_tool_use
- web_search_tool_result
- web_fetch_tool_result
- code_execution_tool_result
- bash_code_execution_tool_result
- text_editor_code_execution_tool_result
- tool_search_tool_result
- container_upload
title: Type
description: Compatibility block type. These blocks are accepted for parsing compatibility and ignored for generation.
type: object
required:
- type
title: MessagesCompatibilityBlock
MessagesImageSource:
oneOf:
- $ref: '#/components/schemas/MessagesBase64ImageSource'
title: Base64
- $ref: '#/components/schemas/MessagesUrlImageSource'
title: URL
discriminator:
propertyName: type
mapping:
base64: '#/components/schemas/MessagesBase64ImageSource'
url: '#/components/schemas/MessagesUrlImageSource'
ContainerMessagesSuccess:
properties:
id:
type: string
title: Id
description: Unique identifier for this message response.
type:
type: string
const: message
title: Type
description: Response object type (`message`).
role:
type: string
const: assistant
title: Role
description: Role of the output message author (`assistant`).
content:
items:
$ref: '#/components/schemas/MessagesResponseContentBlock'
type: array
title: Content
description: Assistant output blocks in generation order.
stop_reason:
anyOf:
- type: string
enum:
- end_turn
- max_tokens
- tool_use
- stop_sequence
- type: 'null'
title: Stop Reason
description: Why generation stopped (`end_turn`, `max_tokens`, `tool_use`, `stop_sequence`).
stop_sequence:
anyOf:
- type: string
- type: 'null'
title: Stop Sequence
description: Matched stop string when `stop_reason` is `stop_sequence`; otherwise null.
usage:
$ref: '#/components/schemas/MessagesUsage'
description: Token usage details for this response.
model:
anyOf:
- type: string
- type: 'null'
title: Model
description: Model used to generate the response.
additionalProperties: true
type: object
required:
- id
- type
- role
- content
- usage
title: ContainerMessagesSuccess
MessagesToolResultBlock:
properties:
type:
type: string
const: tool_result
title: Type
description: Content block type. Must be `tool_result`.
tool_use_id:
type: string
title: Tool Use Id
description: Identifier of the related `tool_use` block this result answers.
content:
anyOf:
- type: string
- items:
additionalProperties: true
type: object
type: array
- type: 'null'
title: Content
description: Tool result payload. Can be plain text, a list of objects, or null when no body is returned.
type: object
required:
- type
- tool_use_id
title: MessagesToolResultBlock
MessagesTextBlock:
properties:
type:
type: string
const: text
title: Type
description: Content block type. Must be `text`.
text:
type: string
title: Text
description: Text content for this block.
type: object
required:
- type
- text
title: MessagesTextBlock
MessagesStreamContentBlockStop:
properties:
type:
type: string
const: content_block_stop
title: Type
description: The type of the event.
index:
type: integer
title: Index
description: Index of the block that has finished streaming.
type: object
required:
- type
- index
title: MessagesStreamContentBlockStop
MessagesStreamMessageDeltaPayload:
properties:
stop_reason:
anyOf:
- type: string
enum:
- end_turn
- max_tokens
- tool_use
- stop_sequence
- type: 'null'
title: Stop Reason
description: Why generation stopped.
stop_sequence:
anyOf:
- type: string
- type: 'null'
title: Stop Sequence
description: Matched stop sequence when `stop_reason=stop_sequence`.
type: object
title: MessagesStreamMessageDeltaPayload
MessagesStreamMessageStart:
properties:
type:
type: string
const: message_start
title: Type
description: The type of the event.
message:
$ref: '#/components/schemas/MessagesStreamMessageEnvelope'
description: Initial response envelope for this streamed message.
type: object
required:
- type
- message
title: MessagesStreamMessageStart
MessagesResponseContentBlock:
oneOf:
- $ref: '#/components/schemas/MessagesResponseThinkingBlock'
title: Thinking
- $ref: '#/components/schemas/MessagesResponseTextBlock'
title: Text
- $ref: '#/components/schemas/MessagesResponseToolUseBlock'
title: Tool Use
discriminator:
propertyName: type
mapping:
text: '#/components/schemas/MessagesResponseTextBlock'
thinking: '#/components/schemas/MessagesResponseThinkingBlock'
tool_use: '#/components/schemas/MessagesResponseToolUseBlock'
ContainerMessagesStreamSuccess:
properties:
data:
$ref: '#/components/schemas/MessagesStreamEvent'
description: A server-sent event containing a streamed Messages API update.
type: object
required:
- data
title: ContainerMessagesStreamSuccess
MessagesStreamMessageStop:
properties:
type:
type: string
const: message_stop
title: Type
description: The type of the event.
type: object
required:
- type
title: MessagesStreamMessageStop
MessagesStreamErrorEvent:
properties:
type:
type: string
const: error
title: Type
description: The type of the event.
error:
$ref: '#/components/schemas/MessagesStreamErrorDetail'
description: Error payload object.
request_id:
anyOf:
- type: string
- type: 'null'
title: Request Id
description: Request identifier for debugging and support.
type: object
required:
- type
- error
title: MessagesStreamErrorEvent
MessagesErrorResponse:
properties:
type:
type: string
const: error
title: Type
description: Top-level response type for Messages API errors.
error:
$ref: '#/components/schemas/MessagesErrorObject'
description: Structured error object.
request_id:
anyOf:
- type: string
- type: 'null'
title: Request Id
description: Request identifier for debugging and support. It may be omitted in some failure paths.
type: object
required:
- type
- error
title: MessagesErrorResponse
MessagesStreamContentBlockDelta:
properties:
type:
type: string
const: content_block_delta
title: Type
description: The type of the event.
index:
type: integer
title: Index
description: Index of the content block being updated.
delta:
$ref: '#/components/schemas/MessagesStreamContentBlockDeltaPayload'
description: Incremental delta payload.
type: object
required:
- type
- index
- delta
title: MessagesStreamContentBlockDelta
MessagesStreamContentBlockDeltaPayload:
oneOf:
- $ref: '#/components/schemas/MessagesStreamTextDelta'
title: Text Delta
- $ref: '#/components/schemas/MessagesStreamThinkingDelta'
title: Thinking Delta
- $ref: '#/components/schemas/MessagesStreamSignatureDelta'
title: Signature Delta
- $ref: '#/components/schemas/MessagesStreamInputJsonDelta'
title: Input JSON Delta
discriminator:
propertyName: type
mapping:
input_json_delta: '#/components/schemas/MessagesStreamInputJsonDelta'
signature_delta: '#/components/schemas/MessagesStreamSignatureDelta'
text_delta: '#/components/schemas/MessagesStreamTextDelta'
thinking_delta: '#/components/schemas/MessagesStreamThinkingDelta'
MessagesStreamStartThinkingBlock:
properties:
type:
type: string
const: thinking
title: Type
description: Content block type.
thinking:
type: string
title: Thinking
description: Reasoning content when `type=thinking`.
signature:
anyOf:
- type: string
- type: 'null'
title: Signature
description: Optional signature when `type=thinking`.
type: object
required:
- type
- thinking
title: MessagesStreamStartThinkingBlock
MessagesStreamMessageEnvelope:
properties:
id:
type: string
title: Id
description: Unique ID of the response message.
type:
type: string
const: message
title: Type
description: Object type, always `message`.
role:
type: string
const: assistant
title: Role
description: Author role of streamed output, always `assistant`.
content:
items:
$ref: '#/components/schemas/MessagesResponseContentBlock'
type: array
title: Content
description: Initialized as an empty array at start. Populated by subsequent block events.
stop_reason:
anyOf:
- type: string
enum:
- end_turn
- max_tokens
- tool_use
- stop_sequence
- type: 'null'
title: Stop Reason
description: Stop reason placeholder at start.
stop_sequence:
anyOf:
- type: string
- type: 'null'
title: Stop Sequence
description: Matched stop sequence placeholder at start.
usage:
$ref: '#/components/schemas/MessagesUsage'
description: Running usage object.
model:
anyOf:
- type: string
- type: 'null'
title: Model
description: Model identifier for this response, when available.
type: object
required:
- id
- type
- role
- usage
title: MessagesStreamMessageEnvelope
MessagesToolChoice:
properties:
type:
type: string
enum:
- auto
- any
- tool
- none
title: Type
description: Tool-calling mode. `auto` lets the model decide, `any` requires at least one tool call, `tool` forces a named tool, and `none` disables tool calls.
name:
anyOf:
- type: string
- type: 'null'
title: Name
description: Tool name to force when `type=tool`. Ignored for other `type` values.
disable_parallel_tool_use:
anyOf:
- type: boolean
- type: 'null'
title: Disable Parallel Tool Use
description: If true, restricts the model to at most one tool call at a time. Must not be provided when `type=none`.
type: object
required:
- type
title: MessagesToolChoice
MessagesStreamEvent:
oneOf:
- $ref: '#/components/schemas/MessagesStreamMessageStart'
title: Message Start
- $ref: '#/components/schemas/MessagesStreamContentBlockStart'
title: Content Block Start
- $ref: '#/components/schemas/MessagesStreamContentBlockDelta'
title: Content Block Delta
- $ref: '#/components/schemas/MessagesStreamContentBlockStop'
title: Content Block Stop
- $ref: '#/components/schemas/MessagesStreamMessageDelta'
title: Message Delta
- $ref: '#/components/schemas/MessagesStreamMessageStop'
title: Message Stop
- $ref: '#/components/schemas/MessagesStreamErrorEvent'
title: Error
discriminator:
propertyName: type
mapping:
content_block_delta: '#/components/schemas/MessagesStreamContentBlockDelta'
content_block_start: '#/components/schemas/MessagesStreamContentBlockStart'
content_block_stop: '#/components/schemas/MessagesStreamContentBlockStop'
error: '#/components/schemas/MessagesStreamErrorEvent'
message_delta: '#/components/schemas/MessagesStreamMessageDelta'
message_start: '#/components/schemas/MessagesStreamMessageStart'
message_stop: '#/components/schemas/MessagesStreamMessageStop'
MessagesStreamInputJsonDelta:
properties:
type:
type: string
const: input_json_delta
title: Type
description: Delta type.
partial_json:
type: string
title: Partial Json
description: Partial JSON fragment for tool arguments when `type=input_json_delta`.
type: object
required:
- type
- partial_json
title: MessagesStreamInputJsonDelta
MessagesErrorObject:
properties:
type:
type: string
title: Type
description: Error category. For HTTP 422 in Messages API, this is `invalid_request_error`.
message:
type: string
title: Message
description: Human-readable error message.
type: object
required:
- type
- message
title: MessagesErrorObject
ContainerMessagesStreamBody:
properties:
messages:
items:
$ref: '#/components/schemas/MessagesInputMessage'
type: array
minItems: 1
title: Messages
description: A list of conversation messages ordered from oldest to newest. Must contain at least one item.
examples:
- - content: Explain top_p in one sentence.
role: user
max_tokens:
anyOf:
- type: integer
minimum: 1.0
- type: 'null'
title: Max Tokens
description: Maximum number of tokens to generate for the assistant response. Must be greater than 0 when provided.
model:
anyOf:
- type: string
- type: 'null'
title: Model
description: Routes the request to a specific adapter.
examples:
- (adapter-route)
system:
anyOf:
- anyOf:
- type: string
- items:
$ref: '#/components/schemas/MessagesSystemTextBlock'
type: array
description: Payload format for the top-level `system` instruction.
- type: 'null'
title: System
description: Optional top-level system instruction applied before conversation turns. Supports a plain string or an array of text blocks.
stream:
type: boolean
title: Stream
description: Whether to stream the response. When set to `true`, events are 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: true
temperature:
anyOf:
- type: number
- type: 'null'
title: Temperature
description: Sampling temperature. Lower values make outputs more deterministic; higher values increase diversity.
top_p:
anyOf:
- type: number
- type: 'null'
title: Top P
description: Nucleus sampling parameter. The model samples from the smallest token set whose cumulative probability reaches `top_p`.
top_k:
anyOf:
- type: integer
- type: 'null'
title: Top K
description: Limits sampling to the `k` most likely tokens at each decoding step.
stop_sequences:
anyOf:
- items:
type: string
type: array
- type: 'null'
title: Stop Sequences
description: Stop strings that terminate generation when matched in output. The matched value is returned in `stop_sequence` when applicable.
tools:
anyOf:
- items:
$ref: '#/components/schemas/MessagesToolDefinition'
type: array
- type: 'null'
title: Tools
description: Tool definitions available to the model. Use this to allow tool calls with structured arguments.
tool_choice:
anyOf:
- $ref: '#/components/schemas/MessagesToolChoice'
- type: 'null'
description: Controls tool-calling behavior (`auto`, `any`, `tool`, `none`) and optional parallel-call behavior.
thinking:
anyOf:
- $ref: '#/components/schemas/MessagesThinkingConfig'
- type: 'null'
description: Controls reasoning behavior with mode (`enabled`, `disabled`, `adaptive`). `enabled` requires `budget_tokens`; `disabled` and `adaptive` must not include it.
output_config:
anyOf:
- $ref: '#/components/schemas/MessagesOutputConfig'
- type: 'null'
description: Output generation options including effort level and structured output format settings.
cache_control:
anyOf:
- additionalProperties: true
type: object
- type: 'null'
title: Cache Control
description: Compatibility field accepted for request portability. Parsed but not used for generation.
container:
anyOf:
- additionalProperties: true
type: object
- type: 'null'
title: Container
description: Compatibility field accepted for request portability. Parsed but not used for generation.
context_manager:
anyOf:
- additionalProperties: true
type: object
- type: 'null'
title: Context Manager
description: Compatibility field accepted for request portability. Parsed but not used for generation.
inference_geo:
anyOf:
- additionalProperties: true
type: object
- type: 'null'
title: Inference Geo
description: Compatibility field accepted for request portability. Parsed but not used for generation.
metadata:
anyOf:
- additionalProperties: true
type: object
- type: 'null'
title: Metadata
description: Compatibility field accepted for request portability. Parsed but not used for generation.
service_tier:
anyOf:
- type: string
- additionalProperties: true
type: object
- type: 'null'
title: Service Tier
description: Compatibility field accepted for request portability. Parsed but not used for generation.
additionalProperties: true
type: object
required:
- messages
title: ContainerMessagesStreamBody
example:
messages:
- content: Hello, summarize what you can do in one sentence.
role: user
model: zai-org/GLM-5.2
MessagesInputMessage:
properties:
role:
type: string
enum:
- user
- assistant
title: Role
description: Author role for this message turn. Use `user` for user input and `assistant` for prior assistant turns.
content:
anyOf:
- type: string
- items:
$ref: '#/components/schemas/MessagesContentBlock'
type: array
title: Content
description: Message payload. Supports plain string shorthand or a typed block array.
type: object
required:
- role
- content
title: MessagesInputMessage
MessagesResponseThinkingBlock:
properties:
type:
type: string
const: thinking
title: Type
description: Content block type.
thinking:
type: string
title: Thinking
description: Reasoning content returned by the model.
signature:
type: string
title: Signature
description: Signature associated with the reasoning content.
type: object
required:
- type
- thinking
- signature
title: MessagesResponseThinkingBlock
MessagesOutputConfig:
properties:
effort:
anyOf:
- type: string
enum:
- minimal
- low
- medium
- high
- xhigh
- max
- ultracode
- type: 'null'
title: Effort
description: Relative generation effort level. Higher effort can improve quality on harder prompts at the cost of additional compute.
format:
anyOf:
- $ref: '#/components/schemas/MessagesOutputFormat'
- type: 'null'
description: Structured output settings. Currently supports only `json_schema`.
type: object
title: MessagesOutputConfig
MessagesStreamStartToolUseBlock:
properties:
type:
type: string
const: tool_use
title: Type
description: Content block type.
id:
type: string
title: Id
description: Tool call ID when `type=tool_use`.
name:
type: string
title: Name
description: Tool name when `type=tool_use`.
input:
additionalProperties: true
type: object
title: Input
description: Parsed tool input object when `type=tool_use`.
type: object
required:
- type
- id
- name
- input
title: MessagesStreamStartToolUseBlock
MessagesStreamContentBlockStart:
pro
# --- truncated at 32 KB (50 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/friendliai/refs/heads/main/openapi/friendliai-container-messages-api-openapi.yml