Anthropic SDK
Use the Anthropic Python or Node SDK with FluxRouter by setting the base URL to the Anthropic endpoint.
The official Anthropic SDKs let you override the base URL, so pointing them at FluxRouter is a one-line change. Set the base URL to https://api.fluxrouter.ai/anthropic and pass your Flux key. Everything else stays the same.
One-click: if you also run Claude Code or other Anthropic tools, Flux Desktop configures the ones it detects for you. The SDK snippets below are for your own code.
Python
import os
from anthropic import Anthropic
client = Anthropic(
base_url="https://api.fluxrouter.ai/anthropic",
api_key=os.environ["FLUX_API_KEY"], # your sk-... key
)
msg = client.messages.create(
model="flux-auto",
max_tokens=1024,
messages=[{"role": "user", "content": "hi"}],
)
print(msg.content)
You can also set the base URL via the ANTHROPIC_BASE_URL environment variable instead of passing base_url.
Node
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://api.fluxrouter.ai/anthropic",
apiKey: process.env.FLUX_API_KEY, // your sk-... key
});
const msg = await client.messages.create({
model: "flux-auto",
max_tokens: 1024,
messages: [{ role: "user", content: "hi" }],
});
console.log(msg.content);
Note the casing: Node uses baseURL, Python uses base_url.
Test it
Run the snippet, or hit the endpoint directly:
curl https://api.fluxrouter.ai/anthropic/v1/messages \
-H "x-api-key: sk-YOUR-FLUX-KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"flux-auto","max_tokens":1024,"messages":[{"role":"user","content":"hi"}]}'