POST /v1/messages
Native Anthropic Messages API. Anthropic-format clients (Claude Code, Claude Desktop, the Anthropic SDKs) target Consus Gateway directly, with no translation layer.
Any active Claude model can be served. The compliance level in the model field selects the government cloud provider that serves the request (see Models for the model:level grammar and the catalog). Google and OpenAI models are not served here; use /v1/chat/completions for those.
This surface has two endpoints: /v1/messages (this section) and /v1/messages/count_tokens.
Request
Headers
Body Parameters
The body is native Anthropic Messages API JSON; see Anthropic’s Messages API reference for the full schema. The gateway validates three fields and passes the rest through for the model to validate:
Everything else (
system, temperature, top_p, tools, tool_choice, stop_sequences, metadata, stream, thinking) passes through unchanged, with three gateway-side behaviors to know about:
stream: trueswitches the response to Server-Sent Events. See Streaming.- Fields the upstream provider’s API version does not support are stripped rather than rejected (e.g.
context_management). - When a
thinkingblock is enabled, the gateway adjusts a few related fields so the request stays valid upstream, and tells you what changed in a response header. See Extended Thinking.
Response
Headers
Non-Streaming
The body is the native Anthropic Messages response, with one optional addition (x_consus_governance, see Tool Use):
Streaming
Setstream: true to receive Server-Sent Events matching Anthropic’s streaming protocol:
content_block_delta with {"type":"input_json_delta","partial_json":"..."}.
Streaming is real and incremental: the gateway relays the provider’s native events as the model generates them, so first-token latency reflects the model, not the full completion. Streaming requests are not bound by the 5-minute non-streaming ceiling. They run up to ~15 minutes (see Request Timeout), which lets long reasoning turns complete instead of timing out.
Token Counting
POST /v1/messages/count_tokens
Counts the input tokens a request would consume, without generating anything. Anthropic-format clients call this automatically to budget their context windows; the gateway serves it so they don’t fall back to sending paid probe requests.
Counting is free: requests are never billed and successful counts do not appear in your usage records.
Request
Same body shape as/v1/messages: model and messages required, plus any of system, tools, tool_choice, and thinking:
max_tokens is not required. It is accepted and ignored: it is an output-side cap that cannot change the input count, so the same body always counts the same with or without it.
Response
usage.input_tokens, including tool-definition overhead and the prompt overhead of an enabled thinking block. Output-side settings that cannot affect the input count (max_tokens, output_config) are ignored. A thinking block is counted the way the billed request sends it: on models that use the budgeted shape, an adaptive-shape block is converted to budgeted and its overhead counted; on adaptive-API models the block adds no input overhead and is ignored. Budget values below the API minimum are raised for the count (the budget amount itself never affects the input count).
Model coverage
Counting is available for every Claude compliance level — Vertex-served levels (:il2, :fedramp-high) and Bedrock-served levels (:il5, :itar) alike — with one model-specific exception.
Claude Opus 4.8’s :itar level does not support token counting. Opus 4.8 is served on AWS Bedrock only for ITAR (claude-opus-4-8:itar), and AWS Bedrock does not yet support token counting for this model, so a count request on that level returns a 400 invalid_request_error — “Token counting is not yet available for this model. Estimate client-side for now.” The gateway fails closed here rather than counting the prompt on Opus 4.8’s lower-boundary Vertex deployment, which would cross the compliance boundary. Counting works normally on Opus 4.8’s Vertex-served levels (:il2, :fedramp-high), and inference itself (/v1/messages, /v1/chat/completions, streaming) is fully available on :itar — only the pre-flight token count is affected. All other Claude models count on every level as usual.
Tool Use
Tool definitions andtool_use content blocks pass through natively. There is no translation through OpenAI’s tool_calls shape.
Tool Call Governance Metadata
When a model returnstool_use blocks, the gateway scans each input payload for outbound destinations (URLs with a scheme like https://, ftp://, s3://, data:, mailto:, and raw IPv4 addresses). When any are found, the response includes an advisory x_consus_governance field alongside the standard Anthropic body. The tool_use block itself is not modified.
consus_governance SSE event after message_stop:
input and decides what to do with the destinations.
Extended Thinking
Claude’s native extended thinking is supported. Models on Anthropic’s adaptive thinking API (Claude Opus 4.7 and 4.8) take the adaptive shape, which the gateway forwards untouched:400, the gateway adjusts it so it stays valid and reports any change in the x-consus-thinking-adjusted response header:
- Budget clamp.
budget_tokensmust be strictly less thanmax_tokens. When it is not, the gateway lowers it to fit and leaves room for output. For example,budget_tokens: 32000withmax_tokens: 8192is lowered to7168. - Drop when there is no room. When
max_tokensis too small to hold even the minimum thinking budget plus output, thinking is dropped and the request runs without it. - Sampling stripped.
temperature,top_p, andtop_kare not compatible with extended thinking, so they are removed when thinking is enabled. - Forced tool choice relaxed. A forced
tool_choice({"type": "any"}or a specific tool) is not compatible with extended thinking, so it is changed to{"type": "auto"}.
interleaved-thinking-2025-05-14 beta in the request body, over-budget allowances depend on the serving provider: Bedrock-served compliance levels honor a budget above max_tokens, while Vertex-served levels clamp it regardless. The header tells you what happened either way.
This mirrors the reasoning handling on /v1/chat/completions, applied to the native thinking block instead of reasoning_effort.
Errors
Errors are returned in Anthropic’s error shape:Known Limitations
- No Anthropic Batches or Files APIs.
/v1/messages/batchesand/v1/filesare not implemented; only/v1/messagesand/v1/messages/count_tokensare served on the Anthropic surface.