---
title: "POST /v1/messages"
method: POST
path: "/v1/messages"
---

# POST /v1/messages

`POST /v1/messages`

## Request body

- union
  - object
    - `model` 'claude-opus-4-1-20250805' | 'anthropic/claude-opus-4-1-20250805' | 'claude-opus-4-20250514' | 'anthropic/claude-opus-4-20250514' | 'claude-sonnet-4-20250514' | 'anthropic/claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'anthropic/claude-sonnet-4-5-20250929' | 'claude-haiku-4-5-20251001' | 'anthropic/claude-haiku-4-5-20251001' | 'claude-opus-4-5-20251101' | 'anthropic/claude-opus-4-5-20251101' | 'claude-opus-4-6' | 'anthropic/claude-opus-4-6' | 'claude-sonnet-4-6' | 'anthropic/claude-sonnet-4-6' | 'claude-sonnet-4-latest' | 'anthropic/claude-sonnet-4' | 'claude-opus-4-latest' | 'anthropic/claude-opus-4' | 'claude-opus-4-1-latest' | 'claude-opus-4-1' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.1-20250805' | 'anthropic/claude-sonnet-4.5' | 'claude-sonnet-4-5' | 'anthropic/claude-haiku-4.5' | 'claude-haiku-4-5' | 'anthropic/claude-opus-4-5' | 'claude-opus-4-5' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-sonnet-4.6' | 'anthropic/claude-sonnet-4-6-20260218', required
    - `messages` union, required — A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, documents (txt, pdf), images, and audio.
      - object[]
        - `role` 'user' | 'assistant', required
        - `content` union, required
          - string
          - union[]
            - union
              - …
      - union[]
        - union
          - object
            - `role` 'system', required — The role of the author of the message — in this case, the system.
            - `content` union, required — The contents of the system message.
              - …
            - `name` string — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
          - object
            - `role` 'user', required — The role of the author of the message — in this case, the user
            - `content` union, required — The contents of the user message.
              - …
            - `name` string — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
          - object
            - `role` 'tool', required — The role of the author of the message — in this case, the tool.
            - `content` union, required — The contents of the tool message.
              - …
            - `tool_call_id` string, required — Tool call that this message is responding to.
            - `name` string, nullable — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
          - object
            - `role` 'function', required
            - `content` string, required
            - `name` string, required
          - object
            - `role` 'assistant', required — The role of the author of the message — in this case, the Assistant.
            - `content` union — The contents of the Assistant message. Required unless tool_calls or function_call is specified.
              - …
            - `tool_calls` union[] — The tool calls generated by the model, such as function calls.
              - …
            - `refusal` string, nullable — The refusal message by the Assistant.
            - `audio` object, nullable — Data about a previous audio response from the model.
              - …
            - `name` string — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
          - object
            - `content` union, required — The contents of the developer message.
              - …
            - `role` 'developer', required — The role of the author of the message — in this case, the developer.
            - `name` string — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
    - `metadata` object — An object describing metadata about the request
    - `stop_sequences` string[] — Custom text sequences that will cause the model to stop generating.
    - `stream` boolean — If set to True, the model response data will be streamed to the client as it is generated using server-sent events.
    - `system` union — A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role.
      - string
      - object[]
        - `type` 'text'
        - `text` string, required
        - `citations` union[]
          - union
            - object
              - …
            - object
              - …
            - object
              - …
            - object
              - …
            - object
              - …
    - `tool_choice` union — Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool. none is the default when no tools are present. auto is the default if tools are present.
      - object
        - `type` 'auto', required
        - `disable_parallel_tool_use` boolean
      - object
        - `type` 'any', required
        - `disable_parallel_tool_use` boolean
      - object
        - `name` string, required
        - `type` 'tool', required
        - `disable_parallel_tool_use` boolean
      - object
        - `type` 'none', required
      - 'none' | 'auto' | 'required' — none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools.
      - object — Specifies a tool the model should use. Use to force the model to call a specific function.
        - `type` 'function', required — The type of the tool. Currently, only function is supported.
        - `function` object, required
          - `name` string, required — The name of the function to call.
      - object — Constrains the tools available to the model to a pre-defined set.
        - `type` 'allowed_tools', required — The type of the tool. Currently, only function is supported.
        - `allowed_tools` object, required
          - `mode` 'auto' | 'required', required — Constrains the tools available to the model to a pre-defined set. - auto allows the model to pick from among the allowed tools and generate a message. - required requires the model to call one or more of the allowed tools.
          - `tools` object[], required — A list of tool definitions that the model should be allowed to call.
      - object — Specifies a tool the model should use. Use to force the model to call a specific function.
        - `type` 'function', required — The type of the tool. Currently, only function is supported.
        - `function` 'name', required — The name of the function to call.
      - object — Specifies a tool the model should use. Use to force the model to call a specific custom tool.
        - `type` 'custom', required — The type of the tool. Currently, only function is supported.
        - `custom` 'name', required — The name of the custom tool to call.
    - `tools` union — Definitions of tools that the model may use. If you include tools in your API request, the model may return tool_use content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using tool_result content blocks. Each tool definition includes: name: Name of the tool. description: Optional, but strongly-recommended description of the tool. input_schema: JSON schema for the tool input shape that the model will produce in tool_use output content blocks.
      - union[]
        - union
          - object
            - `name` string, required — Name of the tool.
            - `description` string — Description of what this tool does. Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.
            - `input_schema` object, required — JSON schema for this tool's input. This defines the shape of the input that your tool accepts and that the model will produce.
              - …
            - `type` 'custom'
            - `defer_loading` boolean
            - `eager_input_streaming` boolean
            - `input_examples` object[]
              - …
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'bash'
            - `type` 'bash_20250124', required
            - `input_examples` object[]
              - …
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'code_execution'
            - `type` 'code_execution_20250522', required
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'code_execution'
            - `type` 'code_execution_20250825', required
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'code_execution'
            - `type` 'code_execution_20260120', required
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'memory'
            - `type` 'memory_20250818', required
            - `input_examples` object[]
              - …
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'str_replace_editor'
            - `type` 'text_editor_20250124', required
            - `input_examples` object[]
              - …
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'str_replace_based_edit_tool'
            - `type` 'text_editor_20250429', required
            - `input_examples` object[]
              - …
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'str_replace_based_edit_tool'
            - `type` 'text_editor_20250728', required
            - `max_characters` number
            - `input_examples` object[]
              - …
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'web_search'
            - `type` 'web_search_20250305', required
            - `allowed_domains` string[]
            - `blocked_domains` string[]
            - `max_uses` number
            - `user_location` object
              - …
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'web_search'
            - `type` 'web_search_20260209', required
            - `allowed_domains` string[]
            - `blocked_domains` string[]
            - `max_uses` number
            - `user_location` object
              - …
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'web_fetch'
            - `type` 'web_fetch_20250910', required
            - `allowed_domains` string[]
            - `blocked_domains` string[]
            - `citations` object
              - …
            - `max_content_tokens` number
            - `max_uses` number
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'web_fetch'
            - `type` 'web_fetch_20260209', required
            - `allowed_domains` string[]
            - `blocked_domains` string[]
            - `citations` object
              - …
            - `max_content_tokens` number
            - `max_uses` number
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'web_fetch'
            - `type` 'web_fetch_20260309', required
            - `allowed_domains` string[]
            - `blocked_domains` string[]
            - `citations` object
              - …
            - `max_content_tokens` number
            - `max_uses` number
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'tool_search_tool_bm25'
            - `type` 'tool_search_tool_bm25_20251119' | 'tool_search_tool_bm25', required
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'tool_search_tool_regex'
            - `type` 'tool_search_tool_regex_20251119' | 'tool_search_tool_regex', required
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
      - union[]
        - union
          - object
            - `type` 'function', required — The type of the tool. Currently, only function is supported.
            - `function` object, required
              - …
          - object
            - `type` 'custom', required — The type of the tool. Currently, only function is supported.
            - `custom` object, required
              - …
    - `thinking` union — Configuration for enabling Claude's extended thinking. When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your max_tokens limit.
      - object
        - `type` 'enabled', required
        - `budget_tokens` integer, required — Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality. Must be ≥1024 and less than max_tokens.
        - `display` 'summarized' | 'omitted'
      - object
        - `type` 'disabled', required
      - object
        - `type` 'adaptive', required
        - `display` 'summarized' | 'omitted'
    - `max_tokens` number — The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API.
    - `temperature` number — Amount of randomness injected into the response. Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks. Note that even with temperature of 0.0, the results will not be fully deterministic.
    - `top_p` number — An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.
    - `top_k` number — Only sample from the top K options for each subsequent token. Used to remove "long tail" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature.
  - object
    - `model` 'claude-opus-4-7' | 'anthropic/claude-opus-4-7' | 'anthropic/claude-opus-4.7', required
    - `messages` union, required — A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, documents (txt, pdf), images, and audio.
      - object[]
        - `role` 'user' | 'assistant', required
        - `content` union, required
          - string
          - union[]
            - union
              - …
      - union[]
        - union
          - object
            - `role` 'system', required — The role of the author of the message — in this case, the system.
            - `content` union, required — The contents of the system message.
              - …
            - `name` string — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
          - object
            - `role` 'user', required — The role of the author of the message — in this case, the user
            - `content` union, required — The contents of the user message.
              - …
            - `name` string — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
          - object
            - `role` 'tool', required — The role of the author of the message — in this case, the tool.
            - `content` union, required — The contents of the tool message.
              - …
            - `tool_call_id` string, required — Tool call that this message is responding to.
            - `name` string, nullable — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
          - object
            - `role` 'function', required
            - `content` string, required
            - `name` string, required
          - object
            - `role` 'assistant', required — The role of the author of the message — in this case, the Assistant.
            - `content` union — The contents of the Assistant message. Required unless tool_calls or function_call is specified.
              - …
            - `tool_calls` union[] — The tool calls generated by the model, such as function calls.
              - …
            - `refusal` string, nullable — The refusal message by the Assistant.
            - `audio` object, nullable — Data about a previous audio response from the model.
              - …
            - `name` string — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
          - object
            - `content` union, required — The contents of the developer message.
              - …
            - `role` 'developer', required — The role of the author of the message — in this case, the developer.
            - `name` string — An optional name for the participant. Provides the model information to differentiate between participants of the same role.
    - `metadata` object — An object describing metadata about the request
    - `stop_sequences` string[] — Custom text sequences that will cause the model to stop generating.
    - `stream` boolean — If set to True, the model response data will be streamed to the client as it is generated using server-sent events.
    - `system` union — A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role.
      - string
      - object[]
        - `type` 'text'
        - `text` string, required
        - `citations` union[]
          - union
            - object
              - …
            - object
              - …
            - object
              - …
            - object
              - …
            - object
              - …
    - `tool_choice` union — Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool. none is the default when no tools are present. auto is the default if tools are present.
      - object
        - `type` 'auto', required
        - `disable_parallel_tool_use` boolean
      - object
        - `type` 'any', required
        - `disable_parallel_tool_use` boolean
      - object
        - `name` string, required
        - `type` 'tool', required
        - `disable_parallel_tool_use` boolean
      - object
        - `type` 'none', required
      - 'none' | 'auto' | 'required' — none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools.
      - object — Specifies a tool the model should use. Use to force the model to call a specific function.
        - `type` 'function', required — The type of the tool. Currently, only function is supported.
        - `function` object, required
          - `name` string, required — The name of the function to call.
      - object — Constrains the tools available to the model to a pre-defined set.
        - `type` 'allowed_tools', required — The type of the tool. Currently, only function is supported.
        - `allowed_tools` object, required
          - `mode` 'auto' | 'required', required — Constrains the tools available to the model to a pre-defined set. - auto allows the model to pick from among the allowed tools and generate a message. - required requires the model to call one or more of the allowed tools.
          - `tools` object[], required — A list of tool definitions that the model should be allowed to call.
      - object — Specifies a tool the model should use. Use to force the model to call a specific function.
        - `type` 'function', required — The type of the tool. Currently, only function is supported.
        - `function` 'name', required — The name of the function to call.
      - object — Specifies a tool the model should use. Use to force the model to call a specific custom tool.
        - `type` 'custom', required — The type of the tool. Currently, only function is supported.
        - `custom` 'name', required — The name of the custom tool to call.
    - `tools` union — Definitions of tools that the model may use. If you include tools in your API request, the model may return tool_use content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using tool_result content blocks. Each tool definition includes: name: Name of the tool. description: Optional, but strongly-recommended description of the tool. input_schema: JSON schema for the tool input shape that the model will produce in tool_use output content blocks.
      - union[]
        - union
          - object
            - `name` string, required — Name of the tool.
            - `description` string — Description of what this tool does. Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.
            - `input_schema` object, required — JSON schema for this tool's input. This defines the shape of the input that your tool accepts and that the model will produce.
              - …
            - `type` 'custom'
            - `defer_loading` boolean
            - `eager_input_streaming` boolean
            - `input_examples` object[]
              - …
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'bash'
            - `type` 'bash_20250124', required
            - `input_examples` object[]
              - …
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'code_execution'
            - `type` 'code_execution_20250522', required
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'code_execution'
            - `type` 'code_execution_20250825', required
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'code_execution'
            - `type` 'code_execution_20260120', required
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'memory'
            - `type` 'memory_20250818', required
            - `input_examples` object[]
              - …
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'str_replace_editor'
            - `type` 'text_editor_20250124', required
            - `input_examples` object[]
              - …
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'str_replace_based_edit_tool'
            - `type` 'text_editor_20250429', required
            - `input_examples` object[]
              - …
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'str_replace_based_edit_tool'
            - `type` 'text_editor_20250728', required
            - `max_characters` number
            - `input_examples` object[]
              - …
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'web_search'
            - `type` 'web_search_20250305', required
            - `allowed_domains` string[]
            - `blocked_domains` string[]
            - `max_uses` number
            - `user_location` object
              - …
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'web_search'
            - `type` 'web_search_20260209', required
            - `allowed_domains` string[]
            - `blocked_domains` string[]
            - `max_uses` number
            - `user_location` object
              - …
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'web_fetch'
            - `type` 'web_fetch_20250910', required
            - `allowed_domains` string[]
            - `blocked_domains` string[]
            - `citations` object
              - …
            - `max_content_tokens` number
            - `max_uses` number
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'web_fetch'
            - `type` 'web_fetch_20260209', required
            - `allowed_domains` string[]
            - `blocked_domains` string[]
            - `citations` object
              - …
            - `max_content_tokens` number
            - `max_uses` number
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'web_fetch'
            - `type` 'web_fetch_20260309', required
            - `allowed_domains` string[]
            - `blocked_domains` string[]
            - `citations` object
              - …
            - `max_content_tokens` number
            - `max_uses` number
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'tool_search_tool_bm25'
            - `type` 'tool_search_tool_bm25_20251119' | 'tool_search_tool_bm25', required
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
          - object
            - `name` 'tool_search_tool_regex'
            - `type` 'tool_search_tool_regex_20251119' | 'tool_search_tool_regex', required
            - `defer_loading` boolean
            - `strict` boolean
            - `allowed_callers` string[]
      - union[]
        - union
          - object
            - `type` 'function', required — The type of the tool. Currently, only function is supported.
            - `function` object, required
              - …
          - object
            - `type` 'custom', required — The type of the tool. Currently, only function is supported.
            - `custom` object, required
              - …
    - `thinking` union — Configuration for enabling Claude's extended thinking. When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your max_tokens limit.
      - object
        - `type` 'enabled', required
        - `budget_tokens` integer, required — Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality. Must be ≥1024 and less than max_tokens.
        - `display` 'summarized' | 'omitted'
      - object
        - `type` 'disabled', required
      - object
        - `type` 'adaptive', required
        - `display` 'summarized' | 'omitted'
    - `max_tokens` number — The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API.

## Response `200`

- object
  - `model` string, required — Model used to generate the response.
  - `id` string, required — Unique identifier of the generated message.
  - `type` string, required — Object type.
  - `role` string, required — Role of the message author.
  - `content` object[], required — Generated response content blocks.
    - `type` string, required — Content block type.
    - `text` string, required — Generated text content.
  - `stop_reason` string, nullable — Reason why generation stopped.
  - `stop_sequence` string, nullable — Custom stop sequence that caused generation to stop.
  - `stop_details` unknown
  - `usage` object, required — Token usage statistics for the request.
    - `input_tokens` integer, required — Number of input tokens used.
    - `cache_creation_input_tokens` integer, required — Number of tokens used for cache creation.
    - `cache_read_input_tokens` integer, required — Number of tokens retrieved from cache.
    - `cache_creation` object, required — Cache creation token statistics.
      - `ephemeral_5m_input_tokens` integer, required — Number of tokens cached for 5 minutes.
      - `ephemeral_1h_input_tokens` integer, required — Number of tokens cached for 1 hour.
    - `output_tokens` integer, required — Number of output tokens generated.
    - `service_tier` string, required — Service tier used for inference.
    - `inference_geo` string, required — Geographic inference location.
  - `meta` object — Additional metadata about the request.
    - `usage` object, required — Billing usage statistics.
      - `credits_used` number, required — Number of credits consumed.
      - `usd_spent` number, required — Amount spent in USD.

---

[API](https://skmtc.dev/aimlapi/apis/aiml-api.md) · [All operations](https://skmtc.dev/aimlapi/apis/aiml-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/aimlapi/aiml-api/revisions/6d578b39a9ec/schema)
