litellm/litellm
openhands 5655cb87fc fix: pass all custom pricing fields to register_model in completion() and embedding()
Previously, register_model() was called with only input_cost_per_token,
output_cost_per_token, and litellm_provider. This dropped ~40+ other
pricing fields from CustomPricingLiteLLMParams (cache_read_input_token_cost,
cache_creation_input_token_cost, output_cost_per_reasoning_token, etc.)
as well as model_info metadata (mode, supports_prompt_caching, max_tokens).

For DB-sourced custom-priced models, the first request after a pod restart
would register a partial entry in litellm.model_cost, causing cost
calculations to miss cache token discounts and other extended pricing
until the entry was later enriched by deployment_callback_on_success
mutating the lru_cache.

Changes:
- Add _build_custom_pricing_entry() helper that iterates over all
  CustomPricingLiteLLMParams.model_fields and merges model_info metadata
- Replace hardcoded 3-field dicts in both completion() and embedding()
  with the new helper
- Add 7 tests covering field collection, model_info merging, precedence,
  None skipping, and end-to-end register_model behavior

Co-authored-by: openhands <openhands@all-hands.dev>
2026-03-02 08:11:07 +00:00
..
a2a_protocol fix: prompt registry 2026-02-18 00:34:54 +05:30
anthropic_interface fix: prompt registry 2026-02-18 00:34:54 +05:30
assistants
batch_completion fix: prompt registry 2026-02-18 00:34:54 +05:30
batches Fix: Test connect failing for bedrock batches mode 2026-02-25 15:03:27 +05:30
caching fix(caching): store background task references in LLMClientCache._remove_key to prevent unawaited coroutine warnings 2026-02-27 21:23:56 -05:00
completion_extras fix: resolve ruff PLR0915 and mypy type checking lint errors (#22359) 2026-02-28 15:43:26 -08:00
containers fix: prompt registry 2026-02-18 00:34:54 +05:30
endpoints/speech/speech_to_completion_bridge
evals fix: prompt registry 2026-02-18 00:34:54 +05:30
experimental_mcp_client fix: prompt registry 2026-02-18 00:34:54 +05:30
files fix: prompt registry 2026-02-18 00:34:54 +05:30
fine_tuning
google_genai fix: prompt registry 2026-02-18 00:34:54 +05:30
images fix(image_generation): propagate extra_headers to OpenAI image generation 2026-02-25 01:29:06 +08:00
integrations Merge pull request #22103 from Harshit28j/litellm_feat_datadog_metrics 2026-02-28 17:25:23 +05:30
interactions fix: prompt registry 2026-02-18 00:34:54 +05:30
litellm_core_utils fix: add sync streaming fallback + fix 429 for all streaming paths (#22375) 2026-02-28 15:55:05 -08:00
llms fix(featherless_ai): use correct FEATHERLESS_AI_API_KEY env var name 2026-03-01 17:11:58 +01:00
ocr Enable local file support for OCR (#22133) 2026-02-27 10:50:02 -08:00
passthrough fix(types): fix mypy errors in pass-through endpoint query param types 2026-02-19 12:24:14 -03:00
proxy Fix undefined kwargs in InFlightRequestsMiddleware 2026-03-01 17:23:37 -03:00
proxy_auth fix: prompt registry 2026-02-18 00:34:54 +05:30
rag fix: prompt registry 2026-02-18 00:34:54 +05:30
realtime_api fix(realtime): fix guardrails not firing for Gemini/Vertex AI and provider_config realtime WebSocket sessions (#22168) 2026-02-26 17:06:07 -08:00
rerank_api fix(bedrock): pass timeout param to bedrock rerank http client (#22021) 2026-02-24 09:32:11 -08:00
responses [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
router_strategy fix(lint): fix ruff/flake8 violations - unused imports, PLR0915, print statements (#21846) 2026-02-21 15:07:47 -08:00
router_utils fix: use atomic increment-first pattern for model RPM rate limiting 2026-02-24 09:55:07 -03:00
search
secret_managers fix: prompt registry 2026-02-18 00:34:54 +05:30
skills fix: prompt registry 2026-02-18 00:34:54 +05:30
types Add OCR guardrail_translation handler and support (#22145) 2026-02-28 17:39:36 -08:00
vector_store_files
vector_stores
videos fix(ollama): thread api_base to get_model_info + graceful fallback (#21970) 2026-02-23 21:00:37 -08:00
__init__.py Merge pull request #22182 from BerriAI/litellm_make_session_duration_configurable 2026-02-28 20:31:31 -08:00
_lazy_imports.py fix: prompt registry 2026-02-18 00:34:54 +05:30
_lazy_imports_registry.py Merge branch 'main' into litellm_oss_staging_02_17_2026 2026-02-18 17:26:33 +05:30
_logging.py fix: prompt registry 2026-02-18 00:34:54 +05:30
_redis.py fix: close leaked Redis connection pools on cache eviction and disconnect 2026-02-20 17:09:32 -08:00
_service_logger.py fix: prompt registry 2026-02-18 00:34:54 +05:30
_uuid.py
_version.py
anthropic_beta_headers_config.json fix: enable context-1m-2025-08-07 beta header for vertex_ai provider (#21867) 2026-02-21 20:12:23 -08:00
anthropic_beta_headers_manager.py fix: prompt registry 2026-02-18 00:34:54 +05:30
blog_posts.json fix(ollama): thread api_base to get_model_info + graceful fallback (#21970) 2026-02-23 21:00:37 -08:00
budget_manager.py
constants.py Merge pull request #22182 from BerriAI/litellm_make_session_duration_configurable 2026-02-28 20:31:31 -08:00
cost.json
cost_calculator.py fix(ollama): thread api_base to get_model_info + graceful fallback (#21970) 2026-02-23 21:00:37 -08:00
exceptions.py Remove nit 2026-02-26 13:44:06 -08:00
main.py fix: pass all custom pricing fields to register_model in completion() and embedding() 2026-03-02 08:11:07 +00:00
model_prices_and_context_window_backup.json fix(mcp): default available_on_public_internet to true (#22331) 2026-02-27 20:06:07 -08:00
mypy.ini
policy_templates_backup.json feat(add-new-block_code_execution-guardrail): prevent agent from executing code (#22154) 2026-02-25 22:02:14 -08:00
provider_endpoints_support_backup.json fix: add 12 missing endpoint keys to _ENDPOINT_METADATA, fix stale _schema keys in backup JSON 2026-02-26 19:18:17 -08:00
py.typed
router.py Merge pull request #22526 from BerriAI/fix/router-plr0915-noqa 2026-03-01 18:02:33 -03:00
scheduler.py fix: prompt registry 2026-02-18 00:34:54 +05:30
timeout.py
utils.py fix: resolve ruff PLR0915 and mypy type checking lint errors (#22359) 2026-02-28 15:43:26 -08:00