Frameworks & Platforms
Haystack
Use TokenLab with Haystack OpenAIChatGenerator
Overview
Haystack's OpenAIChatGenerator supports custom OpenAI-compatible deployments through api_base_url. Point it at TokenLab and provide a TokenLab API key.
Environment
export TOKENLAB_API_KEY="sk-your-tokenlab-key"Generator
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from haystack.utils import Secret
generator = OpenAIChatGenerator(
api_key=Secret.from_env_var("TOKENLAB_API_KEY"),
api_base_url="https://api.tokenlab.sh/v1",
model="claude-sonnet-5",
)
response = generator.run(
messages=[ChatMessage.from_user("Summarize this document in one sentence.")]
)Endpoint Notes
Use this path for Haystack chat generator pipelines. For embeddings, configure the matching Haystack embedding component with TokenLab's /v1 base URL if your pipeline uses TokenLab embeddings.