ANTHROPIC COMPATIBLE
Connect with the Anthropic SDK
Keep the official Anthropic SDK and point the Base URL and API key to LLMRouter to call the Messages-compatible endpoint.
Configure the endpoint and key
export ANTHROPIC_BASE_URL=https://api.llmrouter.pro/anthropic
export ANTHROPIC_API_KEY=sk-lr-your-keyChoose your development language
Official SDK examples for JavaScript, Python, Go, Java, C#, Ruby and PHP.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
const message = await client.messages.create({
model: "your-model",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});
const firstBlock = message.content[0];
if (firstBlock?.type === "text") {
console.log(firstBlock.text);
}Available endpoints
POST /anthropic/v1/messages
Claude Code
Compatibility depends on the target Claude Code version. Before production use, confirm that the model supports tool calls, streaming and compatible error responses.