TracePilot AI records token usage and estimated API cost for every LLM call your agent makes. This data is captured automatically when you wrap calls withDocumentation Index
Fetch the complete documentation index at: https://tracepilot.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
tp.wrapOpenAI() — no additional configuration, no separate instrumentation, and no changes to your agent logic. Every span in the dashboard shows exactly what each step cost.
What gets captured
Each span created bywrapOpenAI records:
- Prompt tokens — the number of tokens in the messages you sent
- Completion tokens — the number of tokens in the model’s response
- Total tokens — prompt plus completion
- Estimated cost — calculated from the model’s public pricing at the time of the call
Viewing costs in the dashboard
Open any trace in the TracePilot dashboard. The trace summary shows total token usage and estimated cost for the full run. Expand individual spans to see the breakdown per step. This makes it easy to identify which steps in your agent are the most expensive — whether that’s a verbose system prompt, a high-frequency tool loop, or an unnecessarily large model choice.Cost estimates are based on publicly listed model pricing. They are accurate for standard OpenAI models but may differ slightly from your actual invoice if you have custom pricing agreements.
No extra configuration required
You do not need to configure cost tracking separately. TracePilot extracts token counts from the OpenAI response object, which already includes usage data. Wrapping the call is sufficient:result you receive is the unmodified OpenAI response. TracePilot reads the usage field from it before returning, so you never lose access to any data.
Tracking costs across a multi-step agent
For agents with multiple LLM calls, TracePilot accumulates token data across all spans in the trace. Each span contributes its own usage, and the trace summary aggregates them.Destructive call warnings
A related cost-saving feature is theisDestructive flag on wrapToolCall. When you mark a tool call as destructive, TracePilot adds a Destructive badge to that span in the dashboard.
Token usage
Per-span prompt and completion token counts, visible on every LLM span in the dashboard.
Estimated cost
Calculated from model pricing on each span. Aggregated at the trace level for total run cost.
No configuration
Cost data is extracted automatically from every
wrapOpenAI response. Nothing to set up.Destructive flags
Mark side-effecting tool calls with
isDestructive: true to surface them clearly during debugging.