Frameworks & Platforms
LiteLLM
Connect LiteLLM to TokenLab
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
pip install 'litellm[proxy]'Proxy Configuration
Create a litellm-config.yaml like this:
model_list:
- model_name: tokenlab-gpt-5.4
litellm_params:
model: custom_openai/gpt-5.4
api_base: https://api.tokenlab.sh/v1
api_key: os.environ/OPENAI_API_KEY
- model_name: tokenlab-claude-sonnet
litellm_params:
model: custom_openai/claude-sonnet-4-6
api_base: https://api.tokenlab.sh/v1
api_key: os.environ/OPENAI_API_KEYStart the proxy:
export OPENAI_API_KEY="sk-your-tokenlab-key"
litellm --config litellm-config.yaml --port 4000Call LiteLLM Through OpenAI SDK
from openai import OpenAI
client = OpenAI(
api_key="anything",
base_url="http://127.0.0.1:4000"
)
response = client.chat.completions.create(
model="tokenlab-gpt-5.4",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)Direct Python Usage
If you are using LiteLLM as a Python library instead of the proxy, keep the same TokenLab base URL:
import litellm
response = litellm.completion(
model="custom_openai/gpt-5.4",
api_base="https://api.tokenlab.sh/v1",
api_key="sk-your-tokenlab-key",
messages=[{"role": "user", "content": "Summarize this repo."}]
)