Strip believed-free models from pricing block to prevent cost attribution#108
Merged
Conversation
…e run Some providers (Cloudflare being the clearest case) have a non-zero per-token price in the LiteLLM cost map because they publish a paid-tier rate, even though their free plan is quota-limited rather than zero-priced. _merge_pricing() was writing those LiteLLM-sourced prices into the pricing block on every run, causing compute_cost() to attribute a cost to every free-tier request — which eventually lands the model in cost_observed_free_tier and silently breaks free routing. Fix: after merging the LiteLLM baseline with per-source overrides, strip any key that appears in any provider's believed_free list before writing to sidecar["pricing"]. The filter runs on every update so newly believed-free models are cleaned up automatically and models removed from believed_free re-appear in pricing on the next run. Also remove the three Cloudflare entries already in providers.json that were in both the pricing block and believed_free (llama-2-7b-chat-fp16, llama-2-7b-chat-int8, mistral-7b-instruct-v0.1). The fourth entry (@hf/thebloke/codellama-7b-instruct-awq) is not believed_free and is left intact. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XLHnQxLYrMzpm5Ar83ihNC
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.
Summary
This PR fixes an issue where models marked as "believed_free" were still being included in the pricing block, causing the cost accounting system to incorrectly attribute per-token costs to free-tier requests. This led to free models being misclassified in the cost tracking system.
Changes
_merge_pricing()inscripts/update_free_models.pyto automatically strip any models marked as "believed_free" from the final pricing block after merging updatesImplementation Details
The fix works by:
https://claude.ai/code/session_01XLHnQxLYrMzpm5Ar83ihNC