Repository navigation
Litellm dev 04 02 2026 p1 #25052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Litellm dev 04 02 2026 p1 #25052
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,18 @@ def get_cost_for_web_search_request( | |
|
|
||
| return get_cost_for_anthropic_web_search(model_info=model_info, usage=usage) | ||
| elif custom_llm_provider.startswith("vertex_ai"): | ||
| # Anthropic Claude models on Vertex AI populate server_tool_use.web_search_requests | ||
| # (same as the direct Anthropic API), not prompt_tokens_details.web_search_requests | ||
| # (which is the Gemini field). Route claude-* models to the Anthropic calculator. | ||
| model_key: str = model_info.get("key", "") if model_info else "" | ||
| if "claude" in model_key.lower(): | ||
| from .anthropic.cost_calculation import get_cost_for_anthropic_web_search | ||
|
|
||
| verbose_logger.debug( | ||
| "vertex_ai/claude model detected — routing web search cost to Anthropic calculator" | ||
| ) | ||
| return get_cost_for_anthropic_web_search(model_info=model_info, usage=usage) | ||
|
Comment on lines
+40
to
+47
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new import at line 42 ( All other branches in this file already follow the same inline-import pattern, so this is consistent — but if refactoring ever brings the imports to module-level, this new one should move too. Consider a top-of-file import with a conditional guard, or document the circular-import reason in a comment, so future contributors know the inline pattern is intentional. Context Used: CLAUDE.md (source) Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
|
|
||
| from .vertex_ai.gemini.cost_calculator import ( | ||
| cost_per_web_search_request as cost_per_web_search_request_vertex_ai, | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
web_search_requests == 0triggers web-search cost path unnecessarilyThe guard
usage.server_tool_use.web_search_requests is not NonereturnsTrueeven whenweb_search_requests == 0(zero actual searches). This causesresponse_object_includes_web_search_callto reportTruefor a response that contained no web searches at all.While downstream
get_cost_for_anthropic_web_searchwould compute0 * rate = 0.0, returningTruehere is semantically incorrect and mirrors a pre-existing gap also present in the Gemini branch. The parallel Gemini check (prompt_tokens_details.web_search_requests is not None) has the same issue, so at minimum be consistent — but consider tightening both to> 0:Evidence:
test_anthropic_chat_transformation.pyline 1208 explicitly assertsusage.server_tool_use.web_search_requests == 0as a valid server-returned value.