Skip to main content
POST
Create a Message
OMA forwards the request to the configured model upstream. Optional beta fields depend on that upstream.

Authorizations

X-Api-Key
string
header
default:sk-ant-local-default
required

OMA workspace API key.

Headers

anthropic-beta
string

Optional header to specify the beta version(s) you want to use.

To use multiple betas, use a comma separated list like beta1,beta2 or specify the header multiple times for each beta.

anthropic-version
string

The version of the OMA API you want to use.

Read more about versioning and our version history here.

anthropic-user-profile-id
string

The user profile ID to attribute this request to. Use when acting on behalf of a party other than your organization. Requires the user-profiles beta header.

Query Parameters

beta
enum<boolean>
required

Selects the beta API contract for this endpoint. Must be true.

Available options:
true

Body

application/json
model
required

The model that will complete your prompt.

See models for additional details and options.

messages
InputMessage · object[]
required

Input messages.

Our models are trained to operate on alternating user and assistant conversational turns. When creating a new Message, you specify the prior conversational turns with the messages parameter, and the model then generates the next Message in the conversation. Consecutive user or assistant turns in your request will be combined into a single turn.

Each input message must be an object with a role and content. You can specify a single user-role message, or you can include multiple user and assistant messages.

If the final message uses the assistant role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.

Example with a single user message:

Example with multiple conversational turns:

Example with a partially-filled response from the model:

Each input message content may be either a single string or an array of content blocks, where each block has a specific type. Using a string for content is shorthand for an array of one content block of type "text". The following input messages are equivalent:

See input examples.

Note that if you want to include a system prompt, you can use the top-level system parameter — there is no "system" role for input messages in the Messages API.

There is a limit of 100,000 messages in a single request.

max_tokens
integer
required

The maximum number of tokens to generate before stopping.

Note that our models may stop before reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate.

Set to 0 to populate the prompt cache without generating a response.

Different models have different maximum values for this parameter. See models for details.

Required range: x >= 0
Example:

1024

cache_control
CacheControlEphemeral · object | null

Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.

container

Container parameters with skills to be loaded.

context_management
ContextManagementConfig · object | null

Context management configuration.

This allows you to control how the model manages context across multiple requests, such as whether to clear function results or not.

diagnostics
DiagnosticsParam · object | null

Request-level diagnostics. Supply previous_message_id to have the response include diagnostics.cache_miss_reason explaining any prompt-cache divergence from that prior request.

fallback_credit_token

The fallback_credit_token from a prior refusal's stop_details.

When a preceding request was refused and returned a fallback_credit_token, pass that code here on the retry to have the retry's cache-creation tokens for the prefix that was warm on the refused model billed at the cache-read rate. Must be redeemed by the same organization and workspace, with the same request body (optionally extended by one appended assistant message whose content is the partial text — with any trailing whitespace stripped from the final text block — and paired server-tool blocks streamed before the refusal; the appended-assistant form is not available for requests with output_format set or forced tool_choice), on an eligible fallback model, on the same platform, and within 5 minutes of the refusal; a mismatch is a 400. A token minted mid-server-tool-loop whose partial content was continuable may only be redeemed with the appended-assistant form — if an exact-body retry is rejected with a 400 saying the token must be redeemed by continuing the partial response, retry with the appended-assistant form instead.

When the appended-assistant form is used on a model that otherwise disallows assistant-turn prefill, this token also authorizes that one prefill.

Required string length: 1 - 2048
fallbacks

Opt-in server-side retry on one or more substitute models when the requested model declines for policy reasons. Tried in order: if the first entry also declines, the second is tried, and so on. The string "default" requests the requested model's server-defined default fallback configuration.

Required array length: 1 - 3 elements
inference_geo
string | null

Specifies the geographic region for inference processing. If not specified, the workspace's default_inference_geo is used.

mcp_servers
RequestMCPServerURLDefinition · object[]

MCP servers to be utilized in this request

Maximum array length: 20
metadata
Metadata · object

An object describing metadata about the request.

output_config
OutputConfig · object

Configuration options for the model's output, such as the output format.

output_format
JsonOutputFormat · object | null
deprecated

Deprecated: Use output_config.format instead. See structured outputs

A schema to specify the model's output format in responses. This parameter will be removed in a future release.

service_tier
enum<string>

Determines whether to use priority capacity (if available) or standard capacity for this request.

OMA offers different levels of service for your API requests. See service-tiers for details.

Available options:
auto,
standard_only
speed
enum<string> | null

The inference speed mode for this request. "fast" enables high output-tokens-per-second inference.

Available options:
standard,
fast
stop_sequences
string[]

Custom text sequences that will cause the model to stop generating.

Our models will normally stop when they have naturally completed their turn, which will result in a response stop_reason of "end_turn".

If you want the model to stop generating when it encounters custom strings of text, you can use the stop_sequences parameter. If the model encounters one of the custom sequences, the response stop_reason value will be "stop_sequence" and the response stop_sequence value will contain the matched stop sequence.

stream
boolean

Whether to incrementally stream the response using server-sent events.

See streaming for details.

Example:

false

system

System prompt.

A system prompt is a way of providing context and instructions to the model, such as specifying a particular goal or role. See our guide to system prompts.

Example:
temperature
number
deprecated

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.

Required range: 0 <= x <= 1
Example:

1

thinking
ThinkingConfigEnabled · object

Configuration for enabling the model's extended thinking.

When enabled, responses include thinking content blocks showing the model's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your max_tokens limit.

See extended thinking for details.

Example:
tool_choice
ToolChoiceAuto · object

The model will automatically decide whether to use tools.

tools
(Tool · object | BashTool_20241022 · object | BashTool_20250124 · object | CodeExecutionTool_20250522 · object | CodeExecutionTool_20250825 · object | CodeExecutionTool_20260120 · object | CodeExecutionTool_20260521 · object | ComputerUseTool_20241022 · object | MemoryTool_20250818 · object | ComputerUseTool_20250124 · object | TextEditor_20241022 · object | ComputerUseTool_20251124 · object | TextEditor_20250124 · object | TextEditor_20250429 · object | TextEditor_20250728 · object | WebSearchTool_20250305 · object | WebFetchTool_20250910 · object | WebSearchTool_20260209 · object | WebFetchTool_20260209 · object | WebFetchTool_20260309 · object | WebSearchTool_20260318 · object | WebFetchTool_20260318 · object | AdvisorTool_20260301 · object | ToolSearchToolBM25_20251119 · object | ToolSearchToolRegex_20251119 · object | MCPToolset · object)[]

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.

There are two types of tools: client tools and server tools. The behavior described below applies to client tools. For server tools, see their individual documentation as each has its own behavior (e.g., the web search tool).

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.

For example, if you defined tools as:

And then asked the model "What's the S&P 500 at today?", the model might produce tool_use content blocks in the response like this:

You might then run your get_stock_price tool with {"ticker": "^GSPC"} as an input, and return the following back to the model in a subsequent user message:

Tools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.

See our guide for more details.

Example:
top_k
integer
deprecated

Only sample from the top K options for each subsequent token.

Used to remove "long tail" low probability responses. Learn more technical details here.

Recommended for advanced use cases only.

Required range: x >= 0
Example:

5

top_p
number
deprecated

Use nucleus sampling.

In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by top_p.

Recommended for advanced use cases only.

Required range: 0 <= x <= 1
Example:

0.7

Response

Message object.

id
string
required

Unique object identifier.

The format and length of IDs may change over time.

Example:

"msg_013Zva2CMHLNnXjNJJKqJ2EF"

type
string
default:message
required

Object type.

For Messages, this is always "message".

Allowed value: "message"
role
string
default:assistant
required

Conversational role of the generated message.

This will always be "assistant".

Allowed value: "assistant"
content
(ResponseTextBlock · object | ResponseThinkingBlock · object | ResponseRedactedThinkingBlock · object | ResponseToolUseBlock · object | ResponseServerToolUseBlock · object | ResponseWebSearchToolResultBlock · object | ResponseWebFetchToolResultBlock · object | ResponseAdvisorToolResultBlock · object | ResponseCodeExecutionToolResultBlock · object | ResponseBashCodeExecutionToolResultBlock · object | ResponseTextEditorCodeExecutionToolResultBlock · object | ResponseToolSearchToolResultBlock · object | ResponseMCPToolUseBlock · object | ResponseMCPToolResultBlock · object | ResponseContainerUploadBlock · object | ResponseCompactionBlock · object | ResponseFallbackBlock · object)[]
required

Content generated by the model.

This is an array of content blocks, each of which has a type that determines its shape.

Example:

If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model's output.

For example, if the input messages were:

Then the response content might be:

Example:
model
required

The model that will complete your prompt.

See models for additional details and options.

stop_reason
enum<string> | null
required

The reason that we stopped.

This may be one the following values:

  • "end_turn": the model reached a natural stopping point
  • "max_tokens": we exceeded the requested max_tokens or the model's maximum
  • "stop_sequence": one of your provided custom stop_sequences was generated
  • "tool_use": the model invoked one or more tools
  • "pause_turn": we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue.
  • "refusal": when streaming classifiers intervene to handle potential policy violations
  • "model_context_window_exceeded": we exceeded the model's context window

In non-streaming mode this value is always non-null. In streaming mode, it is null in the message_start event and non-null otherwise.

Available options:
end_turn,
max_tokens,
stop_sequence,
tool_use,
pause_turn,
compaction,
refusal,
model_context_window_exceeded
stop_sequence
string | null
required

Which custom stop sequence was generated, if any.

This value will be a non-null string if one of your custom stop sequences was generated.

stop_details
RefusalStopDetails · object | null
required

Structured information about why model output stopped.

This is null when the stop_reason has no additional detail to report.

usage
Usage · object
required

Billing and rate-limit usage.

OMA's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems.

Under the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in usage will not match one-to-one with the exact visible content of an API request or response.

For example, output_tokens will be non-zero, even for an empty string response from the model.

Total input tokens in a request is the summation of input_tokens, cache_creation_input_tokens, and cache_read_input_tokens.

Example:
diagnostics
Diagnostics · object | null
required

Request-level diagnostics. Present only when diagnostics was supplied on the request; null when no prompt-cache divergence was detected.

context_management
ResponseContextManagement · object | null
required

Context management response.

Information about context management strategies applied during the request.

container
Container · object | null
required

Information about the container used in this request.

This will be non-null if a container tool (e.g. code execution) was used.