mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-25 22:20:43 +00:00
* fix(auth): enforce key budgets on Google generateContent calls that leave the model out of the URL The router serves POST /v1beta/models/:generateContent (and /models/:generateContent, :streamGenerateContent) with the model taken from the body, because the path convertor accepts an empty value. The auth gate's route matcher required at least one character for the model, so these calls were not LLM routes and skipped the key, team and proxy budget checks. The model placeholder before a ":" suffix now matches zero or more non-colon characters, the same values the router accepts. * fix(auth): let a Google model name with a colon reach the budget check * fix(auth): give an empty Google model URL its call type and check countTokens on the URL model * fix(google): count an empty-model countTokens call with the body model it was checked on With no model in the URL, countTokens checked model access on the body model but counted with an empty model. It now counts with the body model, like generateContent. Tests pin countTokens to the URL model over proxy-wide models and cover countTokens in the zero-budget route test. * fix(google): keep countTokens unmetered with a colon model and let managed agents count the body model The unbilled check split the last path segment at its first colon, so a colon model name like gemini-text:v1 made countTokens look metered once those routes counted as LLM routes. It now reads the verb after the last colon. A managed agent's countTokens with no model in the URL now resolves the body model, like the countTokens handler * fix(auth): check a forced model on the empty Google model URL like the handler serves it With completion_model or --model set, the empty /v1beta/models/:generateContent URL checked the body model while the handler served the forced model. The empty URL now resolves its model the same way as a named URL, through the handler's own precedence --------- Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| auth | ||
| __init__.py | ||
| test_a2a_endpoints.py | ||
| test_a2a_version_e2e.py | ||
| test_agent_header_isolation.py | ||
| test_agent_headers.py | ||
| test_agent_rbac.py | ||
| test_agent_registry.py | ||
| test_agent_search.py | ||
| test_databricks_oauth.py | ||
| test_endpoints.py | ||
| test_identity.py | ||
| test_identity_store.py | ||
| test_kill_switch.py | ||
| test_managed_identity.py | ||
| test_model_list_helpers.py | ||