@anthropic-ai/sdk code and everything works. Requires the ai:chat scope.
Migrating from Anthropic
Request
| Parameter | Type | Description |
|---|---|---|
model | string | Model ID — same identifiers as Anthropic (claude-sonnet-4-6, etc.) |
messages | array | Conversation turns: [{"role": "user", "content": "..."}] |
max_tokens | integer | Required by Anthropic’s spec. |
stream | boolean | true for SSE, false for a single JSON response. |
system | string | System prompt. |
tools | array | Tool definitions (same format as Anthropic). |
Streaming events
Whenstream: true, the event stream uses Anthropic’s exact wire format:
Compliance behavior
All HASP compliance checks apply — PHI Guard, BAA enforcement, credit metering — regardless of which endpoint you use. Compliance is a property of your organization, not the endpoint shape.- PHI Guard runs on all messages. If
phi_mode=redact(default), PHI is replaced with placeholders before the upstream call. Ifphi_mode=block, the request returns403 PHI_BLOCKEDusing the HASP error envelope. - BAA required. No active BAA →
402 BAA_REQUIREDon every request. - Credit metering. Credits are deducted after each successful response. Exhausted credits →
402 AI_CREDITS_EXHAUSTED.
Native-only flags are rejected
Parameters that exist in the native/v1/ai/chat endpoint but not in Anthropic’s wire format are rejected with 400 UNSUPPORTED_PARAMETER rather than silently accepted:
store— usePOST /v1/ai/chatif you need stateless (no-content-storage) requests.- Any other non-Anthropic field.
store: false and get a 200 back, you might wrongly assume the content wasn’t stored.
Graduating to native features
Customers using/v1/messages can migrate endpoint-by-endpoint to /v1/ai/chat to gain:
store: falsefor stateless requests- PHI entity metadata in responses
- Run and conversation management
- Tool use (future phase)
Error codes
| Code | HTTP | Description |
|---|---|---|
INVALID_API_KEY | 401 | Missing or revoked token |
BAA_REQUIRED | 402 | No active BAA |
AI_CREDITS_EXHAUSTED | 402 | Credit allotment exhausted |
MISSING_SCOPE | 403 | Key lacks ai:chat scope |
PHI_BLOCKED | 403 | PHI detected and phi_mode=block is configured |
OPUS_NOT_ENABLED | 403 | Opus model not enabled for this org |
UNSUPPORTED_PARAMETER | 400 | Non-Anthropic parameter sent (e.g. store) |
RATE_LIMITED | 429 | RPM or daily limit exceeded |
INFERENCE_UPSTREAM_FAILURE | 502 | Upstream model provider error — retryable |