Skip to main content
POST /v1/messages Send the gateway token through x-api-key and set anthropic-version explicitly. Native requests include model and messages; the example explicitly supplies max_tokens, with system instructions at top-level system. The schema preserves the gateway’s optional budget behavior; actual native provider requests should supply a model-supported budget. Read nonstreaming content[] and check stop_reason. Values other than end_turn require appropriate handling: tool_use is not a final text answer and max_tokens may indicate truncation. With stream: true, use Claude SSE rather than a Chat / Responses event parser. The native Claude guide and complete TypeScript example include environment variables, run commands, and failure behavior. Only common text fields are expanded here; native extensions and conversion paths depend on channel support. /v1/messages/count_tokens is not enabled. Verified revision: d851a5faa49a00abaafd27bf91b311506fbfbc52. Source files are recorded in this operation’s x-source-files. The Python native SSE and tool-loop example offers text and tool modes, preserving native result association and signatures. 阅读中文

Native cache and reasoning controls

The project DTO represents request-level and content-block cache_control, plus top-level thinking, output_config, and context_management. Actual support, TTLs, budgets, and modes depend on the channel and model. Claude context_management is a protocol-specific object and is not copied directly during Responses conversion; identical names do not imply equivalent semantics. Native cache usage may contain usage.cache_read_input_tokens and cache_creation_input_tokens. Caching, reasoning, and compaction state do not automatically increase the model’s context window. Preserve thinking / signature / redacted_thinking continuation items according to the native protocol. Added fields verified against revision 30a6d88a4. Prompt caching · Reasoning · Context management

Authorizations

x-api-key
string
header
required

网关令牌 / Gateway token

Headers

anthropic-version
string
default:2023-06-01

适配器缺省版本;建议显式发送 / Adapter fallback version; send explicitly.

Body

application/json
model
string
required
Minimum string length: 1
Example:

"YOUR_MODEL_ID"

messages
object[]
required
Minimum array length: 1
max_tokens
integer

输出预算,实际范围依赖模型;调用原生供应商时应显式设置 / Output budget; model limits apply. Set explicitly for native provider requests.

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

256

system
stream
boolean
default:false
tools
object[]
cache_control
object

原生缓存控制;依赖渠道,TTL 与断点限制不能跨供应商假定一致 / Native cache control; channel dependent, TTL and breakpoint limits vary

Example:
thinking
object

原生推理配置;模式与预算由目标模型决定 / Native reasoning configuration; target model determines modes and budgets

output_config
object

原生输出配置,包含条件支持的 effort / Native output configuration, including conditional effort support

context_management
object

Claude 专用上下文编辑对象;Claude 转 Responses 不直接复制 / Claude-specific context editing; not copied directly into Responses

Response

检查原生完成状态及内容 / Check native completion status and content.

id
string
type
string
role
string
model
string
stop_reason
string | null
content
object[]
usage
object