mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
Fix Gemini web search cost: use $0.014 default + custom pricing override
- Changed hardcoded $0.035 to $0.014 (Gemini 3 family rate per Google AI pricing) - Added support for custom pricing via model_info['web_search_cost_per_request'] - Updated docstring to explain the pricing logic - Fixes BerriAI/litellm#24369
This commit is contained in:
parent
3dccdde9c8
commit
e6f5c7d130
1 changed files with 11 additions and 1 deletions
|
|
@ -31,11 +31,21 @@ def cost_per_token(
|
|||
def cost_per_web_search_request(usage: "Usage", model_info: "ModelInfo") -> float:
|
||||
"""
|
||||
Calculates the cost per web search request for a given model, prompt tokens, and completion tokens.
|
||||
|
||||
Uses custom pricing from model_info if available (via `web_search_cost_per_request` key),
|
||||
otherwise falls back to the default of $0.014 (Google's Gemini 3 family rate).
|
||||
The previous hardcoded default of $0.035 is obsolete.
|
||||
"""
|
||||
from litellm.types.utils import PromptTokensDetailsWrapper
|
||||
|
||||
# cost per web search request
|
||||
cost_per_web_search_request = 35e-3
|
||||
# Check for custom override in model_info first
|
||||
custom_cost = model_info.get("web_search_cost_per_request")
|
||||
if custom_cost is not None and isinstance(custom_cost, (int, float)) and custom_cost > 0:
|
||||
cost_per_web_search_request = custom_cost
|
||||
else:
|
||||
# Default Gemini 3 family rate ($0.014 per request)
|
||||
cost_per_web_search_request = 14e-3
|
||||
|
||||
number_of_web_search_requests = 0
|
||||
# Get number of web search requests
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue