Anthropic format
The Messages API is served at its own base URL, for clients and SDKs built for Anthropic. The same key and balance work here and on the OpenAI format.
| Setting | Value |
|---|---|
| Base URL | https://api.mafiallm.com/anthropic |
| Messages | POST /v1/messages |
| Key | x-api-key: sk-mf-… or Authorization: Bearer sk-mf-… |
| Version header | Accepted and ignored |
| Streaming | Supported — SSE from message_start to message_stop |
Anthropic clients append /v1 themselves. Give them https://api.mafiallm.com/anthropic as it is, not …/anthropic/v1.
With the Anthropic SDK
import os
from anthropic import Anthropic
client = Anthropic(
base_url="https://api.mafiallm.com/anthropic",
api_key=os.environ["MAFIA_KEY"],
)
message = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
system="You are terse.",
messages=[{"role": "user", "content": "Explain a gateway in one line."}],
)
print(message.content[0].text)
With curl
curl https://api.mafiallm.com/anthropic/v1/messages \
-H "x-api-key: $MAFIA_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5",
"max_tokens": 1024,
"system": "You are terse.",
"messages": [{"role": "user", "content": "Explain a gateway in one line."}]
}'
The response uses the Anthropic message shape:
{
"id": "msg_…",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-5",
"content": [{ "type": "text", "text": "…" }],
"stop_reason": "end_turn",
"usage": { "input_tokens": 12, "output_tokens": 48 }
}
Supported fields
model,max_tokens,systemandmessages.- Message content as a string, or as an array of text and image blocks. Images may be base64 or URL sources.
tools,tool_choice, assistanttool_useblocks and usertool_resultblocks. Tool calls come back withstop_reason: "tool_use".stream: truereturns Anthropic SSE events, includingcontent_block_deltawithtext_deltaandinput_json_delta.temperature,top_pandstop_sequences.- Both
x-api-keyandAuthorization: Bearer.
Not supported yet
- Extended thinking blocks.
thinkingconfiguration is ignored and no thinking blocks are returned. - Prompt caching.
cache_controlmarkers are ignored; usage reports ordinary input tokens. - Token counting.
POST /v1/messages/count_tokensis not served.
Claude Code and other Anthropic-format clients work through this endpoint, including streaming and tool use. See Coding tools for setup per tool.