Use TeamoRouter with the Vercel AI SDK
The Vercel AI SDK (ai package) talks to TeamoRouter through its OpenAI-compatible provider: set the base URL to TeamoRouter, pass your TeamoRouter API key, and use any model ID from our catalog. Your generateText, streamText and tool code stays the same. Claude models go through the native Anthropic provider instead (section 4).
New accounts start with a $0 balance — top up before your first request. Top up from $5. If a request returns 402 (400 on the OpenAI format) with "wallet balance is insufficient", your balance is empty — your base URL and key are fine. Top up and retry.
No international card? Top up with USDT: click Pay with crypto in the top-up dialog and pay with USDT, USDC or ETH from Binance, OKX or any exchange app — the checkout shows which networks your amount supports (BEP20 works from $5). No wallet extension needed (guide).
1. Install and configure
Create an API key in the TeamoRouter dashboard and put it in an environment variable:
npm install ai @ai-sdk/openai-compatible zod
export TEAMOROUTER_API_KEY=sk-teamo-...
Create the provider once and reuse it:
// teamorouter.ts
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
export const teamorouter = createOpenAICompatible({
name: 'teamorouter',
baseURL: 'https://api.teamorouter.com/v1',
apiKey: process.env.TEAMOROUTER_API_KEY,
includeUsage: true, // also return token usage when streaming
});
| Setting | Value |
|---|---|
| Base URL | https://api.teamorouter.com/v1 |
| API key | sk-teamo-..., sent as Authorization: Bearer |
| Model ID | The ID from our catalog, with no vendor/ prefix, e.g. deepseek-flash |
Model IDs you can use:
GPT9
gpt-6.1-solgpt-6-astragpt-6-solgpt-6-lunagpt-5.6-solgpt-5.6-terragpt-5.6-lunagpt-5.5gpt-5.4
Claude12
claude-opus-5-5claude-sonnet-5-5claude-haiku-5-5claude-fable-5-1claude-opus-5claude-fable-5claude-sonnet-5claude-opus-4-8claude-opus-4-7claude-opus-4-6claude-sonnet-4-6claude-haiku-4-5
Gemini5
gemini-3.8-flashgemini-3.7-flashgemini-3.6-flashgemini-3.5-flash-litegemini-3.1-pro-preview
DeepSeek6
deepseek-flashdeepseek-flash-freedeepseek-v4-flash-vision-expdeepseek-v4-prodeepseek-v4-flashdeepseek-v4-flash-free
GLM4
glm-5.3-flashglm-5.3-flash-freeglm-5.3glm-5.2
Grok1
grok-4.6
2. generateText and streamText
import { generateText, streamText } from 'ai';
import { teamorouter } from './teamorouter';
const { text, usage } = await generateText({
model: teamorouter('deepseek-flash'),
prompt: 'Explain what an API gateway does in one sentence.',
});
console.log(text, usage);
const result = streamText({
model: teamorouter('deepseek-flash'),
prompt: 'Write a haiku about latency.',
});
for await (const chunk of result.textStream) {
process.stdout.write(chunk);
}
3. Tool calling
import { generateText, tool, stepCountIs } from 'ai';
import { z } from 'zod';
import { teamorouter } from './teamorouter';
const { text } = await generateText({
model: teamorouter('deepseek-flash'),
tools: {
getWeather: tool({
description: 'Get the current temperature for a city',
inputSchema: z.object({ city: z.string() }),
execute: async ({ city }) => ({ city, temperatureC: 22 }),
}),
},
stopWhen: stepCountIs(3), // let the model call the tool, then answer
prompt: 'What is the weather in Shanghai right now?',
});
console.log(text);
4. Claude: use the Anthropic provider
Claude runs on the native Anthropic protocol. Use @ai-sdk/anthropic with TeamoRouter as the base URL; calling Claude through the OpenAI-compatible provider can lose prompt caching and thinking.
npm install @ai-sdk/anthropic
import { createAnthropic } from '@ai-sdk/anthropic';
import { generateText } from 'ai';
const anthropic = createAnthropic({
baseURL: 'https://api.teamorouter.com/v1', // requests go to /v1/messages
apiKey: process.env.TEAMOROUTER_API_KEY, // sent as x-api-key
});
const { text } = await generateText({
model: anthropic('claude-sonnet-5-5'),
prompt: 'Review this function for bugs: ...',
});
streamText, tools and the Anthropic-specific providerOptions (prompt caching, thinking) work the same way as with Anthropic's own endpoint. Use model IDs such as claude-opus-5-5, claude-sonnet-5-5 or claude-haiku-5-5.
GPT models can keep using the OpenAI-compatible provider above.
Errors you may see
| Status | Meaning | Fix |
|---|---|---|
| 401 | Missing or wrong API key | Check TEAMOROUTER_API_KEY and that the key starts with sk-teamo- |
| 402 (400 on the OpenAI format) with "wallet balance is insufficient" | Balance is $0 | Top up and retry |
400 model_not_available |
Model ID not in our catalog, or it has a vendor/ prefix |
Use an ID from the list above, without the prefix |
For the raw HTTP endpoints, streaming and caching details, see the API integration guide.