Skip to content
LLM Router
Gateway API

Anthropic Messages

Create messages using Anthropic Messages API format

POST/v1/messages

Creates a message using Anthropic's native Messages API format. This endpoint provides the same API format as Anthropic's official API, making it easy to migrate existing integrations or use Anthropic-specific features.

Requests can also be routed to other supported providers and converted back to Messages format. Provider-specific fields, thinking signatures and native tools are not universally portable: use the compatible destination provider when you need its native features.

Create a response in Anthropic Messages format. Supports native Anthropic dispatch and conversion to other supported providers; it is not restricted to the Anthropic provider. Native dispatch preserves provider-specific JSON fields when the destination supports the caller’s format. Cross-format routing converts through the Gateway’s shared representation: provider-only features are not guaranteed to survive. Support for reasoning, images, built-in tools and structured outputs depends on the destination model.

POSThttps://edgee.io/v1/messages

Try this endpoint

Configure your request, then run the curl command in your terminal or send it from this page.

Comma-separated analytics tags. Trimmed and merged with body tags.

Enable debug capture for this request. Does not add a debug object to the API response.

Turn tool-result trimming on or off. Overrides the API key setting for this request only. Values are case-insensitive, and a missing or invalid value keeps the key's setting.

Turn MCP tool surface reduction on or off. The threshold and resolver mode still come from the API key. Overrides the API key setting for this request only. Values are case-insensitive, and a missing or invalid value keeps the key's setting.

Turn output brevity on or off. Overrides the API key setting for this request only. Values are case-insensitive, and a missing or invalid value keeps the key's setting.

Session identifier used to group request usage.

Anthropic API version header. Forwarded on the native Anthropic path; not a cross-provider capability switch.

Provider beta feature flags for native Anthropic requests. Availability depends on the upstream provider.

Run in your terminal

Set EDGEE_API_KEY to your Gateway API key in your terminal, then copy and run this command. Gateway requests may consume credits.

curl
curl --include --no-buffer --globoff --request POST 'https://edgee.io/v1/messages' \
  --header "Authorization: Bearer $EDGEE_API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "model": "anthropic/claude-sonnet-4-6",
  "max_tokens": 256,
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ]
}'
Send from browser

Your request is relayed through the Edgee documentation server to the Gateway. Your key is used only for this request and is not stored.

Authentication

Use an Edgee Gateway API key. Send it as Authorization: Bearer <key> or x-api-key: <key>.

Parameters

X-Edgee-Tagsheader · string

Comma-separated analytics tags. Trimmed and merged with body tags.

X-Edgee-Debugheader · string

Enable debug capture for this request. Does not add a debug object to the API response.

X-Edgee-Compression-Tool-Result-Trimmingheader · string

Turn tool-result trimming on or off. Overrides the API key setting for this request only. Values are case-insensitive, and a missing or invalid value keeps the key's setting.

X-Edgee-Compression-Tool-Surface-Reductionheader · string

Turn MCP tool surface reduction on or off. The threshold and resolver mode still come from the API key. Overrides the API key setting for this request only. Values are case-insensitive, and a missing or invalid value keeps the key's setting.

X-Edgee-Compression-Brevityheader · string

Turn output brevity on or off. Overrides the API key setting for this request only. Values are case-insensitive, and a missing or invalid value keeps the key's setting.

X-Edgee-Session-Idheader · string

Session identifier used to group request usage.

anthropic-versionheader · string

Anthropic API version header. Forwarded on the native Anthropic path; not a cross-provider capability switch.

anthropic-betaheader · string

Provider beta feature flags for native Anthropic requests. Availability depends on the upstream provider.

Request body

Native dispatch preserves provider-specific JSON fields when the destination supports the caller’s format. Cross-format routing converts through the Gateway’s shared representation: provider-only features are not guaranteed to survive. Support for reasoning, images, built-in tools and structured outputs depends on the destination model.

modelstringrequired

Model identifier from GET /v1/models, in author/model format, or a configured global alias. Append :provider to request a specific provider route. Available models and providers depend on your key and organization policies.

max_tokensintegerrequired

Maximum number of tokens to generate

messagesarrayrequired

Array of message objects

Show schema
rolestringrequired

The role of the message

Values: user, assistant
contentunionrequired
Show schema
Option 1

Simple text content

string
Option 2

Array of content blocks

Common Anthropic content blocks. Native dispatch can carry additional provider-specific blocks; conversion paths only preserve supported content. Cross-provider reasoning is emitted as text, never as forged signed thinking blocks.

Option 1
typestringrequired
Values: text
textstringrequired
cache_controlobject
Option 2
typestringrequired
Values: tool_use
idstringrequired
namestringrequired
inputobjectrequired
Option 3
typestringrequired
Values: tool_result
tool_use_idstringrequired
contentunionrequired
is_errorboolean
Default: false
cache_controlobject
Option 4
typestringrequired
Values: image
sourceunionrequired
cache_controlobject
Option 5
typestringrequired
Values: thinking
thinkingstringrequired
signaturestring

Preserve provider-issued signatures when replaying history. Unsigned thinking blocks are stripped before upstream Anthropic calls.

Option 6
typestringrequired
Values: redacted_thinking
datastringrequired
systemunion
Show schema
Option 1

System prompt as a string

string
Option 2

System prompt as content blocks

Common Anthropic content blocks. Native dispatch can carry additional provider-specific blocks; conversion paths only preserve supported content. Cross-provider reasoning is emitted as text, never as forged signed thinking blocks.

Option 1
typestringrequired
Values: text
textstringrequired
cache_controlobject
Show schema
typestringrequired
Values: ephemeral
ttlstring
Values: 5m, 1h
Option 2
typestringrequired
Values: tool_use
idstringrequired
namestringrequired
inputobjectrequired
Option 3
typestringrequired
Values: tool_result
tool_use_idstringrequired
contentunionrequired
Show schema
Option 1
string
Option 2
Option 1
typestringrequired
Values: text
textstringrequired
cache_controlobject
Option 2
typestringrequired
Values: image
sourceunionrequired
is_errorboolean
Default: false
cache_controlobject
Show schema
typestringrequired
Values: ephemeral
ttlstring
Values: 5m, 1h
Option 4
typestringrequired
Values: image
sourceunionrequired
Show schema
Option 1
typestringrequired
Values: url
urlstringrequired
Option 2
typestringrequired
Values: base64
media_typestringrequired
datastringrequired
cache_controlobject
Show schema
typestringrequired
Values: ephemeral
ttlstring
Values: 5m, 1h
Option 5
typestringrequired
Values: thinking
thinkingstringrequired
signaturestring

Preserve provider-issued signatures when replaying history. Unsigned thinking blocks are stripped before upstream Anthropic calls.

Option 6
typestringrequired
Values: redacted_thinking
datastringrequired
streamboolean

Enable streaming responses

Default: false
toolsarray

Tool definitions

Show schema
namestringrequired

The name of the tool

descriptionstring

Description of what the tool does

input_schemaobject

JSON Schema describing the tool's input parameters

Default: {"type":"object","properties":{}}
cache_controlobject
Show schema
typestringrequired
Values: ephemeral
ttlstring
Values: 5m, 1h
tool_choiceobject
Show schema
Option 1
typestringrequired

Model decides whether to use tools

Values: auto
Option 2
typestringrequired

Model must use one of the provided tools

Values: any
Option 3
typestringrequired
Values: tool
namestringrequired

Name of the specific tool to use

enable_debugboolean

Enable request debug capture. Gateway-only field; does not add debug information to the response.

tagsarray

Optional tags to categorize and label the request. Useful for filtering and grouping requests in analytics and logs. Can also be sent via the `x-edgee-tags` header as a comma-separated string.

Show schema
string
temperaturenumber
top_pnumber
thinkingobject
Show schema
typestringrequired

adaptive, disabled, or legacy enabled; supported modes depend on the model.

displaystring

summarized or omitted. Default display depends on the model.

budget_tokensinteger

Required for legacy enabled thinking; adaptive models do not use this budget.

output_configobject

Only effort is portable through the shared representation. Other fields such as format and task_budget are provider-native and are not preserved by every cross-format path.

Show schema
effortstring

Requested effort; common values include none, minimal, low, medium, high, xhigh and max. The supported vocabulary is model-specific. Cross-format routing maps supported values and can omit unrepresentable levels.

{
  "model": "anthropic/claude-sonnet-4-6",
  "max_tokens": 256,
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ]
}

Responses

200Message created successfully

application/json

idstringrequired

Unique identifier for this message

modelstringrequired

The model that generated the response

contentarrayrequired

Array of content blocks

Show schema

Common Anthropic content blocks. Native dispatch can carry additional provider-specific blocks; conversion paths only preserve supported content. Cross-provider reasoning is emitted as text, never as forged signed thinking blocks.

Option 1
typestringrequired
Values: text
textstringrequired
cache_controlobject
Show schema
typestringrequired
Values: ephemeral
ttlstring
Values: 5m, 1h
Option 2
typestringrequired
Values: tool_use
idstringrequired
namestringrequired
inputobjectrequired
Option 3
typestringrequired
Values: tool_result
tool_use_idstringrequired
contentunionrequired
Show schema
Option 1
string
Option 2
Option 1
typestringrequired
Values: text
textstringrequired
cache_controlobject
Option 2
typestringrequired
Values: image
sourceunionrequired
is_errorboolean
Default: false
cache_controlobject
Show schema
typestringrequired
Values: ephemeral
ttlstring
Values: 5m, 1h
Option 4
typestringrequired
Values: image
sourceunionrequired
Show schema
Option 1
typestringrequired
Values: url
urlstringrequired
Option 2
typestringrequired
Values: base64
media_typestringrequired
datastringrequired
cache_controlobject
Show schema
typestringrequired
Values: ephemeral
ttlstring
Values: 5m, 1h
Option 5
typestringrequired
Values: thinking
thinkingstringrequired
signaturestring

Preserve provider-issued signatures when replaying history. Unsigned thinking blocks are stripped before upstream Anthropic calls.

Option 6
typestringrequired
Values: redacted_thinking
datastringrequired
usageobjectrequired
Show schema
input_tokensintegerrequired

Number of input tokens.

output_tokensintegerrequired

Number of output tokens.

cache_read_input_tokensinteger

Number of input tokens read from the prompt cache.

cache_creation_input_tokensinteger

Number of input tokens written to the prompt cache.

cache_creationobject
Show schema
ephemeral_5m_input_tokensinteger
ephemeral_1h_input_tokensinteger
output_tokens_detailsobject
Show schema
thinking_tokensinteger
stop_reasonstring

Stop reason. Native provider responses may include additional reasons.

typestringrequired
Values: message
rolestringrequired
Values: assistant
stop_sequencestring

text/event-stream

Anthropic-style SSE: message_start, content_block_start/delta/stop, message_delta and message_stop; reasoning and tool argument deltas use their corresponding block types. Inspect error events even if HTTP status is 200.

string
400Malformed request, invalid/disabled model or provider, or unsupported conversion.

application/json

Option 1
typestringrequired
Values: error
errorobjectrequired
Show schema
typestringrequired
messagestringrequired
request_idstring
Option 2

OpenAI-shaped Gateway error. Native upstream errors can retain provider-specific details.

errorobjectrequired
Show schema
messagestringrequired

A human-readable error message.

typestringrequired

High-level error category.

codestring

Machine-readable error code, for example unauthorized, invalid_json, bad_model_id, model_disabled, provider_disabled, usage_limit_exceeded, usage_unavailable, provider_error or internal_error. Not an exhaustive enum.

paramstring

Name of the request parameter that caused the error, when applicable.

401Missing or invalid API credentials.

application/json

Option 1
typestringrequired
Values: error
errorobjectrequired
Show schema
typestringrequired
messagestringrequired
request_idstring
Option 2

OpenAI-shaped Gateway error. Native upstream errors can retain provider-specific details.

errorobjectrequired
Show schema
messagestringrequired

A human-readable error message.

typestringrequired

High-level error category.

codestring

Machine-readable error code, for example unauthorized, invalid_json, bad_model_id, model_disabled, provider_disabled, usage_limit_exceeded, usage_unavailable, provider_error or internal_error. Not an exhaustive enum.

paramstring

Name of the request parameter that caused the error, when applicable.

403Key inactive, expired, model restriction or other permission failure.

application/json

Option 1
typestringrequired
Values: error
errorobjectrequired
Show schema
typestringrequired
messagestringrequired
request_idstring
Option 2

OpenAI-shaped Gateway error. Native upstream errors can retain provider-specific details.

errorobjectrequired
Show schema
messagestringrequired

A human-readable error message.

typestringrequired

High-level error category.

codestring

Machine-readable error code, for example unauthorized, invalid_json, bad_model_id, model_disabled, provider_disabled, usage_limit_exceeded, usage_unavailable, provider_error or internal_error. Not an exhaustive enum.

paramstring

Name of the request parameter that caused the error, when applicable.

429Usage or routing-strategy budget exhausted, or provider rate limit.

application/json

Option 1
typestringrequired
Values: error
errorobjectrequired
Show schema
typestringrequired
messagestringrequired
request_idstring
Option 2

OpenAI-shaped Gateway error. Native upstream errors can retain provider-specific details.

errorobjectrequired
Show schema
messagestringrequired

A human-readable error message.

typestringrequired

High-level error category.

codestring

Machine-readable error code, for example unauthorized, invalid_json, bad_model_id, model_disabled, provider_disabled, usage_limit_exceeded, usage_unavailable, provider_error or internal_error. Not an exhaustive enum.

paramstring

Name of the request parameter that caused the error, when applicable.

500Internal processing error.

application/json

Option 1
typestringrequired
Values: error
errorobjectrequired
Show schema
typestringrequired
messagestringrequired
request_idstring
Option 2

OpenAI-shaped Gateway error. Native upstream errors can retain provider-specific details.

errorobjectrequired
Show schema
messagestringrequired

A human-readable error message.

typestringrequired

High-level error category.

codestring

Machine-readable error code, for example unauthorized, invalid_json, bad_model_id, model_disabled, provider_disabled, usage_limit_exceeded, usage_unavailable, provider_error or internal_error. Not an exhaustive enum.

paramstring

Name of the request parameter that caused the error, when applicable.

502Upstream provider failure.

application/json

Option 1
typestringrequired
Values: error
errorobjectrequired
Show schema
typestringrequired
messagestringrequired
request_idstring
Option 2

OpenAI-shaped Gateway error. Native upstream errors can retain provider-specific details.

errorobjectrequired
Show schema
messagestringrequired

A human-readable error message.

typestringrequired

High-level error category.

codestring

Machine-readable error code, for example unauthorized, invalid_json, bad_model_id, model_disabled, provider_disabled, usage_limit_exceeded, usage_unavailable, provider_error or internal_error. Not an exhaustive enum.

paramstring

Name of the request parameter that caused the error, when applicable.

503Usage accounting or upstream service temporarily unavailable.

application/json

Option 1
typestringrequired
Values: error
errorobjectrequired
Show schema
typestringrequired
messagestringrequired
request_idstring
Option 2

OpenAI-shaped Gateway error. Native upstream errors can retain provider-specific details.

errorobjectrequired
Show schema
messagestringrequired

A human-readable error message.

typestringrequired

High-level error category.

codestring

Machine-readable error code, for example unauthorized, invalid_json, bad_model_id, model_disabled, provider_disabled, usage_limit_exceeded, usage_unavailable, provider_error or internal_error. Not an exhaustive enum.

paramstring

Name of the request parameter that caused the error, when applicable.

529Upstream provider overloaded (when preserved by the request path).

application/json

Option 1
typestringrequired
Values: error
errorobjectrequired
Show schema
typestringrequired
messagestringrequired
request_idstring
Option 2

OpenAI-shaped Gateway error. Native upstream errors can retain provider-specific details.

errorobjectrequired
Show schema
messagestringrequired

A human-readable error message.

typestringrequired

High-level error category.

codestring

Machine-readable error code, for example unauthorized, invalid_json, bad_model_id, model_disabled, provider_disabled, usage_limit_exceeded, usage_unavailable, provider_error or internal_error. Not an exhaustive enum.

paramstring

Name of the request parameter that caused the error, when applicable.

Download the OpenAPI specification