Frameworks & Platforms
VoltAgent
Use TokenLab models in VoltAgent agents
Overview
VoltAgent accepts AI SDK language models directly. Configure an OpenAI-compatible AI SDK provider with TokenLab's /v1 base URL and pass the selected model into your agent.
Installation
npm install @voltagent/core@2 ai@6 @ai-sdk/openai@3 zodEnvironment
export TOKENLAB_API_KEY="sk-your-tokenlab-key"Direct AI SDK Provider
import { Agent } from "@voltagent/core";
import { createOpenAI } from "@ai-sdk/openai";
const tokenlab = createOpenAI({
apiKey: process.env.TOKENLAB_API_KEY,
baseURL: "https://api.tokenlab.sh/v1",
});
const agent = new Agent({
name: "tokenlab-agent",
instructions: "Answer concisely.",
model: tokenlab.chat("claude-sonnet-5"),
});Model Router Path
If your VoltAgent registry snapshot includes a TokenLab provider entry from models.dev, configure:
export TOKENLAB_API_KEY="sk-your-tokenlab-key"
export TOKENLAB_BASE_URL="https://api.tokenlab.sh/v1"Then use the registry model string, for example tokenlab/claude-sonnet-5.
Endpoint Notes
The direct AI SDK path is the most explicit setup. Use TokenLab native Responses, Anthropic Messages, or Gemini endpoints only when your selected AI SDK provider/client is configured for that protocol.