Anthropic SDK
The official Anthropic SDKs, pointed at the RFS Router. Every model works, not only Claude.
The Anthropic SDKs speak the Messages format, which the RFS Router serves for every model. Their base URL has no /v1: they add it themselves.
npm i @anthropic-ai/sdkimport Anthropic from "@anthropic-ai/sdk";
const ai = new Anthropic({
baseURL: "https://relayfor.si/api",
apiKey: process.env.RELAYFOR_ROUTER_KEY,
});
const message = await ai.messages.create({
model: "anthropic/claude-sonnet-5.5",
max_tokens: 1024,
system: "You run the $NOVA community. Be brief.",
messages: [{ role: "user", content: "Welcome the 1,000th holder in one line." }],
});
console.log(message.content);Model names
Any id from Models works, such as openai/gpt-6.1-sol or google/gemini-3.8-flash. Claude's own names work too: claude-sonnet-5-5 and dated names like claude-haiku-4-5-20251001 map to the listed model.
Streaming
const stream = ai.messages.stream({
model: "anthropic/claude-sonnet-5.5",
max_tokens: 1024,
messages: [{ role: "user", content: "Draft today's update for holders." }],
});
stream.on("text", (text) => process.stdout.write(text));
const final = await stream.finalMessage();Extended thinking
const message = await ai.messages.create({
model: "anthropic/claude-sonnet-5.5",
max_tokens: 4096,
thinking: { type: "enabled", budget_tokens: 2048 },
messages: [{ role: "user", content: "Which of our three launch ideas is safest, and why?" }],
});Thinking is billed as output. See Reasoning.
What it cost
Messages answers carry no cost: each call's charge is in the account's ledger within a minute, under call: and the answer's x-relayfor-call-id header. A busy model answers 529 overloaded_error, which the SDK retries.