POST /v1/messages
Anthropic-compatible messages API.
Inference APIs
Send native Anthropic messages through the gateway while keeping Anthropic request and response shapes intact.
POST/v1/messages
Request
- Auth: tenant auth when enabled; otherwise dev mode is open
- Content-Type:
application/json - Max body size: 4 MiB
- Provider restriction: Anthropic only
Request fields
| Field | Type | Required | Notes |
|---|---|---|---|
model | string | yes | Must resolve to provider: anthropic |
messages | array | yes | Anthropic messages array |
max_tokens | integer | yes | Required by the gateway |
stream | boolean | no | Enables SSE streaming |
system | any JSON | no | Passed upstream unchanged |
temperature | number | no | Passed upstream when present |
top_p | number | no | Passed upstream when present |
top_k | integer | no | Passed upstream when present |
tools | any JSON | no | Passed upstream unchanged |
tool_choice | any JSON | no | Passed upstream unchanged |
metadata or aramm | object | no | Attribution fields stripped before upstream dispatch |
| any other fields | any JSON | no | Preserved and forwarded unchanged |
Response schema
| Field | Type | Required | Notes |
|---|---|---|---|
id | string | yes | Gateway-owned message ID |
type | string | yes | Always message |
role | string | yes | Usually assistant |
model | string | yes | Rewritten to the public alias |
content | array | yes | Native Anthropic content blocks |
content[].type | string | yes | Block type such as text |
content[].text | string | no | Text payload for text blocks |
stop_reason | string | no | Native stop reason |
usage | object | no | Usage returned by Anthropic |
usage.input_tokens | integer | no | Input token count |
usage.output_tokens | integer | no | Output token count |
usage.cache_read_input_tokens | integer | no | Cache-read tokens when available |
usage.cache_creation_input_tokens | integer | no | Cache-write tokens when available |
Errors
| HTTP | Code | When |
|---|---|---|
400 | invalid_request_error | Malformed JSON, missing required fields, or invalid content |
400 | invalid_request_error | Resolved target is not Anthropic |
400 | invalid_request_error | Anthropic provider not configured |
422 | pii_detected | PII blocked by guardrails |
422 | BLOCKED_POLICY_VIOLATION | PDPA keyword policy block |
403 | CROSS_BORDER_TRANSFER_BLOCKED | PDPA cross-border transfer rejected |
429 | rate_limit_exceeded | Tenant rate limit exceeded |
402 | monthly_budget_exceeded | Monthly spend limit exceeded |
402 | insufficient_credits | Credit balance too low |
502 | api_error | Unexpected upstream Anthropic failure |
Notes
- Only Anthropic-resolved models are allowed.
- The gateway preserves the native Anthropic response shape.
- Response
modelandidare rewritten at the boundary. - Streaming SSE events are forwarded event-by-event.