Testing With Real LLM Providers
TraceLLM is provider-agnostic. Users can call OpenAI, Anthropic Claude, Gemini, or any other provider. The SDK records normalized sessions, spans, events, errors, and usage.
The local examples/user-app supports three real providers.
Common Variables
OpenAI
$env:LLM_PROVIDER="openai"
$env:OPENAI_API_KEY="sk_your_openai_key"
$env:OPENAI_MODEL="gpt-4.1-mini"
pnpm example:user-app
The app calls:
TraceLLM records:
- provider:
openai - model
- response id
- output text, if content capture allows it
- token usage, if returned
Anthropic Claude
$env:LLM_PROVIDER="anthropic"
$env:ANTHROPIC_API_KEY="sk-ant-your_key"
$env:ANTHROPIC_MODEL="claude-3-5-sonnet-latest"
pnpm example:user-app
The app calls:
TraceLLM records:
- provider:
anthropic - model
- response id
- output text, if content capture allows it
- input and output tokens
Gemini
$env:LLM_PROVIDER="gemini"
$env:GEMINI_API_KEY="your_gemini_key"
$env:GEMINI_MODEL="gemini-1.5-flash"
pnpm example:user-app
The app calls:
TraceLLM records:
- provider:
gemini - model
- output text, if content capture allows it
- prompt, candidate, and total token counts when returned
What The Example Does
The example models a customer support assistant:
- Fetch customer profile.
- Fetch recent customer activity.
- Build a support prompt.
- Call the selected LLM provider.
- Record usage and output.
- End the session.
This is not a mock trace. The LLM call is real when the provider API key is configured.