Prerequisites
- A TCC API key set as
TCC_API_KEYenvironment variable - The
contextcompanypackage installed
Setup
Step 1: Install dependencies
Step 2: Initialize the callback
Import and register theTCCCallback with LiteLLM:
Step 3: Create a run with LiteLLM steps
Create a run and use LiteLLM inside your agent loop. You must pass the run ID in themetadata parameter to associate the step with your run:
main.py
Custom metadata
You can pass additional metadata alongside the requiredtcc.runId:
What gets captured
The LiteLLM integration automatically captures:- Model: Both the requested and used model
- Messages: Input and output messages
- Token usage: Prompt and completion tokens
- Finish reason: Why the LLM stopped generating
- Tool calls: Any tool calls made by the model
