> ## 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.

# Container Messages

> Use the Anthropic Messages-style API with Friendli Container. Send structured message payloads to your self-hosted model and receive responses.

Send Anthropic Messages-style JSON.
Detailed request/response field descriptions are provided in the OpenAPI schema below on this page.

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>


## OpenAPI

````yaml https://github.com/friendliai/friendli-openapi/raw/refs/heads/main/openapi.yaml post /v1/messages
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:
  /v1/messages:
    servers:
      - url: http://localhost:8000
    post:
      tags:
        - Container.Messages
      summary: Messages
      description: Generate responses using Anthropic Messages-style payloads.
      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_...
components:
  schemas:
    ContainerMessagesBody:
      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
            - 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:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Stream
          description: >-
            Whether to stream output as server-sent events
            (`text/event-stream`). When false or omitted, returns a single JSON
            response.
        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: ContainerMessagesBody
      example:
        messages:
          - content: Hello, summarize what you can do in one sentence.
            role: user
        model: zai-org/GLM-5.2
    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
    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.
      additionalProperties: true
      type: object
      required:
        - type
        - error
      title: MessagesErrorResponse
    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
    MessagesSystemTextBlock:
      properties:
        type:
          type: string
          const: text
          title: Type
          description: System block type. Must be `text`.
        text:
          type: string
          title: Text
          description: System instruction text content.
      type: object
      required:
        - type
        - text
      title: MessagesSystemTextBlock
    MessagesToolDefinition:
      properties:
        name:
          type: string
          title: Name
          description: >-
            Tool identifier used in model tool-call outputs. Keep this name
            stable and unique within the request.
        type:
          anyOf:
            - type: string
            - type: 'null'
          title: Type
          description: >-
            Tool category. If missing, empty, or `custom`, it is converted to a
            function tool. Any non-empty value other than `custom` is treated as
            a server-side tool and skipped.
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          description: >-
            Natural-language description of what the tool does and when to call
            it.
        input_schema:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Input Schema
          description: >-
            JSON Schema describing tool arguments. The model uses this schema to
            construct the tool input object.
        strict:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Strict
          description: >-
            If true, applies stricter schema adherence when generating tool
            arguments.
      type: object
      required:
        - name
      title: MessagesToolDefinition
    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
    MessagesThinkingConfig:
      properties:
        type:
          type: string
          enum:
            - enabled
            - disabled
            - adaptive
          title: Type
          description: >-
            Reasoning mode. `enabled` forces reasoning, `disabled` suppresses
            it, and `adaptive` lets the system decide.
        budget_tokens:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Budget Tokens
          description: >-
            Reasoning token budget. Required when `type=enabled`; must not be
            provided when `type=disabled` or `type=adaptive`. If `max_tokens` is
            set, this must be smaller than `max_tokens`.
      type: object
      required:
        - type
      title: MessagesThinkingConfig
    MessagesOutputConfig:
      properties:
        effort:
          anyOf:
            - type: string
              enum:
                - low
                - medium
                - high
                - max
            - type: 'null'
          title: Effort
          description: >-
            Relative generation effort level (`low`, `medium`, `high`, `max`).
            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
    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:
            $ref: '#/components/schemas/MessagesResponseTextBlock'
          thinking:
            $ref: '#/components/schemas/MessagesResponseThinkingBlock'
          tool_use:
            $ref: '#/components/schemas/MessagesResponseToolUseBlock'
    MessagesUsage:
      properties:
        input_tokens:
          type: integer
          minimum: 0
          title: Input Tokens
          description: Number of billed input tokens for this request.
        output_tokens:
          type: integer
          minimum: 0
          title: Output Tokens
          description: Number of billed output tokens generated by the model.
        cache_read_input_tokens:
          anyOf:
            - type: integer
              minimum: 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
    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.
      additionalProperties: true
      type: object
      required:
        - type
        - message
      title: MessagesErrorObject
    MessagesContentBlock:
      oneOf:
        - $ref: '#/components/schemas/MessagesTextBlock'
          title: Text
        - $ref: '#/components/schemas/MessagesImageBlock'
          title: Image
        - $ref: '#/components/schemas/MessagesThinkingBlock'
          title: Thinking
        - $ref: '#/components/schemas/MessagesToolUseBlock'
          title: Tool Use
        - $ref: '#/components/schemas/MessagesToolResultBlock'
          title: Tool Result
        - $ref: '#/components/schemas/MessagesCompatibilityBlock'
          title: Compatibility Block
      discriminator:
        propertyName: type
        mapping:
          bash_code_execution_tool_result:
            $ref: '#/components/schemas/MessagesCompatibilityBlock'
          code_execution_tool_result:
            $ref: '#/components/schemas/MessagesCompatibilityBlock'
          container_upload:
            $ref: '#/components/schemas/MessagesCompatibilityBlock'
          document:
            $ref: '#/components/schemas/MessagesCompatibilityBlock'
          image:
            $ref: '#/components/schemas/MessagesImageBlock'
          redacted_thinking:
            $ref: '#/components/schemas/MessagesCompatibilityBlock'
          search_result:
            $ref: '#/components/schemas/MessagesCompatibilityBlock'
          server_tool_use:
            $ref: '#/components/schemas/MessagesCompatibilityBlock'
          text:
            $ref: '#/components/schemas/MessagesTextBlock'
          text_editor_code_execution_tool_result:
            $ref: '#/components/schemas/MessagesCompatibilityBlock'
          thinking:
            $ref: '#/components/schemas/MessagesThinkingBlock'
          tool_result:
            $ref: '#/components/schemas/MessagesToolResultBlock'
          tool_search_tool_result:
            $ref: '#/components/schemas/MessagesCompatibilityBlock'
          tool_use:
            $ref: '#/components/schemas/MessagesToolUseBlock'
          web_fetch_tool_result:
            $ref: '#/components/schemas/MessagesCompatibilityBlock'
          web_search_tool_result:
            $ref: '#/components/schemas/MessagesCompatibilityBlock'
    MessagesOutputFormat:
      properties:
        type:
          anyOf:
            - type: string
              const: json_schema
            - type: 'null'
          title: Type
          description: >-
            Output format type. Set to `json_schema` to constrain output to a
            JSON schema.
        schema:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Schema
          description: JSON Schema object applied when `type` is `json_schema`.
      type: object
      title: MessagesOutputFormat
    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
    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
    MessagesResponseToolUseBlock:
      properties:
        type:
          type: string
          const: tool_use
          title: Type
          description: Content block type.
        id:
          type: string
          title: Id
          description: Identifier of the tool call emitted by the model.
        name:
          type: string
          title: Name
          description: Name of the invoked tool.
        input:
          additionalProperties: true
          type: object
          title: Input
          description: Parsed tool argument object generated by the model.
      type: object
      required:
        - type
        - id
        - name
        - input
      title: MessagesResponseToolUseBlock
    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
    MessagesImageBlock:
      properties:
        type:
          type: string
          const: image
          title: Type
          description: Content block type. Must be `image`.
        source:
          $ref: '#/components/schemas/MessagesImageSource'
          description: Image source descriptor (`url` or `base64`).
      type: object
      required:
        - type
        - source
      title: MessagesImageBlock
    MessagesThinkingBlock:
      properties:
        type:
          type: string
          const: thinking
          title: Type
          description: Content block type. Must be `thinking`.
        thinking:
          type: string
          title: Thinking
          description: Reasoning content for this block.
        signature:
          anyOf:
            - type: string
            - type: 'null'
          title: Signature
          description: Optional signature associated with the reasoning content.
      type: object
      required:
        - type
        - thinking
      title: MessagesThinkingBlock
    MessagesToolUseBlock:
      properties:
        type:
          type: string
          const: tool_use
          title: Type
          description: Content block type. Must be `tool_use`.
        id:
          anyOf:
            - type: string
            - type: 'null'
          title: Id
          description: >-
            Optional tool call identifier. Use this value to link follow-up
            `tool_result` blocks.
        name:
          type: string
          title: Name
          description: Name of the tool to invoke.
        input:
          additionalProperties: true
          type: object
          title: Input
          description: Tool input argument object.
      type: object
      required:
        - type
        - name
        - input
      title: MessagesToolUseBlock
    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
    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:
            $ref: '#/components/schemas/MessagesBase64ImageSource'
          url:
            $ref: '#/components/schemas/MessagesUrlImageSource'
    MessagesBase64ImageSource:
      properties:
        type:
          type: string
          const: base64
          title: Type
          description: Image source type. Must be `base64`.
        data:
          type: string
          minLength: 1
          title: Data
          description: Base64-encoded image bytes (without data URL prefix).
        media_type:
          type: string
          minLength: 1
          title: Media Type
          description: MIME type, for example `image/png`.
      type: object
      required:
        - type
        - data
        - media_type
      title: MessagesBase64ImageSource
    MessagesUrlImageSource:
      properties:
        type:
          type: string
          const: url
          title: Type
          description: Image source type. Must be `url`.
        url:
          type: string
          minLength: 1
          title: Url
          description: Publicly accessible image URL that the service can fetch.
      type: object
      required:
        - type
        - url
      title: MessagesUrlImageSource

````