Repository navigation
Conversation
…ooking $0 SpanMetricsMixin._calculate_cost returned Decimal(0) whenever tokencost raised for a model, and tokencost's last release (0.1.26, Aug 2025) has no row for gpt-5.2/5.4/5.5, the gpt-6 family, Claude Opus 4.6+ or Gemini 3.x. Spans on those models showed $0 in prompt, completion and total cost. When tokencost has no row, the cost now comes from llm-prices (dated, source-cited list prices, no dependencies). tokencost still wins when it has the model, and a model neither table knows still costs 0.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SpanMetricsMixin._calculate_costbooks a span at $0 whenever tokencost raises for its model (span_metrics.py):tokencost's latest release is 0.1.26 (2025-08-13), and its table has no gpt-5.2, gpt-5.4, gpt-5.5, gpt-6, Claude Opus 4.6+ or Sonnet 4.6, or Gemini 3.x rows.
calculate_cost_by_tokensraisesKeyErrorfor each of them, so every span on those models shows $0 prompt, completion and total cost. A gpt-5.5 call with a 100K-token prompt and 5K output costs $0.65 and is shown as $0.What this changes
llm-prices>=1.8.0is added toapp/api/pyproject.tomlanduv.lock.Tests
app/api/tests/test_span_metrics_cost.py: gpt-5.5 input and output priced ($0.50 for 100K input, $0.15 for 5K output), claude-opus-4-7 priced, gpt-4o still priced by tokencost, unknown model and missing model still 0. 5 passed. ruff format and ruff check are clean.The collector's cost table (
app/opentelemetry-collector/builder/costs) is also built from tokencost and has the same gap; happy to follow up there if this direction works for you.Disclosure: I maintain llm-prices.