Use this compatibility route for existing OpenAI SDK integrations and portable chat or embedding flows. For Claude or Gemini native behavior, use the Anthropic or Gemini format below.
from openai import OpenAIclient = OpenAI( api_key="sk-your-tokenlab-key", base_url="https://api.tokenlab.sh/v1")# Portable chat works across many modelsresponse = client.chat.completions.create( model="claude-sonnet-4-6", # Claude via OpenAI format messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ])
Native Anthropic Messages API. Required for Claude-specific features like extended thinking.
from anthropic import Anthropicclient = Anthropic( api_key="sk-your-tokenlab-key", base_url="https://api.tokenlab.sh" # No /v1 suffix!)message = client.messages.create( model="claude-sonnet-4-6", max_tokens=1024, system="You are a helpful assistant.", # Separate system field messages=[ {"role": "user", "content": "Hello!"} ])
Gemini Files and Cache:/upload/v1beta/files, /v1beta/files, /v1beta/files:register, and /v1beta/cachedContents are available on the native Gemini route. Files use Gemini File API-compatible upstream channels; explicit cache resources can also route through Vertex AI channels. Resources created through TokenLab are bound to the same upstream channel/key for later generateContent calls.
Function tools can be converted between formats when the target route supports them. Provider-native tools must stay on their native route:
OpenAI Responses hosted and native tools such as tool_search, web_search, file_search, code_interpreter, MCP, shell/apply_patch, and computer-use tools require /v1/responses.
Anthropic server/native tools such as web_search_*, web_fetch_*, code_execution_*, tool_search_*, bash, computer-use, and text-editor tools require /v1/messages.
Gemini built-in tools such as googleSearch, codeExecution, urlContext, computerUse, and similar tools fields require /v1beta.
If TokenLab cannot route a request with native tools to a native-capable upstream path, it returns an explicit unsupported-field error instead of dropping the tool or pretending it is a Chat Completions function. User-defined function tools remain the portable path.
# Before (OpenAI)client = OpenAI(api_key="sk-openai-key")# After (TokenLab)client = OpenAI( api_key="sk-tokenlab-key", base_url="https://api.tokenlab.sh/v1" # Add this line)# That's it! Same code works
# Before (Anthropic)client = Anthropic(api_key="sk-ant-key")# After (TokenLab)client = Anthropic( api_key="sk-tokenlab-key", base_url="https://api.tokenlab.sh" # Add this line (no /v1!))