Skip to main content
Meliai exposes a fully Anthropic-compatible endpoint at /v1/messages, accepting the exact request shape and returning the exact response shape that the Anthropic SDK expects. You migrate by setting two environment variables — ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL — and your existing code continues to run without modification. Claude model names such as claude-sonnet-4 are mapped automatically to open-weight equivalents served from EU infrastructure.
1

Get a Meliai API key

Create a key at meliai.ai/account/api/keys. Your key will have the format sk-mel-<KEY>.
Keep your existing ANTHROPIC_API_KEY value if any other services in your stack still call Anthropic directly. You can hold both variables in your environment simultaneously.
2

Set your environment variables

Override the two values the Anthropic SDK reads to locate the API:
The SDK picks these up automatically — no code changes needed at this stage. ANTHROPIC_BASE_URL must point to the root URL (without a /v1 suffix); the SDK appends the path itself.
3

Run your existing code

Your Anthropic SDK calls work unchanged. Here’s a minimal example to confirm the connection:
Streaming, tool use, vision inputs, and system prompts all work through the same /v1/messages endpoint with no modifications to your feature-specific code.
4

Understand model name mapping

Meliai does not serve Anthropic’s proprietary Claude weights. Instead, when you pass a Claude model name, Meliai maps it to the closest open-weight equivalent available on EU infrastructure. For example:You can also supply a Meliai-native model ID directly — browse the full mapping at meliai.ai/hub or retrieve it programmatically:
The Anthropic SDK’s beta.messages.create interface (used for extended thinking, prompt caching, and other beta features) targets the same /v1/messages endpoint on Meliai. Pass the corresponding betas header values as you normally would; Meliai forwards them to the underlying model where supported.
Meliai also exposes POST /v1/messages/count_tokens, the Anthropic-compatible token-count preflight endpoint. Call it before a full completion to estimate token usage and cost without incurring inference charges.

What changes and what stays the same