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:

bash
npm install ai @ai-sdk/openai-compatible zod
export TEAMOROUTER_API_KEY=sk-teamo-...

Create the provider once and reuse it:

ts
// 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:

ID model yang tersedia37 model

OpenAIGPT9

  • gpt-6.1-sol
  • gpt-6-astra
  • gpt-6-sol
  • gpt-6-luna
  • gpt-5.6-sol
  • gpt-5.6-terra
  • gpt-5.6-luna
  • gpt-5.5
  • gpt-5.4

ClaudeClaude12

  • claude-opus-5-5
  • claude-sonnet-5-5
  • claude-haiku-5-5
  • claude-fable-5-1
  • claude-opus-5
  • claude-fable-5
  • claude-sonnet-5
  • claude-opus-4-8
  • claude-opus-4-7
  • claude-opus-4-6
  • claude-sonnet-4-6
  • claude-haiku-4-5

GeminiGemini5

  • gemini-3.8-flash
  • gemini-3.7-flash
  • gemini-3.6-flash
  • gemini-3.5-flash-lite
  • gemini-3.1-pro-preview

DeepSeekDeepSeek6

  • deepseek-flash
  • deepseek-flash-free
  • deepseek-v4-flash-vision-exp
  • deepseek-v4-pro
  • deepseek-v4-flash
  • deepseek-v4-flash-free

ZhipuGLM4

  • glm-5.3-flash
  • glm-5.3-flash-free
  • glm-5.3
  • glm-5.2

GrokGrok1

  • grok-4.6

2. generateText and streamText

ts
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

ts
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.

bash
npm install @ai-sdk/anthropic
ts
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.

Siap? Tiga langkah untuk memulaiMasuk ke konsol · isi saldo · buat API key
DiscordDapatkan bantuan komunitas secara instan