Skip to main content
Keep the request format your application already uses. OpenAI-compatible clients, Anthropic Messages, Gemini REST, and media endpoints each have a matching TokenLab API address.

API mapping

Quick Migration Recipes

OpenAI to TokenLab

Change the SDK base_url / baseURL to https://api.tokenlab.sh/v1, replace the API key, and choose a model ID from GET /v1/models.

OpenRouter to TokenLab

Replace the OpenRouter base URL with https://api.tokenlab.sh/v1. TokenLab model IDs do not include an OpenRouter provider prefix. Use Anthropic Messages or Gemini only when your application needs fields from those formats.

LiteLLM to TokenLab

Use LiteLLM’s custom_openai/<model> configuration with api_base: https://api.tokenlab.sh/v1. Keep your LiteLLM alias separate from the TokenLab model ID so either can change without editing application prompts.

Claude Messages via TokenLab

Point Anthropic SDK clients at https://api.tokenlab.sh and call messages.create. Do not append /v1 to the SDK base URL; the SDK owns the /v1/messages path.

Gemini Native via TokenLab

Keep Gemini payloads on https://api.tokenlab.sh/v1beta/models/{model}:generateContent. Gemini-native contents, parts, files, cached contents, function declarations, and built-in tools should stay on this route when your app depends on Gemini behavior.

OpenAI-Compatible Migration

Your existing retry, timeout, and streaming code can usually stay. Confirm the model ID with GET /v1/models. Image requests must include a model explicitly; see the image guide for model-specific inputs.

Anthropic Migration

Use /v1/messages for Claude tool calls, thinking blocks, and Anthropic message fields. Chat Completions does not guarantee those fields.

Gemini Migration

Keep Gemini built-in tools, File API references, cached contents, function declarations, and native content parts on /v1beta when your app depends on Gemini-native behavior.

Media Migration

  1. Query GET /v1/models?recommended_for=image|video|music|3d.
  2. Read GET /v1/models in list responses and the full GET /v1/models/{model} where available.
  3. Send an explicit model, especially for image endpoints.
  4. Store task_id, poll_url, endpoint, model, and your own job ID for async jobs.
  5. Reconcile costs through usage records and billing_transaction_id, not provider task IDs.
Media generation can finish asynchronously, so save task_id and poll_url before replacing an existing integration. A create-request timeout must not produce a second user job.

Migration Pitfalls

  • Do not put every model behind one OpenAI Chat Completions path if your app needs native Anthropic, Gemini, or Responses behavior.
  • Do not assume old image defaults. Send model explicitly.
  • Do not retry async create requests without checking whether a task was already created.
  • Use TokenLab task IDs and usage records in your product. Third-party task IDs are not billing identifiers.

API Reference