Anthropic SDK
The official Anthropic libraries, with Claude and every other model.
The Anthropic SDKs speak the Messages format. Set the base URL to https://binference.io/api: the SDK adds /v1/messages itself.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://binference.io/api",
apiKey: process.env.BINF_API_KEY,
});
const message = await client.messages.create({
model: "anthropic/claude-sonnet-5.5",
max_tokens: 1024,
messages: [{ role: "user", content: "Explain gas fees to a new trader." }],
});
console.log(message.content);Good to know
- Model names: both
anthropic/claude-sonnet-5.5and Claude's own names likeclaude-sonnet-5-5work. - Any model: the Messages format works with non-Claude models too, such as
google/gemini-3.8-flash. - Cost: Messages answers carry token counts but no cost. Each call's charge is on your Calls page within a minute.
- Overloaded: a busy model answers
529 overloaded_error, which the SDK retries after the wait we name.