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

# Count tokens for a message request

> Anthropic `count_tokens` compatible endpoint. Returns the number of input tokens that would be consumed by a `POST /messages` call with the same prompt content (system, messages, tools, tool_choice). Authentication accepts either the bearer `Authorization: Bearer <key>` header (SambaNova SDK default) or the `x-api-key` header (Anthropic SDK default); the same API key is used in both cases.



## OpenAPI

````yaml https://raw.githubusercontent.com/sambanova/sambanova-inference-api-spec/refs/heads/main/openapi.documented.json post /messages/count_tokens
openapi: 3.1.1
info:
  title: SambaNova cloud API
  description: SambaNova cloud API Specification
  version: 1.2.0
  termsOfService: https://sambanova.ai/cloud-end-user-license-agreement
  contact:
    email: info@sambanova.ai
    name: SambaNova information
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://api.sambanova.ai/v1
security:
  - api_key: []
externalDocs:
  description: Find out more in the official SambaNova docs
  url: https://docs.sambanova.ai/docs/en/api-reference/overview
paths:
  /messages/count_tokens:
    post:
      tags:
        - Messages
      summary: Count tokens for a message request
      description: >-
        Anthropic `count_tokens` compatible endpoint. Returns the number of
        input tokens that would be consumed by a `POST /messages` call with the
        same prompt content (system, messages, tools, tool_choice).
        Authentication accepts either the bearer `Authorization: Bearer <key>`
        header (SambaNova SDK default) or the `x-api-key` header (Anthropic SDK
        default); the same API key is used in both cases.
      operationId: countMessageTokens
      parameters:
        - in: header
          name: anthropic-version
          required: false
          description: >-
            Anthropic API version header sent by the official `anthropic` SDK.
            Accepted (any value) but currently has no effect on response shape -
            included for drop-in SDK compatibility.
          schema:
            title: Anthropic Version
            type: string
            example: '2023-06-01'
      requestBody:
        required: true
        description: Token counting parameters (subset of message creation parameters).
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MessageCountTokensRequest'
      responses:
        '200':
          description: Successful response. Returns the input token count.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageCountTokensResponse'
        '400':
          description: >-
            Bad Request — `invalid_request_error`. Returned for missing or
            invalid parameters, unsupported feature flags, unsupported tool
            types, image source `type:"url"`, `document` content blocks, or
            non-object request bodies.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageErrorResponse'
        '401':
          description: Unauthorized — `authentication_error`. Invalid or missing API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageErrorResponse'
        '403':
          description: >-
            Forbidden — `permission_error`. API key lacks access to the
            requested resource.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageErrorResponse'
        '404':
          description: >-
            Not Found — `not_found_error`. Model does not exist or is not
            accessible.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageErrorResponse'
        '413':
          description: >-
            Payload Too Large — `request_too_large`. Request exceeds the maximum
            allowed size.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageErrorResponse'
        '429':
          description: Too Many Requests — `rate_limit_error`. Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageErrorResponse'
        '500':
          description: >-
            Internal Server Error — `api_error`. Unexpected issue on the server
            side.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageErrorResponse'
        '503':
          description: >-
            Service Unavailable — `overloaded_error`. Backend is temporarily
            over capacity.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageErrorResponse'
      security:
        - api_key: []
        - x_api_key: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import SambaNova from 'sambanova';


            const client = new SambaNova({
              apiKey: process.env['SAMBANOVA_API_KEY'], // This is the default and can be omitted
            });


            const messageCountTokensResponse = await
            client.messages.countTokens({
              messages: [{ content: 'Hello, Claude!', role: 'user' }],
              model: 'DeepSeek-V3.1',
            });


            console.log(messageCountTokensResponse.input_tokens);
        - lang: Python
          source: |-
            import os
            from sambanova import SambaNova

            client = SambaNova(
                api_key=os.environ.get("SAMBANOVA_API_KEY"),  # This is the default and can be omitted
            )
            message_count_tokens_response = client.messages.count_tokens(
                messages=[{
                    "content": "Hello, Claude!",
                    "role": "user",
                }],
                model="DeepSeek-V3.1",
            )
            print(message_count_tokens_response.input_tokens)
components:
  schemas:
    MessageCountTokensRequest:
      title: Message Count Tokens Request
      type: object
      description: >-
        Request body for `POST /messages/count_tokens`. Returns the input token
        count for a prompt without generating output. Same prompt shape as
        `MessageCreateRequest` minus generation-time parameters (`max_tokens`,
        `stream`, sampling, `stop_sequences`, `metadata`, `service_tier`, etc.).
      additionalProperties: true
      properties:
        model:
          title: Model
          type: string
          description: Model identifier.
          example: gpt-oss-120b
        messages:
          title: Messages
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/MessageInputMessage'
          description: Conversation turns.
        system:
          $ref: '#/components/schemas/MessageSystemPrompt'
        thinking:
          $ref: '#/components/schemas/MessageThinkingConfig'
        tools:
          title: Tools
          type: array
          items:
            $ref: '#/components/schemas/MessageTool'
          nullable: true
          description: Tool definitions the model may call.
        tool_choice:
          allOf:
            - $ref: '#/components/schemas/MessageToolChoice'
          nullable: true
          description: Controls how the model selects from `tools`.
      required:
        - model
        - messages
      example:
        model: DeepSeek-V3.1
        messages:
          - role: user
            content: Hello, Claude!
    MessageCountTokensResponse:
      title: Message Count Tokens Response
      type: object
      description: Token count for the supplied prompt.
      properties:
        input_tokens:
          type: integer
          description: Total tokens in the prompt (system + messages + tools).
      required:
        - input_tokens
    MessageErrorResponse:
      title: Message Error Response
      type: object
      description: >-
        Top-level error envelope returned by the Messages API on any non-2xx
        response. Shape matches Anthropic's wire format. This envelope is used
        ONLY on `/messages` and `/messages/count_tokens`
      properties:
        type:
          title: Type
          type: string
          description: Always `error` for error envelopes.
          enum:
            - error
          const: error
        error:
          $ref: '#/components/schemas/MessageError'
        request_id:
          title: Request Id
          type: string
          description: >-
            Opaque request identifier echoed by the server, useful for
            correlating client-side failures with server-side logs.
          nullable: true
      required:
        - type
        - error
    MessageInputMessage:
      title: Message Input Message
      type: object
      description: A turn in the conversation.
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
          description: >-
            Conversational role. `user` for the human-side turn, `assistant` for
            prior model output.
        content:
          anyOf:
            - type: string
            - title: Content Block Array
              type: array
              items:
                $ref: '#/components/schemas/MessageInputContentBlock'
      required:
        - role
        - content
    MessageSystemPrompt:
      title: Message System Prompt
      description: >-
        System prompt for the conversation. Accepts either a single string (most
        common) or an array of text blocks (used when individual segments need
        `cache_control` markers). Multiple text blocks are joined with newlines
        and prepended to the conversation as a `role: system` message.
      anyOf:
        - type: string
        - title: System Text Block Array
          type: array
          items:
            $ref: '#/components/schemas/MessageSystemTextBlock'
    MessageThinkingConfig:
      title: Message Thinking Config
      description: >-
        Controls Anthropic-style extended thinking. **In v1**: only
        `type:"disabled"` is silently accepted as a no-op; `type:"enabled"` and
        `type:"adaptive"` return a 400 `invalid_request_error`
        (`unsupported_parameter`).
      oneOf:
        - $ref: '#/components/schemas/MessageThinkingDisabled'
        - $ref: '#/components/schemas/MessageThinkingEnabled'
        - $ref: '#/components/schemas/MessageThinkingAdaptive'
      discriminator:
        propertyName: type
        mapping:
          disabled:
            $ref: '#/components/schemas/MessageThinkingDisabled'
          enabled:
            $ref: '#/components/schemas/MessageThinkingEnabled'
          adaptive:
            $ref: '#/components/schemas/MessageThinkingAdaptive'
    MessageTool:
      title: Message Tool
      type: object
      description: >-
        User-defined function tool definition. Only custom function tools are
        supported (Anthropic's `type:"custom"` style or the absent-type Beta
        style). Anthropic-hosted server tools (`web_search`, `code_execution`,
        `bash`, `text_editor`, `memory`, `tool_search` variants) return 400
        `unsupported_tool_type` if sent.
      properties:
        name:
          type: string
          description: Tool name. Must match `^[a-zA-Z0-9_-]+$`.
        type:
          type: string
          enum:
            - custom
          nullable: true
          description: >-
            Tool-type discriminator. May be omitted (defaults to custom) or set
            to `custom`. Other values return 400 `unsupported_tool_type`.
        description:
          type: string
          nullable: true
          description: Human-readable description of when the tool should be used.
        input_schema:
          type: object
          additionalProperties: true
          nullable: true
          description: >-
            JSON Schema describing the tool's expected input. Required by the
            Anthropic spec; accepted as optional by SambaNova.
        cache_control:
          allOf:
            - $ref: '#/components/schemas/MessageCacheControl'
          nullable: true
          description: >-
            Silently dropped on tool definitions (only content and system cache
            markers participate in caching).
        input_examples:
          type: array
          items:
            type: object
            additionalProperties: true
          nullable: true
          description: Silently dropped.
        allowed_callers:
          type: array
          items:
            type: string
          nullable: true
          description: Silently dropped.
        defer_loading:
          type: boolean
          nullable: true
          description: Silently dropped.
        eager_input_streaming:
          type: boolean
          nullable: true
          description: Silently dropped.
        strict:
          type: boolean
          nullable: true
          description: Silently dropped.
      required:
        - name
    MessageToolChoice:
      title: Message Tool Choice
      description: How the model should choose from the provided tools.
      oneOf:
        - $ref: '#/components/schemas/MessageToolChoiceAuto'
        - $ref: '#/components/schemas/MessageToolChoiceAny'
        - $ref: '#/components/schemas/MessageToolChoiceNone'
        - $ref: '#/components/schemas/MessageToolChoiceTool'
      discriminator:
        propertyName: type
        mapping:
          auto:
            $ref: '#/components/schemas/MessageToolChoiceAuto'
          any:
            $ref: '#/components/schemas/MessageToolChoiceAny'
          none:
            $ref: '#/components/schemas/MessageToolChoiceNone'
          tool:
            $ref: '#/components/schemas/MessageToolChoiceTool'
    MessageError:
      title: Message Error
      type: object
      description: >-
        Inner error object carried inside a `MessageErrorResponse`. The `type`
        value follows Anthropic's published error taxonomy.
      properties:
        type:
          title: Type
          type: string
          description: Error category. Values follow Anthropic's taxonomy.
          enum:
            - invalid_request_error
            - authentication_error
            - permission_error
            - not_found_error
            - request_too_large
            - rate_limit_error
            - api_error
            - overloaded_error
            - not_implemented_error
        message:
          title: Message
          type: string
          description: Human-readable explanation of the error.
      required:
        - type
        - message
    MessageInputContentBlock:
      title: Message Input Content Block
      description: Typed content block inside a message's `content` array.
      oneOf:
        - $ref: '#/components/schemas/MessageInputTextBlock'
        - $ref: '#/components/schemas/MessageInputImageBlock'
        - $ref: '#/components/schemas/MessageInputVideoBlock'
        - $ref: '#/components/schemas/MessageInputToolUseBlock'
        - $ref: '#/components/schemas/MessageInputToolResultBlock'
        - $ref: '#/components/schemas/MessageInputServerToolUseBlock'
        - $ref: '#/components/schemas/MessageInputSearchResultBlock'
        - $ref: '#/components/schemas/MessageInputWebSearchToolResultBlock'
        - $ref: '#/components/schemas/MessageInputWebFetchToolResultBlock'
        - $ref: '#/components/schemas/MessageInputCodeExecutionToolResultBlock'
        - $ref: '#/components/schemas/MessageInputBashCodeExecutionToolResultBlock'
        - $ref: >-
            #/components/schemas/MessageInputTextEditorCodeExecutionToolResultBlock
        - $ref: '#/components/schemas/MessageInputToolSearchToolResultBlock'
        - $ref: '#/components/schemas/MessageInputThinkingBlock'
        - $ref: '#/components/schemas/MessageInputRedactedThinkingBlock'
        - $ref: '#/components/schemas/MessageInputContainerUploadBlock'
        - $ref: '#/components/schemas/MessageInputDocumentBlock'
      discriminator:
        propertyName: type
        mapping:
          text:
            $ref: '#/components/schemas/MessageInputTextBlock'
          image:
            $ref: '#/components/schemas/MessageInputImageBlock'
          video:
            $ref: '#/components/schemas/MessageInputVideoBlock'
          tool_use:
            $ref: '#/components/schemas/MessageInputToolUseBlock'
          tool_result:
            $ref: '#/components/schemas/MessageInputToolResultBlock'
          server_tool_use:
            $ref: '#/components/schemas/MessageInputServerToolUseBlock'
          search_result:
            $ref: '#/components/schemas/MessageInputSearchResultBlock'
          web_search_tool_result:
            $ref: '#/components/schemas/MessageInputWebSearchToolResultBlock'
          web_fetch_tool_result:
            $ref: '#/components/schemas/MessageInputWebFetchToolResultBlock'
          code_execution_tool_result:
            $ref: '#/components/schemas/MessageInputCodeExecutionToolResultBlock'
          bash_code_execution_tool_result:
            $ref: '#/components/schemas/MessageInputBashCodeExecutionToolResultBlock'
          text_editor_code_execution_tool_result:
            $ref: >-
              #/components/schemas/MessageInputTextEditorCodeExecutionToolResultBlock
          tool_search_tool_result:
            $ref: '#/components/schemas/MessageInputToolSearchToolResultBlock'
          thinking:
            $ref: '#/components/schemas/MessageInputThinkingBlock'
          redacted_thinking:
            $ref: '#/components/schemas/MessageInputRedactedThinkingBlock'
          container_upload:
            $ref: '#/components/schemas/MessageInputContainerUploadBlock'
          document:
            $ref: '#/components/schemas/MessageInputDocumentBlock'
    MessageSystemTextBlock:
      title: Message System Text Block
      type: object
      description: >-
        A text segment within a structured `system` prompt array. Multiple text
        blocks are concatenated (with newlines) and prepended to the
        conversation as a `role: system` message at the chat-completions layer.
      properties:
        type:
          const: text
          enum:
            - text
          title: Type
          type: string
        text:
          title: Text
          type: string
          description: Plain-text content of the system prompt segment.
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
        citations:
          title: Citations
          type: array
          description: 'Optional citations. **In v1**: silently dropped'
          items:
            type: object
            additionalProperties: true
          nullable: true
      required:
        - type
        - text
    MessageThinkingDisabled:
      title: Message Thinking Disabled
      type: object
      description: >-
        Disables Anthropic-style extended thinking. **In v1**: silently accepted
        as a no-op
      properties:
        type:
          title: Type
          type: string
          enum:
            - disabled
          const: disabled
      required:
        - type
    MessageThinkingEnabled:
      title: Message Thinking Enabled
      type: object
      description: >-
        Enables Anthropic-style extended thinking with a fixed budget. **In
        v1**: returns a 400 `invalid_request_error` (`unsupported_parameter`).
      properties:
        type:
          title: Type
          type: string
          enum:
            - enabled
          const: enabled
        budget_tokens:
          title: Budget Tokens
          type: integer
          minimum: 1024
          description: >-
            Maximum tokens the model may spend on extended thinking before
            producing the final answer.
      required:
        - type
        - budget_tokens
    MessageThinkingAdaptive:
      title: Message Thinking Adaptive
      type: object
      description: >-
        Enables Anthropic-style adaptive extended thinking. **In v1**: returns a
        400 `invalid_request_error` (`unsupported_parameter`).
      properties:
        type:
          title: Type
          type: string
          enum:
            - adaptive
          const: adaptive
        budget_tokens:
          title: Budget Tokens
          type: integer
          minimum: 1024
          nullable: true
          description: >-
            Optional upper bound on tokens spent on adaptive thinking. When
            omitted, the backend chooses based on prompt complexity.
      required:
        - type
    MessageCacheControl:
      title: Message Cache Control
      type: object
      description: >-
        Marks the preceding content block (or system text block) as a prompt-
        cache breakpoint. Marker positions are collected by the adapter; their
        wiring into the router's longest-prefix matching **In v1**: position is
        recorded; the `ttl` value is ignored.
      properties:
        type:
          title: Type
          type: string
          enum:
            - ephemeral
          const: ephemeral
          description: Cache breakpoint type. Only `ephemeral` is supported by Anthropic.
        ttl:
          title: TTL
          type: string
          description: >-
            Optional time-to-live hint (e.g. `"5m"`, `"1h"`). **Currently
            ignored** in v1
          nullable: true
      required:
        - type
    MessageToolChoiceAuto:
      title: Message Tool Choice (Auto)
      type: object
      description: Let the model decide whether and which tool to use.
      properties:
        type:
          type: string
          enum:
            - auto
          const: auto
        disable_parallel_tool_use:
          type: boolean
          nullable: true
          description: Silently dropped.
      required:
        - type
    MessageToolChoiceAny:
      title: Message Tool Choice (Any)
      type: object
      description: Require the model to call one of the provided tools.
      properties:
        type:
          type: string
          enum:
            - any
          const: any
        disable_parallel_tool_use:
          type: boolean
          nullable: true
          description: Silently dropped.
      required:
        - type
    MessageToolChoiceNone:
      title: Message Tool Choice (None)
      type: object
      description: Forbid the model from calling any tool.
      properties:
        type:
          type: string
          enum:
            - none
          const: none
      required:
        - type
    MessageToolChoiceTool:
      title: Message Tool Choice (Tool)
      type: object
      description: Force the model to call a specific tool by name.
      properties:
        type:
          type: string
          enum:
            - tool
          const: tool
        name:
          type: string
          description: Name of the required tool.
        disable_parallel_tool_use:
          type: boolean
          nullable: true
          description: Silently dropped.
      required:
        - type
        - name
    MessageInputTextBlock:
      title: Message Input Text Block
      type: object
      description: Plain-text segment of a message.
      properties:
        type:
          type: string
          enum:
            - text
          const: text
        text:
          type: string
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
        citations:
          title: Citations
          type: array
          items:
            type: object
            additionalProperties: true
          nullable: true
      required:
        - type
        - text
    MessageInputImageBlock:
      title: Message Input Image Block
      type: object
      description: >-
        Image content. Only `source.type:"base64"` is supported in v1; URL
        sources return 400.
      properties:
        type:
          type: string
          enum:
            - image
          const: image
        source:
          oneOf:
            - $ref: '#/components/schemas/MessageInputImageSourceBase64'
            - $ref: '#/components/schemas/MessageInputImageSourceUrl'
          discriminator:
            propertyName: type
            mapping:
              base64:
                $ref: '#/components/schemas/MessageInputImageSourceBase64'
              url:
                $ref: '#/components/schemas/MessageInputImageSourceUrl'
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
      required:
        - type
        - source
    MessageInputVideoBlock:
      title: Message Input Video Block
      type: object
      description: Video content.
      properties:
        type:
          type: string
          enum:
            - video
          const: video
        source:
          oneOf:
            - $ref: '#/components/schemas/MessageInputVideoSourceBase64'
            - $ref: '#/components/schemas/MessageInputVideoSourceUrl'
          discriminator:
            propertyName: type
            mapping:
              base64:
                $ref: '#/components/schemas/MessageInputVideoSourceBase64'
              url:
                $ref: '#/components/schemas/MessageInputVideoSourceUrl'
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
      required:
        - type
        - source
    MessageInputToolUseBlock:
      title: Message Input Tool Use Block
      type: object
      description: A prior assistant turn that invoked a tool.
      properties:
        type:
          type: string
          enum:
            - tool_use
          const: tool_use
        id:
          type: string
          description: >-
            Unique identifier for the tool call (used to correlate
            `tool_result`).
        name:
          type: string
          description: Name of the tool being invoked.
        input:
          type: object
          additionalProperties: true
          description: Tool inputs as a JSON object.
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
      required:
        - type
        - id
        - name
        - input
    MessageInputToolResultBlock:
      title: Message Input Tool Result Block
      type: object
      description: Result of a prior tool call.
      properties:
        type:
          type: string
          enum:
            - tool_result
          const: tool_result
        tool_use_id:
          type: string
          description: ID of the `tool_use` block this result corresponds to.
        content:
          anyOf:
            - type: string
            - title: Tool Result Content Array
              type: array
              items:
                $ref: '#/components/schemas/MessageInputToolResultContent'
        is_error:
          type: boolean
          nullable: true
          description: Silently dropped in v1.
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
      required:
        - type
        - tool_use_id
    MessageInputServerToolUseBlock:
      title: Message Input Server Tool Use Block
      type: object
      description: >-
        Anthropic compatibility only — SambaNova does not run server-side tools.
        A prior assistant turn that invoked an Anthropic-hosted tool
        (web_search, code_execution, etc.). Accepted in conversation history
        (e.g. replaying an Anthropic-served session) but never originates from a
        SambaNova response. New `server_tool_use`-type tool definitions on
        outgoing requests are rejected with 400 `unsupported_tool_type`.
      properties:
        type:
          type: string
          enum:
            - server_tool_use
          const: server_tool_use
        id:
          type: string
        name:
          type: string
        input:
          type: object
          additionalProperties: true
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
      required:
        - type
        - id
        - name
        - input
    MessageInputSearchResultBlock:
      title: Message Input Search Result Block
      type: object
      description: >-
        Inline search result content. In v1 the `title`, `source`, and
        `content[]` text are extracted into a text block; citations are dropped.
      properties:
        type:
          type: string
          enum:
            - search_result
          const: search_result
        title:
          type: string
        source:
          type: string
        content:
          type: array
          items:
            $ref: '#/components/schemas/MessageInputTextBlock'
        citations:
          type: object
          additionalProperties: true
          nullable: true
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
      required:
        - type
    MessageInputWebSearchToolResultBlock:
      title: Message Input Web Search Tool Result Block
      type: object
      description: >-
        Anthropic compatibility only — SambaNova does not run server-side
        `web_search`. Echo of a prior Anthropic-served `web_search` tool call;
        accepted in conversation history but never originates from a SambaNova
        response. When present, only `title` (`url`) per result is extracted
        into a tool message.
      properties:
        type:
          type: string
          enum:
            - web_search_tool_result
          const: web_search_tool_result
        tool_use_id:
          type: string
        content:
          type: array
          items:
            type: object
            additionalProperties: true
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
      required:
        - type
        - tool_use_id
        - content
    MessageInputWebFetchToolResultBlock:
      title: Message Input Web Fetch Tool Result Block
      type: object
      description: >-
        Anthropic compatibility only — SambaNova does not run server-side
        `web_fetch`. Echo of a prior Anthropic-served `web_fetch` tool call;
        accepted in conversation history but never originates from a SambaNova
        response. When present, only the text content is extracted.
      properties:
        type:
          type: string
          enum:
            - web_fetch_tool_result
          const: web_fetch_tool_result
        tool_use_id:
          type: string
        content:
          type: object
          additionalProperties: true
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
      required:
        - type
        - tool_use_id
        - content
    MessageInputCodeExecutionToolResultBlock:
      title: Message Input Code Execution Tool Result Block
      type: object
      description: >-
        Anthropic compatibility only — SambaNova does not run server-side
        `code_execution`. Echo of a prior Anthropic-served `code_execution` tool
        call; accepted in conversation history but never originates from a
        SambaNova response. When present, only `stdout`, `stderr`, and
        `return_code` are extracted; image output is dropped.
      properties:
        type:
          type: string
          enum:
            - code_execution_tool_result
          const: code_execution_tool_result
        tool_use_id:
          type: string
        content:
          type: object
          additionalProperties: true
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
      required:
        - type
        - tool_use_id
        - content
    MessageInputBashCodeExecutionToolResultBlock:
      title: Message Input Bash Code Execution Tool Result Block
      type: object
      description: >-
        Anthropic compatibility only — SambaNova does not run server-side bash
        code execution. Echo of a prior Anthropic-served bash tool call;
        accepted in conversation history but never originates from a SambaNova
        response. Same lossy extraction as `code_execution_tool_result`.
      properties:
        type:
          type: string
          enum:
            - bash_code_execution_tool_result
          const: bash_code_execution_tool_result
        tool_use_id:
          type: string
        content:
          type: object
          additionalProperties: true
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
      required:
        - type
        - tool_use_id
        - content
    MessageInputTextEditorCodeExecutionToolResultBlock:
      title: Message Input Text Editor Code Execution Tool Result Block
      type: object
      description: >-
        Anthropic compatibility only — SambaNova does not run server-side
        text-editor code execution. Echo of a prior Anthropic-served text-editor
        tool call; accepted in conversation history but never originates from a
        SambaNova response. When present, only file content is extracted;
        metadata (line count, file type) is dropped.
      properties:
        type:
          type: string
          enum:
            - text_editor_code_execution_tool_result
          const: text_editor_code_execution_tool_result
        tool_use_id:
          type: string
        content:
          type: object
          additionalProperties: true
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
      required:
        - type
        - tool_use_id
        - content
    MessageInputToolSearchToolResultBlock:
      title: Message Input Tool Search Tool Result Block
      type: object
      description: >-
        Anthropic compatibility only — SambaNova does not run server-side
        `tool_search`. Echo of a prior Anthropic-served `tool_search` tool call;
        accepted in conversation history but never originates from a SambaNova
        response. When present, an empty string is emitted to the tool message
        (no plain-text fields).
      properties:
        type:
          type: string
          enum:
            - tool_search_tool_result
          const: tool_search_tool_result
        tool_use_id:
          type: string
        content:
          type: object
          additionalProperties: true
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
      required:
        - type
        - tool_use_id
        - content
    MessageInputThinkingBlock:
      title: Message Input Thinking Block
      type: object
      description: Extended-reasoning trace from a prior assistant turn.
      properties:
        type:
          type: string
          enum:
            - thinking
          const: thinking
        thinking:
          type: string
        signature:
          type: string
      required:
        - type
        - thinking
        - signature
    MessageInputRedactedThinkingBlock:
      title: Message Input Redacted Thinking Block
      type: object
      description: >-
        Anthropic compatibility only — SambaNova does not produce encrypted
        thinking output. Echo of a prior Anthropic-served response where
        `thinking.display:"omitted"` was set. Accepted in conversation history
        but never originates from a SambaNova response. Silently dropped on
        input.
      properties:
        type:
          type: string
          enum:
            - redacted_thinking
          const: redacted_thinking
        data:
          type: string
      required:
        - type
        - data
    MessageInputContainerUploadBlock:
      title: Message Input Container Upload Block
      type: object
      description: >-
        Anthropic compatibility only — SambaNova does not produce
        container_upload blocks (these come from Anthropic's server-side
        `code_execution` tool). Accepted in conversation history but never
        originates from a SambaNova response. Silently dropped on input.
      properties:
        type:
          type: string
          enum:
            - container_upload
          const: container_upload
        file_id:
          type: string
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
      required:
        - type
        - file_id
    MessageInputDocumentBlock:
      title: Message Input Document Block
      type: object
      description: >-
        PDF or document content. **Returns 400** — no document-extraction
        pipeline available.
      properties:
        type:
          type: string
          enum:
            - document
          const: document
        source:
          type: object
          additionalProperties: true
        title:
          type: string
          nullable: true
        context:
          type: string
          nullable: true
        citations:
          type: object
          additionalProperties: true
          nullable: true
        cache_control:
          $ref: '#/components/schemas/MessageCacheControl'
      required:
        - type
        - source
    MessageInputImageSourceBase64:
      title: Message Input Image Source (Base64)
      type: object
      description: Inline image data encoded as base64.
      properties:
        type:
          type: string
          enum:
            - base64
          const: base64
        media_type:
          type: string
          enum:
            - image/jpeg
            - image/png
            - image/webp
          description: MIME type of the image bytes.
        data:
          type: string
          description: Base64-encoded image bytes (no `data:` URI prefix).
      required:
        - type
        - media_type
        - data
    MessageInputImageSourceUrl:
      title: Message Input Image Source (URL)
      type: object
      description: >-
        HTTPS URL pointing to an image. **Returns 400 in v1** — URL fetching is
        blocked. Use `type:"base64"` instead.
      properties:
        type:
          type: string
          enum:
            - url
          const: url
        url:
          type: string
          format: uri
      required:
        - type
        - url
    MessageInputVideoSourceBase64:
      title: Message Input Video Source (Base64)
      type: object
      description: Inline video data encoded as base64.
      properties:
        type:
          type: string
          enum:
            - base64
          const: base64
        media_type:
          type: string
          enum:
            - video/mp4
          description: MIME type of the video bytes.
        data:
          type: string
          description: Base64-encoded video bytes (no `data:` URI prefix).
      required:
        - type
        - media_type
        - data
    MessageInputVideoSourceUrl:
      title: Message Input Video Source (URL)
      type: object
      description: HTTPS URL pointing to a video.
      properties:
        type:
          type: string
          enum:
            - url
          const: url
        url:
          type: string
          format: uri
      required:
        - type
        - url
    MessageInputToolResultContent:
      title: Message Input Tool Result Content
      description: Content of a `tool_result` block. only text is forwarded.
      oneOf:
        - $ref: '#/components/schemas/MessageInputTextBlock'
        - $ref: '#/components/schemas/MessageInputImageBlock'
      discriminator:
        propertyName: type
        mapping:
          text:
            $ref: '#/components/schemas/MessageInputTextBlock'
          image:
            $ref: '#/components/schemas/MessageInputImageBlock'
  securitySchemes:
    api_key:
      type: http
      description: >-
        SambaNova API key, sent as a bearer token in the `Authorization` header
        (`Authorization: Bearer <key>`). Default authentication scheme used by
        the SambaNova SDK across every OpenAI compatible endpoint.
      scheme: bearer
      bearerFormat: apiKey
    x_api_key:
      type: apiKey
      description: >-
        SambaNova API key, sent in the `x-api-key` header. Accepted on the
        Messages API routes (`/messages`, `/messages/count_tokens`) so that
        callers can point the official Anthropic SDK at SambaNova by swapping
        `base_url` — no code changes. The credential value is the same as the
        bearer `api_key` scheme; only the transport differs.
      in: header
      name: x-api-key

````