Frameworks & Plattformen

LiteLLM

LiteLLM mit TokenLab als OpenAI-kompatiblen Endpunkt oder Teil Ihres Team-Gateways verwenden

Überblick

LiteLLM und TokenLab lassen sich meist auf zwei Arten kombinieren.

  • TokenLab als OpenAI-kompatiblen Endpunkt hinter LiteLLM verwenden
  • LiteLLM vor TokenLab setzen, um virtuelle Keys, Modellauswahlrichtlinien oder zentrale Observability abzubilden

Für TokenLab ist der sauberste Standardpfad die Nutzung des custom OpenAI / OpenAI-kompatiblen-Pfads von LiteLLM mit api_base = https://api.tokenlab.sh/v1.

Wenn Sie explizit Claude-native oder Gemini-native Request-Shapes benötigen, bevorzugen Sie die nativen TokenLab-Integrationen, statt diese Abläufe durch LiteLLMs OpenAI-kompatible Abstraktion zu zwingen.

Typ: Framework oder Plattform

Primärer Pfad: OpenAI-kompatibler Endpunkt

Support-Niveau: Unterstützter Pfad

Installation

pip install 'litellm[proxy]'

Proxy-Konfiguration

litellm-config.yaml
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_KEY

Starten:

export OPENAI_API_KEY="sk-your-tokenlab-key"
litellm --config litellm-config.yaml --port 4000

Mit dem OpenAI SDK aufrufen

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)

Direkt mit der Python-Bibliothek aufrufen

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."}]
)

Bewährte Praktiken

  • Behandeln Sie TokenLab zunächst als custom_openai-Upstream
  • Setzen Sie LiteLLM nur dann davor, wenn Sie wirklich eine zusätzliche Gateway-Schicht benötigen
  • Erwarten Sie auf dem OpenAI-kompatiblen Pfad nicht automatisch jedes anbieternative Detail

Auf dieser Seite