Skip to main content

Overview

TokenLab exposes multiple API formats so common coding tools, SDKs, and frameworks can integrate with minimal glue code. This page is intentionally narrower than a marketing matrix:
  • Supported means we document a concrete setup path and TokenLab exposes the protocol shape that path expects.
  • Strong native path means the repo also has direct adapter or request-format evidence for that protocol family.
  • Best-effort means the integration can work, but the upstream client does not treat this custom gateway workflow as a stable contract.
Unsupported fields are not handled uniformly. On compatibility routes, some fields are ignored or normalized. On /v1/responses, unsupported fields can return explicit 400 or 503 errors when that route cannot guarantee the requested behavior.

Supported API Formats

EndpointFormatUse Case
/v1/chat/completionsOpenAI ChatUniversal compatibility
/v1/responsesOpenAI ResponsesStateful conversations
/v1/messagesAnthropic MessagesClaude native features
/v1beta/models/:model:generateContentGoogle GeminiGemini native features

IDE & CLI Compatibility

Documented Tool Paths

ToolSupport LevelFormatNotes
CursorSupported with limitsOpenAI-compatibleWorks for BYOK standard chat/editor flows, not as a replacement for Cursor-managed features like Tab Completion
Claude Code CLIStrong native pathAnthropicNative /v1/messages route with adapter coverage for thinking and tool_choice
Codex CLISupported with model/path limitsOpenAI ResponsesTreat /v1/responses as an advanced path for Codex-specific workflows; some Responses-only fields are not guaranteed across every model and routed path
Gemini CLIBest-effort / experimentalGeminiCustom TokenLab base URL flow is not an official Gemini CLI integration
OpenCodeSupportedOpenAI-compatibleUse an OpenAI-compatible provider by default; move to a Responses-based provider only when you explicitly need it
OpenHandsSupportedOpenAI-compatibleUse the LiteLLM/OpenAI-compatible path with openai/<model> and TokenLab’s /v1 base URL
Other OpenAI-compatible editors and agent tools often work with the same base URL pattern; check the tool’s own custom-provider support before using it in production.

Configuration Examples

Base URL: https://api.tokenlab.sh/v1
API Key: sk-your-tokenlab-key
Cursor uses Anthropic-style tool format internally. TokenLab supports both:
  • OpenAI format: { type: "function", function: { name, parameters } }
  • Anthropic format: { name, input_schema } (no type field)

SDK Compatibility

Documented SDK & Framework Paths

SDK / FrameworkLanguageSupport LevelNotes
OpenAI SDKPython/JS/GoSupported core pathCompatibility path for /v1 Chat Completions and Embeddings; use native provider routes for provider-specific behavior, and do not assume Responses-only fields work across every model
Anthropic SDKPython/JSStrong native pathNative Messages route with direct evidence for tools, thinking, and prompt caching
Vercel AI SDKTypeScriptRecommended integration patternPrefer @ai-sdk/openai-compatible; use @ai-sdk/openai only when you explicitly want Responses-native behavior
LangChainPython/JSSupported standard surfacesChatOpenAI and OpenAIEmbeddings are the intended scope; vendor-native extras are out of scope
LlamaIndexPythonSupported via OpenAILikeUse OpenAILike, not the built-in OpenAI classes, for third-party gateways such as TokenLab
OpenAI Agents SDKPythonSupported chat-completions pathUse AsyncOpenAI(base_url="https://api.tokenlab.sh/v1") with OpenAIChatCompletionsModel; native Responses behavior depends on the selected model and route
AutoGenPythonSupported custom endpoint pathUse OpenAIChatCompletionClient with base_url: https://api.tokenlab.sh/v1
Semantic Kernel.NETSupported custom endpoint pathUse the OpenAI chat completion connector custom endpoint and point it at https://api.tokenlab.sh/v1
CrewAIPythonSupported custom endpoint pathSet OPENAI_API_BASE or LLM(base_url=...) to TokenLab’s /v1 endpoint
Pydantic AIPythonSupported OpenAI-compatible provider pathUse OpenAIChatModel with OpenAIProvider(base_url="https://api.tokenlab.sh/v1")
DSPyPythonSupported custom endpoint pathUse dspy.LM("openai/<model>", api_base="https://api.tokenlab.sh/v1")
LangflowPython / WebSupported with scope limitsUse the OpenAI component’s OpenAI API Base field with TokenLab’s /v1 endpoint
HaystackPythonSupported custom endpoint pathUse OpenAIChatGenerator(api_base_url="https://api.tokenlab.sh/v1")
GraphitiPythonSupported custom endpoint pathUse OpenAIGenericClient with TokenLab’s /v1 endpoint
Dify-Supported with scope limitsOpenAI provider and chat-completions-oriented flows are the intended path; not a fit for Codex-specific Responses or WebSocket behavior
FlowiseWeb / NodeSupported with scope limitsUse the TokenLab chat node when available, or a ChatOpenAI-compatible node pointed at https://api.tokenlab.sh/v1
Mem0PythonSupported custom endpoint pathKeep the OpenAI provider and set openai_base_url to TokenLab’s /v1 endpoint
AgnoPythonSupported pathUse the TokenLab model wrapper when available, or the OpenAI-compatible base URL path
Browser UsePythonSupported custom endpoint pathUse ChatOpenAILike with TokenLab’s /v1 endpoint
VoltAgentTypeScriptSupported custom endpoint pathPass an AI SDK OpenAI provider configured with baseURL: "https://api.tokenlab.sh/v1"
RagasPythonSupported custom endpoint pathPass AsyncOpenAI(base_url="https://api.tokenlab.sh/v1") into llm_factory
GuardrailsPythonSupported validation pathPass an OpenAI SDK chat completions callable configured with TokenLab’s /v1 endpoint
Prompt flowPython / CLISupported custom endpoint pathCreate an OpenAI connection with base_url=https://api.tokenlab.sh/v1
PromptfooCLI / NodeSupported pathUse OpenAI chat or Responses providers with apiBaseUrl: https://api.tokenlab.sh/v1
Portkey GatewayGatewaySupported pathUse TokenLab as an upstream provider for OpenAI-compatible chat and Responses traffic
HeliconeGateway / ObservabilitySupported observability pathRoute OpenAI-compatible requests through Helicone Gateway with Helicone-Target-Url: https://api.tokenlab.sh
LangfuseObservabilitySupported tracing pathConfigure the Langfuse OpenAI integration with TokenLab’s /v1 base URL
OpenLITObservabilitySupported tracing pathInstrument an OpenAI SDK client configured with TokenLab’s /v1 base URL
OpenLLMetryObservabilitySupported tracing pathUse OpenAI SDK instrumentation with TokenLab’s /v1 base URL
PhoenixObservabilitySupported tracing pathAuto-instrument the OpenAI SDK client configured with TokenLab’s /v1 base URL
OpikObservabilitySupported tracing pathWrap an OpenAI SDK client configured with TokenLab’s /v1 base URL
LangBotBot PlatformSupported chat pathUse the TokenLab requester when available, or configure an OpenAI-compatible requester with TokenLab’s /v1 endpoint
Open WebUIWeb ChatSupported chat-app pathAdd TokenLab as an OpenAI-compatible API connection and refresh the model list
Chatbox / DeepChat / Jan / LibreChat / Cherry StudioDesktop / WebSupported chat-app pathUse each app’s OpenAI-compatible custom provider flow; these apps are usually chat-completions oriented

Chat Completions Parameters

Core Parameters

ParameterTypeDescription
modelstringModel identifier (required)
messagesarrayConversation messages (required)
max_tokensintegerMaximum output tokens
temperaturenumberSampling temperature (0-2)
top_pnumberNucleus sampling (0-1)
streambooleanEnable streaming

Tool Calling

{
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get weather for a location",
        "parameters": {
          "type": "object",
          "properties": {
            "location": { "type": "string" }
          }
        },
        "strict": true
      }
    }
  ],
  "tool_choice": "auto",
  "parallel_tool_calls": true
}

Tool Choice Options

FormatExampleDescription
String"auto", "none", "required"Simple selection
OpenAI Object{ "type": "function", "function": { "name": "fn" } }Force specific function
Anthropic Object{ "type": "tool", "name": "fn", "disable_parallel_tool_use": true }Anthropic native format

Advanced Parameters

ParameterTypeDescription
stream_optionsobjectChat Completions only: { include_usage: true } for token counts
reasoning_effortstring"low", "medium", "high" for reasoning-enabled GPT-5 models
service_tierstring"auto" or "default"
seedintegerDeterministic outputs
logprobsbooleanReturn log probabilities
top_logprobsintegerNumber of top logprobs (0-20)
logit_biasobjectToken bias map (-100 to 100)
frequency_penaltynumberRepetition penalty (-2 to 2)
presence_penaltynumberTopic penalty (-2 to 2)
stopstring/arrayStop sequences
nintegerNumber of completions (1-128)
userstringUser identifier for tracking

OpenAI Advanced Features

ParameterTypeDescription
modalitiesarray["text", "audio"] for multimodal
audioobjectAudio output config (voice, format)
predictionobjectPredicted output for faster completion
metadataobjectKey-value pairs for tracking
storebooleanStore for later retrieval

Provider-Specific Options

{
  "anthropic_options": {
    "thinking": {
      "type": "enabled",
      "budget_tokens": 10000
    },
    "prompt_caching": true
  },
  "google_options": {
    "safety_settings": [...],
    "google_search": true,
    "code_execution": true
  }
}

Anthropic Messages Parameters

Core Parameters

ParameterTypeDescription
modelstringModel identifier
messagesarrayConversation messages
max_tokensintegerMaximum output (up to 128000)
systemstring/arraySystem prompt
streambooleanEnable streaming

Tool Calling

{
  "tools": [
    {
      "name": "get_weather",
      "description": "Get weather",
      "input_schema": {
        "type": "object",
        "properties": {
          "location": { "type": "string" }
        }
      }
    }
  ],
  "tool_choice": {
    "type": "auto",
    "disable_parallel_tool_use": false
  }
}

Extended Thinking

{
  "model": "claude-opus-4-6",
  "thinking": {
    "type": "enabled",
    "budget_tokens": 10000
  }
}

Responses API Parameters

Core Parameters

ParameterTypeDescription
modelstringModel identifier
inputstring/arrayInput content
instructionsstringSystem instructions
max_output_tokensintegerMaximum output tokens
previous_response_idstringContinue conversation

Advanced Parameters

ParameterTypeDescription
truncation_strategystring"auto" or "disabled"
includearray["reasoning.encrypted_content"]
reasoning_effortstringFor reasoning models
service_tierstringPriority tier

Tool Format

Supports both OpenAI and Anthropic tool formats:
// OpenAI format
{ "type": "function", "name": "fn", "parameters": {...} }

// Anthropic format (Cursor compatibility)
{ "name": "fn", "input_schema": {...} }

Gemini API Parameters

Core Parameters

ParameterTypeDescription
contentsarrayConversation content
systemInstructionobjectSystem prompt
generationConfigobjectGeneration settings

Tools

{
  "tools": [{
    "functionDeclarations": [{
      "name": "search",
      "description": "Search the web",
      "parameters": {...}
    }],
    "codeExecution": {},
    "googleSearch": {}
  }],
  "toolConfig": {
    "functionCallingConfig": {
      "mode": "AUTO"
    }
  }
}

Safety Settings

{
  "safetySettings": [
    {
      "category": "HARM_CATEGORY_HARASSMENT",
      "threshold": "BLOCK_MEDIUM_AND_ABOVE"
    }
  ]
}

Additional Parameters

ParameterTypeDescription
cachedContentstringCached content reference
responseMimeTypestring"text/plain" or "application/json"
responseSchemaobjectJSON schema for structured output

Streaming

Generation endpoints that expose stream: true, including Chat Completions and Responses, use Server-Sent Events (SSE):
# Chat Completions
curl https://api.tokenlab.sh/v1/chat/completions \
  -H "Authorization: Bearer sk-xxx" \
  -d '{"model": "gpt-4o", "messages": [...], "stream": true}'

# Chat Completions usage tracking
-d '{"...", "stream_options": {"include_usage": true}}'

Error Handling

TokenLab returns OpenAI-compatible error responses:
{
  "error": {
    "message": "Invalid API key",
    "type": "invalid_api_key",
    "code": "invalid_api_key"
  }
}
See Error Handling Guide for details.

Best Practices

Unknown parameters are forwarded only when the selected public route and model support them.
For Chat Completions streaming, enable stream_options.include_usage for accurate token counts. Responses has its own streaming contract and does not expose this Chat-only option.
Match your SDK’s expected format. TokenLab accepts both OpenAI and Anthropic formats.