跳转到内容

Anthropic Messages

POST /v1/messages  compatible  语义操作 generate  契约修订 1

状态语义:stateless; portable is default; native pins one exact Anthropic-wire provider profile and disables cross-provider fallback

逐条来自契约,不是补充说明:

  • only anthropic-version 2023-06-01 is accepted
  • anthropic-beta is forwarded only in native mode and only for tokens the selected connection has been configured to accept; portable mode rejects it because the request is re-authored through the canonical model and a beta token describes the request as written
  • tools are classified by execution site: Anthropic-defined client-executed tools are accepted at any dated version suffix, while provider-executed tools require the selected connection to declare provider_executed_tools, because the upstream would make network calls outside SafeTransport’s host allowlist
  • family matching is anchored to <family><YYYYMMDD>, so a longer name that merely begins with a known family (bash_code_execution*) is classified on its own terms rather than as the client-executed tool it resembles
  • portable mode rejects members of tools[], output_config, and message content blocks that the canonical model cannot carry, because that path re-authors the body and would otherwise drop them silently; native mode forwards them verbatim
  • mcp_servers, container, and fallbacks are rejected as deliberate boundaries rather than unmodelled fields: the first two delegate egress or code execution to the upstream, and the third moves model selection outside Halro’s routing and cost attribution
  • in native mode tool and content-block bodies are forwarded verbatim, so cache_control and per-tool configuration reach the provider unchanged; portable mode refuses them rather than re-authoring the body without them
  • Gateway Keys are accepted through x-api-key for official SDK compatibility and are never forwarded upstream
  • native mode is selected with Halro-Route-Mode and requires either the direct Anthropic or Bedrock Mantle Anthropic profile

Anthropic 兼容层。注意 base URL 不带 /v1 —— Anthropic SDK 自己会补上, 这与 OpenAI SDK 相反,接错的表现是 404。认证可用 x-api-keyAuthorization, 但两个头同时出现且值不一致会直接判失败。

Terminal window
curl https://halro.example.com/v1/messages \
-H "x-api-key: $HALRO_GATEWAY_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{ "model": "claude", "max_tokens": 256,
"messages": [{"role": "user", "content": "你好"}] }'
  • x-api-key or Authorization
  • anthropic-version
  • anthropic-beta
  • Halro-Route-Mode
  • Content-Type
字段不支持该字段的 Provider Profile组合级限制
model
max_tokens
messages
messages[].role
messages[].content
messages[].content[].type=document
messages[].content[].type=search_result
system
stream1 见脚注 1
stop_sequencesbedrock.mantle.openai.responses.v1
temperature
top_p
top_kopenai.chat-embeddings.v1azure-openai.chat-embeddings.v1deepseek.chat.v1openai-compatible.chat-embeddings.v1gemini.generate-content.text.v1betabedrock.runtime.converse.text.v1bedrock.mantle.openai.chat.v1bedrock.mantle.openai.responses.v1
toolsgemini.generate-content.text.v1betabedrock.runtime.converse.text.v12 见脚注 2
tools[].type=custom3 见脚注 3
tools[].type=bash_*4 见脚注 4
tools[].type=text_editor_*5 见脚注 5
tools[].type=memory_*6 见脚注 6
tools[].type=computer_*7 见脚注 7
tool_choicegemini.generate-content.text.v1betabedrock.runtime.converse.text.v1
thinkingopenai.chat-embeddings.v1azure-openai.chat-embeddings.v1deepseek.chat.v1openai-compatible.chat-embeddings.v1gemini.generate-content.text.v1betabedrock.runtime.converse.text.v1bedrock.mantle.openai.chat.v1bedrock.mantle.openai.responses.v1
metadataopenai.chat-embeddings.v1azure-openai.chat-embeddings.v1deepseek.chat.v1openai-compatible.chat-embeddings.v1gemini.generate-content.text.v1betabedrock.runtime.converse.text.v1bedrock.mantle.openai.chat.v1bedrock.mantle.openai.responses.v1
service_tieropenai.chat-embeddings.v1azure-openai.chat-embeddings.v1deepseek.chat.v1openai-compatible.chat-embeddings.v1gemini.generate-content.text.v1betabedrock.runtime.converse.text.v1bedrock.mantle.openai.chat.v1bedrock.mantle.openai.responses.v1
output_config8 见脚注 8
output_config.effortdeepseek.chat.v1gemini.generate-content.text.v1betabedrock.runtime.converse.text.v1bedrock.mantle.openai.responses.v1bedrock.mantle.anthropic.messages.v19 见脚注 9
output_config.formatdeepseek.chat.v1gemini.generate-content.text.v1betabedrock.runtime.converse.text.v1bedrock.mantle.anthropic.messages.v110 见脚注 10

这些字段在到达任何 Provider 之前就会被拒。照搬 OpenAI 文档最容易撞上的就是它们:

  • provider-executed tools (web_search_*, web_fetch_*, code_execution_*, advisor_*, tool_search_*) unless the selected connection declares provider_executed_tools
  • mcp_servers
  • container
  • fallbacks
  • Anthropic-defined tools in portable mode
  • strict tools in portable mode
  • signed thinking in portable mode
  • unknown top-level fields
  • unknown members of tools[] and output_config in portable mode

id type role content model stop_reason stop_sequence usage

message_start content_block_start content_block_delta content_block_stop message_delta message_stop ping error

可路由的 Provider Profile 及各自成熟度

Section titled “可路由的 Provider Profile 及各自成熟度”
Provider Profile成熟度不支持的请求字段
openai.chat-embeddings.v1compatibletop_kthinkingmetadataservice_tier
anthropic.messages.2023-06-01compatible未声明
azure-openai.chat-embeddings.v1compatibletop_kthinkingmetadataservice_tier
deepseek.chat.v1compatibletop_kthinkingmetadataservice_tieroutput_config.effortoutput_config.format
openai-compatible.chat-embeddings.v1compatibletop_kthinkingmetadataservice_tier
gemini.generate-content.text.v1betacompatibletop_ktoolstool_choicethinkingmetadataservice_tieroutput_config.effortoutput_config.format
bedrock.runtime.converse.text.v1compatibletop_ktoolstool_choicethinkingmetadataservice_tieroutput_config.effortoutput_config.format
bedrock.mantle.openai.chat.v1compatibletop_kthinkingmetadataservice_tier
bedrock.mantle.openai.responses.v1compatiblestop_sequencestop_kthinkingmetadataservice_tieroutput_config.effort
bedrock.mantle.anthropic.messages.v1compatibleoutput_config.effortoutput_config.format
openai.chat-embeddings.v1
  • portable Messages content is mapped through OpenAI Chat Completions
anthropic.messages.2023-06-01
  • native mode preserves validated Anthropic content blocks and events
azure-openai.chat-embeddings.v1
  • portable Messages content is mapped through Azure Chat Completions
deepseek.chat.v1
  • portable Messages content is mapped through DeepSeek Chat Completions
  • output_config.effort and output_config.format are declared unsupported at field granularity because support is value-dependent: none, low and high reach DeepSeek’s thinking switch while minimal, medium and xhigh have no rung, and DeepSeek has json_object but no schema mode
  • thinking stays unsupported for the same reason it is on every other portable profile — it is the Anthropic-native block config, which only native mode forwards; DeepSeek’s own thinking switch is reached through output_config.effort
openai-compatible.chat-embeddings.v1
  • portable Messages content is mapped through an OpenAI-compatible primitive
gemini.generate-content.text.v1beta
  • portable text Messages content is mapped through Gemini generateContent
  • output_config.effort and output_config.format are this endpoint’s spelling of reasoning_effort and response_format, which this profile declares unsupported at every value, so a request carrying either is routed away before provider I/O
bedrock.runtime.converse.text.v1
  • portable text Messages content is mapped through Bedrock Converse
  • output_config.effort and output_config.format are this endpoint’s spelling of reasoning_effort and response_format, which this profile declares unsupported at every value, so a request carrying either is routed away before provider I/O
bedrock.mantle.openai.chat.v1
  • portable Messages content is mapped through Bedrock Mantle Chat Completions
bedrock.mantle.openai.responses.v1
  • portable Messages content is mapped through stateless Bedrock Mantle Responses
  • streaming requests with tools are rejected before provider I/O
  • output_config.effort is this endpoint’s spelling of reasoning_effort, which the stateless Responses primitive does not carry, so a request carrying it is routed away before provider I/O
bedrock.mantle.anthropic.messages.v1
  • native mode preserves validated Anthropic content blocks, thinking signatures, and events
  • output_config is unsupported in portable mode only: this profile shares the Anthropic wire form and could carry the member, but its Mantle Beta capability ceiling is fixed by the build and widening it is a separate contract review, so a portable request carrying effort or format is routed away before provider I/O while native mode forwards the member verbatim

已验证的证据:gateway_contractprovider_transport_fixturesdk_blackbox

anthropic-goanthropic-typescriptanthropic-python


本页的字段表、覆盖矩阵与偏差列表由 Halro 7117fdc38491 的兼容性契约生成 (scripts/generate-api-pages.mjs,契约摘要 9f8a5c57f76ae870…)。 字段的类型、是否必填与语义说明尚未进入契约,因此本页只列字段名。

  1. stream —— bedrock.mantle.openai.responses.v1:streaming requests with tools are rejected before provider I/O

  2. tools —— bedrock.mantle.openai.responses.v1:streaming requests with tools are rejected before provider I/O

  3. tools[].type=custom —— bedrock.mantle.openai.responses.v1:streaming requests with tools are rejected before provider I/O

  4. tools[].type=bash_* —— bedrock.mantle.openai.responses.v1:streaming requests with tools are rejected before provider I/O

  5. tools[].type=text_editor_* —— bedrock.mantle.openai.responses.v1:streaming requests with tools are rejected before provider I/O

  6. tools[].type=memory_* —— bedrock.mantle.openai.responses.v1:streaming requests with tools are rejected before provider I/O

  7. tools[].type=computer_* —— bedrock.mantle.openai.responses.v1:streaming requests with tools are rejected before provider I/O

  8. output_config —— gemini.generate-content.text.v1beta:output_config.effort and output_config.format are this endpoint’s spelling of reasoning_effort and response_format, which this profile declares unsupported at every value, so a request carrying either is routed away before provider I/O;bedrock.runtime.converse.text.v1:output_config.effort and output_config.format are this endpoint’s spelling of reasoning_effort and response_format, which this profile declares unsupported at every value, so a request carrying either is routed away before provider I/O;bedrock.mantle.openai.responses.v1:output_config.effort is this endpoint’s spelling of reasoning_effort, which the stateless Responses primitive does not carry, so a request carrying it is routed away before provider I/O;bedrock.mantle.anthropic.messages.v1:output_config is unsupported in portable mode only: this profile shares the Anthropic wire form and could carry the member, but its Mantle Beta capability ceiling is fixed by the build and widening it is a separate contract review, so a portable request carrying effort or format is routed away before provider I/O while native mode forwards the member verbatim

  9. output_config.effort —— gemini.generate-content.text.v1beta:output_config.effort and output_config.format are this endpoint’s spelling of reasoning_effort and response_format, which this profile declares unsupported at every value, so a request carrying either is routed away before provider I/O;bedrock.runtime.converse.text.v1:output_config.effort and output_config.format are this endpoint’s spelling of reasoning_effort and response_format, which this profile declares unsupported at every value, so a request carrying either is routed away before provider I/O;bedrock.mantle.openai.responses.v1:output_config.effort is this endpoint’s spelling of reasoning_effort, which the stateless Responses primitive does not carry, so a request carrying it is routed away before provider I/O

  10. output_config.format —— gemini.generate-content.text.v1beta:output_config.effort and output_config.format are this endpoint’s spelling of reasoning_effort and response_format, which this profile declares unsupported at every value, so a request carrying either is routed away before provider I/O;bedrock.runtime.converse.text.v1:output_config.effort and output_config.format are this endpoint’s spelling of reasoning_effort and response_format, which this profile declares unsupported at every value, so a request carrying either is routed away before provider I/O