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.

SettingValue
Base URLhttps://api.mafiallm.com/anthropic
MessagesPOST /v1/messages
Keyx-api-key: sk-mf-… or Authorization: Bearer sk-mf-…
Version headerAccepted and ignored
StreamingSupported — 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

Not supported yet

Claude Code and other Anthropic-format clients work through this endpoint, including streaming and tool use. See Coding tools for setup per tool.