TeamoRouter API Integration Guide

TeamoRouter supports multiple compatible API formats, including OpenAI, Google Gemini, and Anthropic. Point the official SDK base URL to TeamoRouter and keep your application code unchanged. You can call Claude / Gemini / GPT and other model families through one gateway.

  • Base URL: https://api.teamorouter.com
  • Authentication: API Key (sk-teamo-...)
  • Protocols: Anthropic native format (/v1/messages), OpenAI-compatible format (/v1/chat/completions), OpenAI Responses API (/v1/responses, GPT models only), Gemini native format (/v1beta/models/{model}:generateContent), and image generation (/v1/images)

Replace sk-teamo-xxxxxx with your own key. Keep the key private and never commit it to a code repository.


1. Authentication

Choose the compatible format according to the model you use:

Different formats use different authentication headers. Choose the header according to the protocol:

Protocol Header
Anthropic x-api-key: sk-teamo-xxxxxx + anthropic-version: 2023-06-01
OpenAI Authorization: Bearer sk-teamo-xxxxxx
Gemini Authorization: Bearer sk-teamo-xxxxxx

2. Available models

Fetch the complete model list in real time with GET /v1/models:

bash
curl https://api.teamorouter.com/v1/models \
  -H "Authorization: Bearer sk-teamo-xxxxxx"

Currently available models (examples):

Provider Model ID
Anthropic claude-fable-5, claude-opus-5, claude-sonnet-5, claude-opus-4-8, claude-opus-4-7, claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5
OpenAI gpt-5.6-sol,gpt-5.6-terra,gpt-5.6-luna,gpt-5.5,gpt-5.4,gpt-5.4-mini,gpt-image-2
Google gemini-3.6-flash, gemini-3.5-flash-lite,gemini-3.1-pro-preview, gemini-3.5-flash, gemini-3.1-flash-lite-preview

3. Anthropic native format /v1/messages

3.1 Basic request

bash
curl https://api.teamorouter.com/v1/messages \
  -H "x-api-key: sk-teamo-xxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-fable-5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Introduce yourself in one sentence"}
    ]
  }'

Example response:

json
{
  "id": "msg_01KxDE...",
  "type": "message",
  "role": "assistant",
  "model": "claude-fable-5",
  "content": [{"type": "text", "text": "I am Claude..."}],
  "stop_reason": "end_turn",
  "usage": {"input_tokens": 159, "output_tokens": 34}
}

3.2 Streaming with SSE

Add "stream": true. The response is text/event-stream:

bash
curl https://api.teamorouter.com/v1/messages \
  -H "x-api-key: sk-teamo-xxxxxx" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-fable-5",
    "max_tokens": 1024,
    "stream": true,
    "messages": [{"role": "user", "content": "Write a short poem"}]
  }'

Event sequence: message_start -> content_block_start -> multiple content_block_delta events -> content_block_stop -> message_delta -> message_stop.

3.3 Python SDK with anthropic

python
from anthropic import Anthropic

client = Anthropic(
    api_key="sk-teamo-xxxxxx",
    base_url="https://api.teamorouter.com",
)

resp = client.messages.create(
    model="claude-fable-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.content[0].text)

4. OpenAI-compatible format /v1/chat/completions and /v1/responses

4.1 Basic Chat Completions request

bash
curl https://api.teamorouter.com/v1/chat/completions \
  -H "Authorization: Bearer sk-teamo-xxxxxx" \
  -H "content-type: application/json" \
  -d '{
    "model": "gpt-5.6-sol",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

The response follows the standard OpenAI chat.completion structure:

json
{
  "object": "chat.completion",
  "model": "gpt-5.6-sol",
  "choices": [
    {"index": 0, "message": {"role": "assistant", "content": "Hello!"}, "finish_reason": "stop"}
  ],
  "usage": {"prompt_tokens": 214, "completion_tokens": 3, "total_tokens": 217}
}

4.2 Python SDK with openai

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-teamo-xxxxxx",
    base_url="https://api.teamorouter.com/v1",
)

resp = client.chat.completions.create(
    model="gpt-5.6-sol",
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)

4.3 Streaming

Add "stream": true. TeamoRouter returns standard OpenAI SSE chunks in the data: {...} format and ends with data: [DONE].

4.4 Basic Responses API request

If your application already uses the OpenAI Responses API, call /v1/responses directly:

bash
curl https://api.teamorouter.com/v1/responses \
  -H "Authorization: Bearer sk-teamo-xxxxxx" \
  -H "content-type: application/json" \
  -d '{
    "model": "gpt-5.6-sol",
    "input": "Introduce TeamoRouter in one sentence"
  }'

/v1/responses only supports GPT models. Requests for Claude / Gemini return 400. Use /v1/messages for Claude and the Gemini native format for Gemini.

4.5 Python SDK with openai Responses

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-teamo-xxxxxx",
    base_url="https://api.teamorouter.com/v1",
)

resp = client.responses.create(
    model="gpt-5.6-sol",
    input="Introduce TeamoRouter in one sentence",
)
print(resp.output_text)

4.6 Responses API streaming

Add "stream": true to receive standard OpenAI Responses API streaming events.


5. Gemini native format /v1beta/models/{model}:generateContent

5.1 Basic request

bash
curl https://api.teamorouter.com/v1beta/models/gemini-3.5-flash:generateContent \
  -H "Authorization: Bearer sk-teamo-xxxxxx" \
  -H "content-type: application/json" \
  -d '{
    "contents": [
      {"role": "user", "parts": [{"text": "Introduce yourself in one sentence"}]}
    ]
  }'

Example response:

json
{
  "candidates": [
    {
      "content": {"role": "model", "parts": [{"text": "I am Gemini..."}]},
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {"promptTokenCount": 12, "candidatesTokenCount": 22, "totalTokenCount": 34}
}

5.2 Streaming with SSE

Use streamGenerateContent and add alt=sse:

bash
curl "https://api.teamorouter.com/v1beta/models/gemini-3.5-flash:streamGenerateContent?alt=sse" \
  -H "Authorization: Bearer sk-teamo-xxxxxx" \
  -H "content-type: application/json" \
  -d '{
    "contents": [
      {"role": "user", "parts": [{"text": "Write a short poem"}]}
    ]
  }'

5.3 Environment variables

If your tool or SDK supports a custom Gemini Base URL, configure it like this:

bash
export GOOGLE_GEMINI_BASE_URL="https://api.teamorouter.com"
export GEMINI_API_KEY="sk-teamo-xxxxxx"
export GEMINI_API_KEY_AUTH_MECHANISM="bearer"

Different Gemini SDKs may use different field names for custom endpoints. Common names include base_url, baseURL, apiEndpoint, or environment variables. The core rule is: point the Base URL to https://api.teamorouter.com and use your TeamoRouter API Key.


6. Image generation /v1/images

The image model gpt-image-2 uses a separate image endpoint and authenticates with Authorization: Bearer.

6.1 Generate images POST /v1/images/generations

bash
curl https://api.teamorouter.com/v1/images/generations \
  -H "Authorization: Bearer sk-teamo-xxxxxx" \
  -H "content-type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "An orange cat typing on a keyboard, illustration style"
  }'

Example response. data[0].b64_json is the Base64-encoded image:

json
{
  "created": 1752345600,
  "data": [
    {"b64_json": "iVBORw0KGgo..."}
  ]
}

Set the timeout to 300 seconds. Image generation models can take longer to respond, and shorter timeouts may fail.

6.2 Edit images POST /v1/images/edits

Upload the source image as multipart/form-data and provide an edit instruction:

bash
curl https://api.teamorouter.com/v1/images/edits \
  -H "Authorization: Bearer sk-teamo-xxxxxx" \
  -F model="gpt-image-2" \
  -F image="@photo.png" \
  -F prompt="Replace the background with a starry sky"

This endpoint is compatible with the OpenAI Images API.


7. Connect Claude Code / Codex / Gemini CLI and other agent tools

Claude Code uses the Anthropic protocol, Codex uses the OpenAI protocol, and Gemini CLI uses the Gemini protocol.

Just point the Base URL and API Key environment variables to TeamoRouter. You do not need to modify the tools themselves.

Claude Code (Anthropic protocol):

bash
export ANTHROPIC_BASE_URL="https://api.teamorouter.com"
export ANTHROPIC_API_KEY="sk-teamo-xxxxxx"

OpenAI protocol tools (Chat Completions / Responses API):

bash
export OPENAI_BASE_URL="https://api.teamorouter.com/v1"
export OPENAI_API_KEY="sk-teamo-xxxxxx"

Gemini CLI:

bash
export GOOGLE_GEMINI_BASE_URL="https://api.teamorouter.com"
export GEMINI_API_KEY="sk-teamo-xxxxxx"
export GEMINI_API_KEY_AUTH_MECHANISM="bearer"

8. FAQ

Getting 401 / authentication failed?

First verify the protocol-to-header mapping: Anthropic uses x-api-key; OpenAI / Gemini use Authorization: Bearer; Gemini native endpoints also accept x-goog-api-key. Then confirm the key is complete, starts with sk-teamo-, has no extra spaces, and has not been deleted in the dashboard. Also check the base_url format: OpenAI SDKs need /v1; Anthropic SDKs do not.

Calling Claude through the OpenAI format returns errors, costs more, or performs worse?

Use the Anthropic native protocol (/v1/messages) for Claude models whenever possible. Claude Code and other agent tools must be configured with the Anthropic protocol. Calling Claude through the OpenAI-compatible format can lose prompt cache, thinking, and other capabilities, increasing cost and reducing quality. It is only suitable for simple chat scenarios. /v1/responses does not support Claude / Gemini and returns 400.

Model unavailable?

Use GET /v1/models to fetch the real-time model list first. Check the model ID spelling, use lowercase, and pay attention to - versus .. Also confirm the endpoint matches the model.

Timeout or slow first token?

Large models such as Opus / Fable can take several seconds to tens of seconds for the first token during reasoning. This does not mean the request failed. In production, set "stream": true for better perceived latency and increase the client read timeout. The server supports responses up to 600 seconds.

Key security:

Store keys in environment variables or a secret manager. Do not hardcode them, commit them to Git, or bundle them into a frontend / public client. If you suspect a key has leaked, delete it in the dashboard immediately and create a replacement.

Ready? Three steps to startLog in to the console · top up · create an API key
DiscordGet community help instantly
TeamoRouter API Integration Guide · Docs