Skip to main content

Messages API (Anthropic-compatible)

POST https://gateway.primex.work/v1/messages

The Anthropic Messages API format — used by the Anthropic SDK, Claude Code, and Cline. Note the base URL has no /v1 prefix on its own; the SDK appends /v1/messages.

Request

curl https://gateway.primex.work/v1/messages \
-H "x-api-key: prx-YOUR_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 512,
"messages": [{"role": "user", "content": "Hello, Claude via Primex."}]
}'

Supported models

Any enabled Anthropic model in the catalogue — claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5, claude-fable-5.

note

Claude Code and the Anthropic format are Claude-only. To use GPT / Grok / DeepSeek etc., use the OpenAI-compatible endpoint with Cursor, Windsurf, Codex, or the OpenAI SDK.

Token counting

POST /v1/messages/count_tokens is supported for pre-flighting request sizes, mirroring the Anthropic API.

Response

{
"id": "msg_…",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-4-6",
"content": [{"type": "text", "text": "Hello! …"}],
"usage": {"input_tokens": 12, "output_tokens": 9}
}

See Client Setup → Claude Code for the CLI workflow.