Overview
CrewAI supports OpenAI-compatible LLMs by setting the model, API key, and base URL on environment variables or on the LLM class.
Type: Agent FrameworkPrimary Path: OpenAI-compatible chat completionsSupport Confidence: Supported custom endpoint path
Environment Variables
import os
os.environ["OPENAI_API_KEY"] = "sk-your-tokenlab-key"
os.environ["OPENAI_API_BASE"] = "https://api.tokenlab.sh/v1"
os.environ["OPENAI_MODEL_NAME"] = "claude-sonnet-5"
LLM Class
from crewai import Agent, LLM
llm = LLM(
model="claude-sonnet-5",
base_url="https://api.tokenlab.sh/v1",
api_key="sk-your-tokenlab-key",
)
agent = Agent(
role="Research analyst",
goal="Summarize technical tradeoffs clearly",
backstory="You produce concise implementation notes.",
llm=llm,
)
Model Suggestions
Use gpt-5.4-mini for routine crews, claude-sonnet-5 or gpt-5.4 for planning-heavy agents, and deepseek-v4-flash for faster low-cost iterations.
Endpoint Notes
CrewAI’s OpenAI-compatible path is best for Chat Completions style agent calls. Use TokenLab native endpoints directly only when the tool or SDK you choose can speak those native protocols.