Overview
AutoGen can use TokenLab through OpenAIChatCompletionClient, the same OpenAI-compatible client path it uses for other custom Chat Completions endpoints.
Type: Agent FrameworkPrimary Path: OpenAI-compatible chat completionsSupport Confidence: Supported custom endpoint path
Installation
pip install -U autogen-agentchat "autogen-ext[openai]" pyyaml
Environment
export TOKENLAB_API_KEY="sk-your-tokenlab-key"
YAML Model Config
Use TokenLab’s /v1 endpoint as base_url:
provider: autogen_ext.models.openai.OpenAIChatCompletionClient
config:
model: claude-sonnet-5
base_url: https://api.tokenlab.sh/v1
api_key: ${TOKENLAB_API_KEY}
model_info:
function_calling: true
json_output: true
vision: false
family: claude
Python Client
import os
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
model_client = OpenAIChatCompletionClient(
model="claude-sonnet-5",
base_url="https://api.tokenlab.sh/v1",
api_key=os.environ["TOKENLAB_API_KEY"],
model_info={
"function_calling": True,
"json_output": True,
"vision": False,
"family": "claude",
},
)
agent = AssistantAgent("assistant", model_client=model_client)
Endpoint Notes
AutoGen’s OpenAI extension expects the OpenAI-compatible request shape. For provider-native features such as Anthropic Messages or Gemini generateContent, use TokenLab’s native endpoints from a client that supports those protocols directly.