Skip to main content
POST
Handle an Anthropic Messages-compatible request, streaming or returning the assembled response

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Validates POST /v1/messages (Anthropic-compat) per PRD §05-public-api.

Accepts Anthropic's exact wire format so existing @anthropic-ai/sdk integrations (including coding agents such as Claude Code, per ADR-YGE00M) need only change the baseURL: structured content blocks (text / tool_use / tool_result / image), tool definitions, and cache_control markers on system blocks, content blocks, and tool definitions.

HASP-native flags (e.g. 'store') are rejected with 400 UNSUPPORTED_PARAMETER per PRD §05: "rejecting rather than silently accepting keeps the contract honest."

model
string
required
Maximum string length: 100
messages
object[]
required
Minimum array length: 1
max_tokens
integer | null
Required range: 1 <= x <= 32000
tool_choice
string | null

Shape-validated here; normalized by AnthropicMessagesRequestBuilder::buildToolChoice() and enforced by AiGatewayService::assertParametersSupported() (HASP-509).

stream
boolean | null
temperature
number | null
Required range: 0 <= x <= 1
top_p
number | null
Required range: 0 <= x <= 1
top_k
integer | null
Required range: x >= 1
provider_extensions
string[] | null

Escape hatch for Anthropic-specific wire keys the canonical fields above don't (yet) model — see ADR-ZP99PX. Merged into the raw wire payload by DirectProviderDriver; rejected with UNSUPPORTED_PARAMETER on drivers that can't honor it.

stop_sequences
string[] | null
metadata
object
on_behalf_of
object

Asserted end-user identity — a HASP extension on the Anthropic wire shape (Anthropic SDK users send it via extra_body). Records which user of your application took this action on the audit chain, as an assertion made by your integration — HASP does not verify it, it is never forwarded to the model provider, and it is never shown to the model. Distinct from metadata.user_id, which is provider metadata. Supported for API-key credentials only.

system
object[]

System is either a plain string or an array of blocks carrying per-block cache_control (Anthropic's system-prompt caching shape).

tools
object[] | null

Response

id
string
required
type
string
required
Allowed value: "message"
role
string
required
Allowed value: "assistant"
content
object[]
required
model
any
required
stop_reason
string
required
stop_sequence
null
required
usage
object
required
meta
object
required