Skip to main content

Overview

LiteLLM can use TokenLab in two ways:
  • use TokenLab as an OpenAI-compatible endpoint behind LiteLLM
  • use LiteLLM’s gateway when your team also needs its virtual keys, aliases, or logs
For Chat Completions, configure LiteLLM’s custom OpenAI / OpenAI-compatible client with https://api.tokenlab.sh/v1.
If your application needs Claude Messages or Gemini fields, use an integration that keeps that API format.

Install

Proxy Configuration

Create a litellm-config.yaml like this:
Start the proxy:

Call LiteLLM Through OpenAI SDK

Direct Python Usage

If you are using LiteLLM as a Python library instead of the proxy, keep the same TokenLab base URL:

Best Practices

Treat TokenLab as an OpenAI-compatible endpoint unless you have a very specific reason to build a more complex provider mapping.
LiteLLM makes sense when your own platform wants virtual keys, extra model-selection policy, or centralized logs in front of TokenLab.
OpenAI-compatible translation layers are great for broad compatibility, but they are not the right place to promise every provider-native feature.

Troubleshooting

  • Verify api_base is exactly https://api.tokenlab.sh/v1
  • Make sure LiteLLM can reach TokenLab over the public internet
  • If you run the proxy locally, verify the OpenAI client points to your LiteLLM port instead of TokenLab directly
  • Check that LiteLLM is reading the right OPENAI_API_KEY
  • Confirm the TokenLab key starts with sk-
  • Confirm the key is active in TokenLab dashboard
  • Verify the TokenLab model name in custom_openai/<model>
  • Keep your LiteLLM model_name alias separate from the real TokenLab model id