Migrate from Anthropic
Move from the Anthropic API to FluxRouter by changing the base URL, key, and model. Nothing else changes.
FluxRouter speaks the Anthropic Messages API. If your code already calls Anthropic, you keep the same SDK and the same request shape. You change three things:
- Base URL to
https://api.fluxrouter.ai/anthropic - API key to your Flux key (
sk-...from the dashboard) - Model to
flux-auto(or a specificflux-*id)
The endpoint (/anthropic/v1/messages), the request and response JSON, streaming, and tool use all stay the same.
How auth works on the Anthropic endpoint
The Flux Anthropic endpoint accepts your key two ways:
- As
x-api-key: sk-...(the Anthropic SDK default), or - As
Authorization: Bearer sk-....
The Anthropic SDK sends x-api-key automatically when you set its API key, so you don't have to do anything special.
Get a Flux key
Sign up at /auth/sign-up, open the dashboard, and create an API key. It looks like sk-.... The examples below read it from a FLUX_API_KEY environment variable.
Migrate the Python SDK
Before (Anthropic)
from anthropic import Anthropic
client = Anthropic(
api_key="sk-ant-...",
)
message = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Say hello."}],
)
print(message.content[0].text)
After (FluxRouter)
from anthropic import Anthropic
client = Anthropic(
api_key="sk-...", # your Flux key (sent as x-api-key)
base_url="https://api.fluxrouter.ai/anthropic", # the one line you change
)
message = client.messages.create(
model="flux-auto", # let Flux route, or pin a flux-* id
max_tokens=1024,
messages=[{"role": "user", "content": "Say hello."}],
)
print(message.content[0].text)
Migrate the Node SDK
Before (Anthropic)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
const message = await client.messages.create({
model: "claude-sonnet-4-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Say hello." }],
});
console.log(message.content[0].text);
After (FluxRouter)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.FLUX_API_KEY, // your Flux key (sent as x-api-key)
baseURL: "https://api.fluxrouter.ai/anthropic", // the one line you change
});
const message = await client.messages.create({
model: "flux-auto", // let Flux route, or pin a flux-* id
max_tokens: 1024,
messages: [{ role: "user", content: "Say hello." }],
});
console.log(message.content[0].text);
What stays the same
Everything except the three values above:
- The Anthropic SDK and its method names (
messages.create). - The endpoint:
/anthropic/v1/messages. - The request and response JSON, including
max_tokens, system prompts, streaming, and tool use. - Your prompts, message arrays, and parameters.
What to do about the model field
Anthropic model ids like claude-sonnet-4-5 are not Flux models. Pick one of these instead:
flux-auto(recommended): Flux routes each request to a sensible model for the prompt.- A tier alias (
flux-fast,flux-standard,flux-reasoning,flux-image) or aflux-pinned-*id when you want the same backing model every time.
The authoritative list of model ids is GET https://api.fluxrouter.ai/v1/models. See Models.
Next steps
- Models: every model alias and how
flux-autoand pinning work. - Connect your tools: wire up Claude Code or another Anthropic-protocol tool.