Call TeamoRouter from an SDK: Python, Node.js, LiteLLM, LangChain, Vercel AI SDK
One TeamoRouter API key lets the SDKs you already use call GPT, Claude, Gemini, DeepSeek and other models. Your code stays the same; only the base URL, key and model ID change. Every snippet below is the shortest code that runs. TeamoRouter also answers from servers where api.openai.com returns 403 unsupported_country_region_territory, for example in Russia.
Checked on 2026-11-08 with openai (Python 2.48, Node 7.53), anthropic (Python 0.125, Node 1.6), LiteLLM 1.83 and langchain-openai 0.3 / langchain-anthropic 0.3: requests reach TeamoRouter's /v1/chat/completions and /v1/messages.
Before you start
- Create an API key in the TeamoRouter console.
- Put it in an environment variable:
export TEAMOROUTER_API_KEY=sk-teamo-xxxxxx
| Format | Base URL | Use it for |
|---|---|---|
| OpenAI-compatible | https://api.teamorouter.com/v1 |
Every model (GPT, Claude, Gemini, DeepSeek and more) |
| Anthropic native | https://api.teamorouter.com (no /v1; the SDK adds /v1/messages) |
Claude, with prompt caching |
Model IDs are the IDs in the model list, with no vendor/ prefix.
Python: openai
pip install openai
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["TEAMOROUTER_API_KEY"],
base_url="https://api.teamorouter.com/v1",
)
resp = client.chat.completions.create(
model="gpt-6.1-sol",
messages=[{"role": "user", "content": "Introduce yourself in one sentence"}],
)
print(resp.choices[0].message.content)
- Keep
/v1at the end ofbase_url. - Add
stream=Truefor streaming, exactly as with OpenAI. client.responses.create(...)(the Responses API) serves GPT models only; usechat.completionsfor everything else.- In async code (FastAPI, bots) use
AsyncOpenAIthe same way.
Python: anthropic (Claude)
pip install anthropic
import os
from anthropic import Anthropic
client = Anthropic(
api_key=os.environ["TEAMOROUTER_API_KEY"],
base_url="https://api.teamorouter.com", # no /v1
)
resp = client.messages.create(
model="claude-sonnet-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Introduce yourself in one sentence"}],
)
print(resp.content[0].text)
Claude also works through the OpenAI format above, but only the Anthropic format gives you prompt caching (cache_control), thinking and other Claude-specific parameters.
Node.js: openai
npm install openai
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.TEAMOROUTER_API_KEY,
baseURL: "https://api.teamorouter.com/v1",
});
const resp = await client.chat.completions.create({
model: "gpt-6.1-sol",
messages: [{ role: "user", content: "Introduce yourself in one sentence" }],
});
console.log(resp.choices[0].message.content);
Node.js: @anthropic-ai/sdk (Claude)
npm install @anthropic-ai/sdk
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.TEAMOROUTER_API_KEY,
baseURL: "https://api.teamorouter.com", // no /v1
});
const resp = await client.messages.create({
model: "claude-sonnet-5-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Introduce yourself in one sentence" }],
});
console.log(resp.content[0].text);
LiteLLM
pip install litellm
Prefix the model with openai/ so LiteLLM sends an OpenAI-compatible request to your api_base:
import os
import litellm
resp = litellm.completion(
model="openai/gpt-6.1-sol",
api_base="https://api.teamorouter.com/v1",
api_key=os.environ["TEAMOROUTER_API_KEY"],
messages=[{"role": "user", "content": "Introduce yourself in one sentence"}],
)
print(resp.choices[0].message.content)
For Claude in the native Anthropic format, use the anthropic/ prefix and an api_base without /v1 (LiteLLM adds /v1/messages):
resp = litellm.completion(
model="anthropic/claude-sonnet-5-5",
api_base="https://api.teamorouter.com",
api_key=os.environ["TEAMOROUTER_API_KEY"],
messages=[{"role": "user", "content": "Introduce yourself in one sentence"}],
)
With the LiteLLM Proxy (gateway mode), add this to config.yaml:
model_list:
- model_name: gpt-6.1-sol
litellm_params:
model: openai/gpt-6.1-sol
api_base: https://api.teamorouter.com/v1
api_key: os.environ/TEAMOROUTER_API_KEY
- model_name: claude-sonnet-5-5
litellm_params:
model: anthropic/claude-sonnet-5-5
api_base: https://api.teamorouter.com
api_key: os.environ/TEAMOROUTER_API_KEY
LangChain
pip install langchain-openai langchain-anthropic
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-6.1-sol",
base_url="https://api.teamorouter.com/v1",
api_key=os.environ["TEAMOROUTER_API_KEY"],
)
print(llm.invoke("Introduce yourself in one sentence").content)
For Claude, use ChatAnthropic with a base_url without /v1:
from langchain_anthropic import ChatAnthropic
llm = ChatAnthropic(
model="claude-sonnet-5-5",
base_url="https://api.teamorouter.com",
api_key=os.environ["TEAMOROUTER_API_KEY"],
)
Vercel AI SDK
npm install ai @ai-sdk/openai-compatible
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";
const teamorouter = createOpenAICompatible({
name: "teamorouter",
baseURL: "https://api.teamorouter.com/v1",
apiKey: process.env.TEAMOROUTER_API_KEY,
});
const { text } = await generateText({
model: teamorouter("gpt-6.1-sol"),
prompt: "Introduce yourself in one sentence",
});
console.log(text);
Streaming, tool calling and Claude through @ai-sdk/anthropic: see Vercel AI SDK.
Common errors
| What you see | Cause | Fix |
|---|---|---|
| 401, API key incomplete | Key copied with missing characters | Copy the full sk-teamo- key again |
| 402 (400 on the OpenAI format), wallet balance is insufficient | Balance is $0 | Top up, from $5 |
| Redirect (301) or an HTML page instead of JSON | OpenAI-format base URL missing /v1 |
https://api.teamorouter.com/v1 |
404 route not found (Anthropic SDK, LiteLLM anthropic/, ChatAnthropic) |
/v1 added to the Anthropic-format URL |
https://api.teamorouter.com, without /v1 |
| 400 when calling a non-GPT model through the Responses API | The Responses API serves GPT only | Use chat.completions or the Anthropic SDK |
| Model not found | Wrong model ID, or a vendor/ prefix (LiteLLM's openai/ is fine) |
Use the ID from the model list |