Cost & Token Tracking
2Signal automatically tracks token usage and calculates cost for every LLM call when you use a wrapped client. Here's how it works.
How Cost is Calculated
When you wrap an LLM client with wrap_openai, wrap_anthropic, or any other wrapper, 2Signal captures:
- Model name from the API response
- Token counts (prompt tokens + completion tokens) from the usage field
- Cost calculated as:
(prompt_tokens × input_price) + (completion_tokens × output_price)
Costs are stored per-span and aggregated up to the trace level as total_cost.
Supported Models & Pricing
The SDK includes a built-in pricing table for 50+ models. Prices reflect the latest public pricing from each provider.
OpenAI
| Model | Input ($/1M tokens) | Output ($/1M tokens) |
|---|---|---|
| gpt-4o | $2.50 | $10.00 |
| gpt-4o-mini | $0.15 | $0.60 |
| gpt-4-turbo | $10.00 | $30.00 |
| gpt-4 | $30.00 | $60.00 |
| gpt-3.5-turbo | $0.50 | $1.50 |
| o3-mini | $1.10 | $4.40 |
Anthropic
| Model | Input ($/1M tokens) | Output ($/1M tokens) |
|---|---|---|
| claude-opus-4 | $15.00 | $75.00 |
| claude-sonnet-4 | $3.00 | $15.00 |
| claude-haiku-4 | $0.80 | $4.00 |
| claude-3-5-sonnet | $3.00 | $15.00 |
| claude-3-opus | $15.00 | $75.00 |
| Model | Input ($/1M tokens) | Output ($/1M tokens) |
|---|---|---|
| gemini-2.5-pro | $1.25 | $10.00 |
| gemini-2.5-flash | $0.15 | $0.60 |
| gemini-2.0-flash | $0.10 | $0.40 |
| gemini-1.5-pro | $1.25 | $5.00 |
| gemini-1.5-flash | $0.075 | $0.30 |
Other Providers
| Provider | Models |
|---|---|
| Mistral | mistral-large, mistral-medium, mistral-small, codestral, ministral-8b |
| Cohere | command-r-plus, command-r |
| Groq | llama-3.3-70b, llama-3.1-8b, mixtral-8x7b, gemma2-9b |
Unsupported Models
If a model isn't in the pricing table, 2Signal still captures the token counts but reports cost as $0.00. You can still use the Cost evaluator with custom thresholds, or submit costs manually via the API:
# Manual cost submission in a span
with ts.span(name="llm-call", span_type="llm") as ctx:
result = my_custom_llm(prompt)
ctx["output"] = result
ctx["usage"] = {"prompt_tokens": 500, "completion_tokens": 200}
ctx["cost"] = 0.015 # USDUsage Tracking
Beyond per-request costs, 2Signal tracks monthly usage at the organization level:
| Metric | Description |
|---|---|
| Trace count | Total traces ingested this month |
| Span count | Total spans across all traces |
| Eval run count | Total evaluator executions |
Plan Limits
| Plan | Traces/month | Evals/month | Retention |
|---|---|---|---|
| Free | 1,000 | 500 | 7 days |
| Pro | 10,000 | 5,000 | 30 days |
| Team | 50,000 | 25,000 | 90 days |
| Enterprise | Unlimited | Unlimited | Unlimited |
Usage Alerts
2Signal sends email notifications to organization owners and admins at:
- 80% of your monthly trace limit — warning to review usage
- 100% of your monthly trace limit — hard limit reached, new traces rejected
Alerts are sent once per threshold per month and include a link to the billing page for plan upgrades.