Anthropic Messages API
The Anthropic-compatible API lets Claude Code and the Anthropic SDKs connect without code changes, and it serves any text model in the catalog, not just Claude.
Connecting
- Set the base URL to
https://modelportal.aiwithout/v1; the SDK buildshttps://modelportal.ai/v1/messagesitself. - Send the key in the
x-api-keyheader, or asAuthorization: Bearer. - The old addresses under
/anthropic/*are retired and return 410 with a message pointing to the new path.
import anthropic
client = anthropic.Anthropic(base_url="https://modelportal.ai", api_key="YOUR_API_KEY")
message = client.messages.create(
model="MODEL_ID",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(message.content[0].text)
Differences from the OpenAI format
max_tokensis required.thinking, tool use andcache_controlare supported according to each endpoint's declared capabilities; see Reasoning, Tool calling and Prompt caching.- Signed thinking blocks sent back during multi-turn tool use pin later requests to the endpoint that produced the signature.
- Pass routing preferences in the
X-ModelPortal-Provider-Preferencesheader; see Provider selection.metadata.user_idserves as the session identifier for session affinity and is removed before forwarding. - Error bodies are
{"type": "error", "error": {"type", "message"}}with no machine-readable code; thex-should-retryresponse header tells you whether a retry is worthwhile.
Endpoints and fields are in the Anthropic-compatible API reference.