Use Any Claude-Compatible SDK or Framework with MonoRouter

MonoRouter is a drop-in replacement for the Anthropic API. Use it with the Claude SDK, LangChain, LangGraph, Claude Code, or any tool that speaks the Messages API.

MonoRouter exposes a fully Anthropic-compatible API at api.monorouter.dev. Any tool, SDK, or framework that can talk to the Anthropic Messages API works with MonoRouter out of the box — change the base URL, swap in your MonoRouter API key, and everything else stays the same. Streaming, tool use, vision, caching, extended thinking — it all works.

This guide shows you how to set up the most popular tools and frameworks. If your tool isn't listed here, the pattern is always the same: find the "base URL" or "API endpoint" setting, point it at https://api.monorouter.dev, and use your MonoRouter key.

Anthropic Python SDK

pip install anthropic
from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.monorouter.dev",
    api_key="mrk_your_monorouter_key_here",
)

message = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello, Claude!"}],
)
print(message.content[0].text)

That's the entire change — base_url is the only difference from a normal Anthropic setup. Streaming, tool use, system prompts, multi-turn conversations, and vision all work identically. You can drop this into an existing project by setting ANTHROPIC_BASE_URL in your environment without touching any business logic.

Anthropic TypeScript SDK

npm install @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://api.monorouter.dev",
  apiKey: "mrk_your_monorouter_key_here",
});

const message = await client.messages.create({
  model: "claude-opus-4-8",
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello, Claude!" }],
});
console.log(message.content[0].text);

Note the casing: Python uses base_url, TypeScript uses baseURL. Both accept the same MonoRouter endpoint.

LangChain

LangChain's ChatAnthropic class accepts a base URL parameter, so MonoRouter plugs right in:

from langchain_anthropic import ChatAnthropic

llm = ChatAnthropic(
    model="claude-sonnet-4-5-20250514",
    anthropic_api_url="https://api.monorouter.dev",
    anthropic_api_key="mrk_your_monorouter_key_here",
)

response = llm.invoke("Explain quantum entanglement in plain English.")
print(response.content)

This works with LangChain's full ecosystem — chains, output parsers, structured output, retrieval-augmented generation. MonoRouter returns standard Anthropic responses, so LangChain never knows the difference.

LangGraph

LangGraph agents use the same ChatAnthropic model under the hood:

from langchain_anthropic import ChatAnthropic
from langgraph.prebuilt import create_react_agent

llm = ChatAnthropic(
    model="claude-sonnet-4-5-20250514",
    anthropic_api_url="https://api.monorouter.dev",
    anthropic_api_key="mrk_your_monorouter_key_here",
)

agent = create_react_agent(llm, tools=[...])
result = agent.invoke({"messages": [("user", "Find flights from SF to NYC")]})

Multi-step agentic workflows, tool calling, and human-in-the-loop flows all work as expected. MonoRouter handles the underlying API calls transparently.

Claude Code CLI

Set two environment variables before launching:

export ANTHROPIC_BASE_URL="https://api.monorouter.dev"
export ANTHROPIC_API_KEY="mrk_your_monorouter_key_here"
claude

To make this permanent, add both lines to your ~/.zshrc or ~/.bashrc:

# ~/.zshrc or ~/.bashrc
export ANTHROPIC_BASE_URL="https://api.monorouter.dev"
export ANTHROPIC_API_KEY="mrk_your_monorouter_key_here"

Every claude invocation — agentic tasks, project sessions, slash commands — routes through MonoRouter automatically.

Cursor, Cline, and Other IDE Tools

Most AI coding assistants let you configure a custom Anthropic endpoint:

Cursor: Go to Settings → Models → Anthropic. Set the API base to https://api.monorouter.dev and paste your MonoRouter key.

Cline: Open the extension settings. Set the provider to Anthropic, the base URL to https://api.monorouter.dev, and use your MonoRouter key.

The same pattern applies to any tool that supports a custom Anthropic endpoint — Aider, Continue, Zed, and others.

What Makes MonoRouter Different

MonoRouter isn't just a passthrough proxy. Here's what you get on top of Anthropic API compatibility:

Auto-switch and load balancing. Connect multiple provider tokens to your account. MonoRouter automatically rotates requests across them in round-robin fashion. If one token hits a rate limit, it's automatically cooled down and traffic shifts to the next available token — no errors, no manual intervention.

Token cooldown and failover. When a provider token is rate-limited or temporarily unavailable, MonoRouter parks it and routes through your other tokens. The calling application never sees an error. When the token recovers, it re-enters the rotation.

Usage tracking. Every API call is logged with model, token counts, cost estimates, and latency. Your MonoRouter dashboard shows exactly how your usage breaks down — no more guessing what that agent run cost.

All models supported. Claude Opus 4.8, Opus 4.7, Sonnet 4.5, Fable 5, Haiku — every model available through the Anthropic API works through MonoRouter.

Server and Production Deployment

MonoRouter works anywhere that makes outbound HTTPS requests — production servers, background workers, CI pipelines, cloud functions:

docker run \
  -e ANTHROPIC_BASE_URL="https://api.monorouter.dev" \
  -e ANTHROPIC_API_KEY="mrk_your_monorouter_key_here" \
  your-image:latest

For multi-region deployments, inject the env vars through your secrets manager (AWS Secrets Manager, GCP Secret Manager, Vault) the same way you would any other API credential.

Getting Started

Sign up at monorouter.dev/signup — anonymous, no email required. The full setup guide including rate limits, supported models, and key management is at monorouter.dev/guide.