Repository navigation
fix(cost-map): bill Azure OpenAI web search at the Grounding with Bing rate - #48367
Closed
kelp-aryan wants to merge 1 commit into
Closed
kelp-aryan wants to merge 1 commit into
kelp-aryan wants to merge 1 commit into
Conversation
…g rate Azure OpenAI's web_search tool runs on Grounding with Bing and is billed per Bing request ($14 per 1,000). azure/* rows copied OpenAI's $0.01, and 73 azure rows whose OpenAI model prices web search had no search price, so they billed $0.
kelp-aryan
requested review from
joshua-berri,
kerry-berri and
mateo-berri
as code owners
October 26, 2026 06:54
Contributor
Merging this PR will not alter performance1 warning
Comparing Footnotes |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
3 of 6 tasks
Contributor
|
Absorbed into the rolling registry PR #48188 with the Bing rate and both tests, credited as co-author. Closing as superseded |
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.
Azure OpenAI's web search tool runs on Grounding with Bing, and Microsoft bills it at $14 per 1,000 Bing requests. LiteLLM billed Azure web search at OpenAI's $10 per 1,000, or at $0 on Azure models whose price row had no search price, so proxy spend and budgets under-counted it. This PR prices every Azure row that supports web search at $0.014 per request and adds tests that keep new Azure rows in line.
Details
TLDR
Problem this solves:
How it solves it:
search_context_cost_per_queryto 0.014 on 51 azure rowsUser Flow
Before: a proxy admin running Azure OpenAI with web search sees search spend recorded low, or at $0
"model": "azure/gpt-5-mini"and"tools": [{"type": "web_search"}]tool_usage.web_search.num_requests: 3)x-litellm-response-cost-tool-usagereads0.0, and key spend counts no search costAfter: the same request records the Bing requests at Microsoft's rate
x-litellm-response-cost-tool-usagereads0.042(3 x $0.014), and key spend includes itRelevant issues
Fixes #48365
Pre-Submission checklist
uv run pytest tests/unit/<your_test_file>.py -vcost-map-guard,lint passedandsmoke passedpass.unit passedfails only ontest_token_counter_loads_a_custom_tokenizer_off_the_event_loopinproxy-infra-root(event loop stalled 0.111s against a 0.104s limit; 4328 other tests passed). That timing test fails the same way on other open PRs and doesn't touch pricing, so a re-run should clear it. I can't re-run jobs from a fork.Screenshots / Proof of Fix
Real responses from Azure OpenAI deployments on Microsoft Foundry (
/v1/responses,web_searchtool), captured through a LiteLLM 1.106.4 proxy. The Before header values are what that proxy charged live. Both Before and After price the same saved response bodies with each checkout's cost calculator. I don't have a raw Azure key to run a second proxy on this branch.Before (dddbaa8)
azure/gpt-5.6-luna, 1 Bing request
x-litellm-response-cost-tool-usage: 0.01num_requests=1 web_search_fee=$0.010000azure/gpt-5-mini, 3 Bing requests
x-litellm-response-cost-tool-usage: 0.0num_requests=3 web_search_fee=$0.000000After (d6ce0fb)
azure/gpt-5.6-luna, 1 Bing request
num_requests=1 web_search_fee=$0.014000azure/gpt-5-mini, 3 Bing requests
num_requests=3 web_search_fee=$0.042000Tests:
The 4 new tests fail on the dddbaa8 cost map and pass here.
test_embedding_success_logging_and_spend_log_carry_no_forwarded_credentialsintests/unit/test_cost_calculator.pyfails locally on both dddbaa8 and this branch withModuleNotFoundError: websockets, which is a local environment gap.Type
🐛 Bug Fix
Caveats (if any)
Medium
tool_usage.web_search.num_requestsand links Grounding with Bing pricing for ratesLow
supports_web_searchflags are unchangeddocs/search/bing_groundingstill says web search mode pays no per-search fee; left for a separate changeFinal Attestation