Commit graph

8121 commits

Author SHA1 Message Date
Nik
13db8e10dc feat: add display_name, model_vendor, and model_version metadata 2026-01-05 11:01:36 -08:00
Alexsander Hamir
3b847e0d9d
refactor: migrate utils.py lazy imports to registry pattern (#18657)
* refactor: migrate utils.py lazy imports to registry pattern

- Refactored utils.py __getattr__ to use cached registry pattern (similar to __init__.py)
- Added UTILS_MODULE_NAMES tuple and _UTILS_MODULE_IMPORT_MAP to _lazy_imports_registry.py
- Added _get_utils_globals() helper function to _lazy_imports.py
- Added _lazy_import_utils_module() handler function for utils module lazy imports
- Updated _get_lazy_import_registry() to include utils module lazy imports
- Removed redundant _get_utils_globals() from utils.py (now in _lazy_imports.py)
- Added comprehensive tests for utils module lazy imports in test_lazy_imports.py

This refactoring:
- Reduces code duplication (from 670+ lines to ~10 lines in __getattr__)
- Improves maintainability (new lazy imports just need registry entry)
- Maintains consistency with __init__.py lazy import pattern
- All existing functionality preserved and tested

* Fix NameError: get_coroutine_checker not defined in check_coroutine function

* Fix lazy loading for get_coroutine_checker in function_setup and check_coroutine

- Add lazy loading for get_coroutine_checker at start of function_setup to ensure all calls use lazy-loaded version
- Fix check_coroutine function to use lazy loading pattern via getattr
- All direct calls to get_coroutine_checker() now properly use lazy import mechanism
2026-01-05 09:55:48 -08:00
Sameer Kankute
d0a26dd4bc
Merge pull request #18644 from BerriAI/litellm_fix_mapped_tests_05012026
Fix mapped tests 05012026
2026-01-05 17:53:17 +05:30
Sameer Kankute
3c60b930e2
Merge pull request #18635 from BerriAI/litellm_completions_api_summary_param
(feat) Add mapping for reasoning effort to summary param of responses API
2026-01-05 17:36:21 +05:30
Sameer Kankute
30096ffe5c
Merge pull request #18637 from BerriAI/litellm_gemini_api_base_auth_fix
fix: auth header for custom api base in generate Content request
2026-01-05 17:35:47 +05:30
Sameer Kankute
2d7f0a1351 fix: test_create_simple_string_input 2026-01-05 17:15:12 +05:30
Sameer Kankute
c0f74c994a Fix: test_transform_request_image_extraction 2026-01-05 17:02:54 +05:30
YutaSaito
165d5f3af1
Merge pull request #18640 from BerriAI/litellm_fix_cloudzero_integration_test
tests: mock LiteLLM_UserTable for CloudZero export
2026-01-05 17:41:22 +09:00
Yuta Saito
bdc35b4cd2 tests: mock LiteLLM_UserTable for CloudZero export 2026-01-05 17:23:04 +09:00
Sameer Kankute
0730a74dda fix: auth header for custom api base in generate Content request 2026-01-05 12:25:13 +05:30
Yuta Saito
f1d77ae14d feat: allow_all_keys to mcp server 2026-01-05 15:49:09 +09:00
Sameer Kankute
0f8e4364d6 Replace summary param as detailed 2026-01-05 11:24:35 +05:30
Sameer Kankute
42d4aab3e7 Add mapping for reasoning effort to summary of responses API 2026-01-05 11:21:34 +05:30
YutaSaito
b6664669d2
Merge pull request #18480 from hamzaq453/fix/openapi-parameter-names-security
Fix: Remove exec() usage and handle invalid OpenAPI parameter names
2026-01-05 14:34:57 +09:00
YutaSaito
c405135c2b
Merge pull request #18584 from BerriAI/feat/add_user_email_to_cloudzero
feat: add user email to cloudzero
2026-01-05 14:22:46 +09:00
hamzaq453
9ca7b1ad9b Resolve merge conflicts: integrate path validation with **kwargs approach
- Keep **kwargs approach (no exec()) for security
- Integrate path traversal validation from main branch
- Add URL encoding for path parameters
- Merge both test suites (edge cases + security tests)
- All 14 tests passing
2026-01-05 10:20:26 +05:00
YutaSaito
fcabc059ca
Merge pull request #18630 from BerriAI/litellm_fix_mcp_guardrail
fix: MCP handling in unified guardrail
2026-01-05 12:25:14 +09:00
amangupta-20
399579f8ea
feat: Add Levo AI integration (#18529) 2026-01-05 08:49:21 +05:30
Yuta Saito
0509fc79da fix: move code from litellm/llms to the mcp_server dir 2026-01-05 12:05:16 +09:00
Yuta Saito
c8c73e6fa5 fix: MCP handling in unified guardrail 2026-01-05 10:41:24 +09:00
lif
7d81d245fb
fix: align prometheus metric names with DEFINED_PROMETHEUS_METRICS (#18463)
Fix metric name inconsistency for litellm_remaining_requests_metric
and litellm_remaining_tokens_metric. The factory received names
without the _metric suffix, causing _is_metric_enabled to fail when
users configured these metrics in prometheus_metrics_config.

Fixes #18221

Signed-off-by: majiayu000 <1835304752@qq.com>
2026-01-04 00:48:09 +05:30
lif
64cfe75bfd
fix: extract pure base64 data from data URLs for Ollama (#18465)
Fix Ollama_chatException "illegal base64 data at input byte 4" error
when using images with ollama_chat provider. Ollama expects pure base64
data, not the full data URL format (data:image/png;base64,...).

Fixes #18338

Signed-off-by: majiayu000 <1835304752@qq.com>
2026-01-04 00:47:38 +05:30
lif
099e108b51
fix: correctly route codestral chat and FIM endpoints (#18467)
Fixed duplicate condition that made text-completion-codestral provider
unreachable. Now:
- codestral.mistral.ai/v1/chat/completions -> codestral
- codestral.mistral.ai/v1/fim/completions -> text-completion-codestral

Fixes #18464

Signed-off-by: majiayu000 <1835304752@qq.com>
2026-01-04 00:45:45 +05:30
cantalupo555
9b1c5f7e36
feat(zai): Add GLM-4.7 model with reasoning support (#18476)
Add support for Z.AI GLM-4.7, latest flagship model with enhanced reasoning capabilities.

Changes:
- Add zai/glm-4.7 to model pricing with /bin/bash.60/M input, .20/M output
- Add cached input pricing (/bin/bash.11/M) for GLM-4.7
- Add supports_reasoning flag to enable thinking parameter
- Update ZAIChatConfig to support thinking parameter for models with reasoning
- Update documentation with GLM-4.7 as latest flagship model
- Add cached input column to pricing table (GLM-4.7 only)
- Add tests for GLM-4.7 reasoning support and cost calculation
- Update all examples to use GLM-4.7

Model specifications:
- Context: 200K input, 128K output
- Supports: reasoning, function calling, tool choice, prompt caching
- Pricing: Same as GLM-4.6 with cache support

See: https://docs.z.ai/guides/llm/glm-4.7
2026-01-04 00:44:19 +05:30
Lu
37c908caf9
google genai adapter inline data support (#18477)
* support inline data

* add test
2026-01-04 00:43:22 +05:30
ゆり
9ba27d85ce
feat(types): add output_text property to ResponsesAPIResponse (#18491)
Add the output_text convenience property to ResponsesAPIResponse that
aggregates all output_text items from the output list, matching the
OpenAI SDK's Response.output_text behavior.

The property iterates through output items, collects text content from
message-type outputs, and returns them concatenated into a single
string. Returns empty string if no output_text content exists.

Handles both dict and Pydantic model access patterns for compatibility
with different output formats.

Fixes #18470

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: yurekami <yurekami@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 00:38:32 +05:30
Cesar Garcia
bdd05475bc
fix: correct cost calculation when reasoning_tokens present without text_tokens (#18607)
Fixes #18599

When OpenAI models (gpt-5-nano, o1-*, o3-*) and other providers return
reasoning_tokens in completion_tokens_details but don't provide text_tokens,
LiteLLM was incorrectly calculating costs using only reasoning_tokens,
ignoring the remaining completion tokens.

Changes:
- Modified generic_cost_per_token() in llm_cost_calc/utils.py to calculate
  text_tokens as: completion_tokens - reasoning_tokens - audio_tokens - image_tokens
  when text_tokens is not explicitly provided
- Added comprehensive test case test_reasoning_tokens_without_text_tokens_gpt5_nano()
  to verify all completion_tokens are billed correctly

Example:
- completion_tokens: 977
- reasoning_tokens: 768
- Before: only 768 tokens billed (21% less)
- After: all 977 tokens billed correctly

Affected models:
- OpenAI: gpt-5-nano, o1-*, o3-*
- Perplexity: sonar-reasoning*
- Any model returning reasoning_tokens without text_tokens
2026-01-04 00:09:00 +05:30
YutaSaito
61e666c457
Merge pull request #18597 from BerriAI/litellm_fix_openapi_to_mcp
fix openapi to mcp
2026-01-03 09:43:06 +09:00
Yuta Saito
8e633ab513 fix: reuse shared async client in mcp openapi generator 2026-01-03 09:33:12 +09:00
Yuta Saito
6168e500a8 fix: add checking path param 2026-01-03 08:57:54 +09:00
kevinpauer
705b54bf04
Feat/add watsonx fields (#18569) 2026-01-03 02:53:17 +05:30
Alexsander Hamir
44d309f270
refactor: Add lazy loading for get_llm_provider (#18591) 2026-01-02 13:18:57 -08:00
Harshit Jain
cc659b8702
fix(logging_worker): handle event loop changes in multiprocessing by checking bound_loop (#18423) 2026-01-03 00:19:14 +05:30
Alex Gertz
3bd309f808
fix: return empty data array instead of 500 when no models configured (#18556)
- /v2/model/info now returns {"data": []} when llm_router is None or model_list is empty
- /model_group/info now returns {"data": []} when llm_model_list is None or empty
- Fixes UI crash on fresh installs with STORE_MODEL_IN_DB=True
- Added 4 unit tests for empty model list scenarios
2026-01-02 23:36:05 +05:30
Cesar Garcia
c8950a5ba2
fix(cost_calculator): correct gpt-image-1 cost calculation using token-based pricing (#17906)
* fix(cost_calculator): correct gpt-image-1 cost calculation using token-based pricing (#13847)

gpt-image-1 uses token-based pricing (like chat models), not pixel-based pricing
like DALL-E. The old code was calculating incorrect costs by treating it as DALL-E.

Changes:
- Update model pricing JSON with correct token-based costs for gpt-image-1
- Add dedicated cost calculator for OpenAI gpt-image models
- Route gpt-image-1 to token-based calculator in cost router
- Add comprehensive tests for the new calculator

* refactor: simplify gpt-image-1 cost calculator using responses API helper

Reuse _transform_response_api_usage_to_chat_usage and generic_cost_per_token
for gpt-image-1 cost calculation since ImageUsage has the same spec as
ResponseAPIUsage.
2026-01-02 23:08:52 +05:30
Sameer Kankute
c380ad70d5
Merge pull request #18588 from BerriAI/litellm_fix_sameer_cicd
fix background cost tracking tests
2026-01-02 21:52:44 +05:30
Sameer Kankute
5ed83756eb
Merge pull request #18583 from BerriAI/litellm_block_negative_budget
Add validation for negative budget
2026-01-02 21:52:15 +05:30
Sameer Kankute
233ba9d4b8 fix mock tests 2026-01-02 21:40:27 +05:30
Sameer Kankute
ed59a9b376 fix background cost tracking tests 2026-01-02 21:12:25 +05:30
Sameer Kankute
7512b327d4
Merge pull request #18585 from BerriAI/litellm_gemini_system_instructions
Preserve system instructions for gemini
2026-01-02 20:59:44 +05:30
Sameer Kankute
bfbe13bbd4
Merge pull request #18190 from RensDimmendaal/add-gemini-img-tool-result-support
Fix Gemini 3 imgs in tool response
2026-01-02 17:06:51 +05:30
Sameer Kankute
ccdbe921e1
Merge pull request #18514 from xuan07t2/fix/vertex-ai-tools-one-type-per-object
fix(vertex_ai): separate Tool objects for each tool type per API spec
2026-01-02 16:21:17 +05:30
Sameer Kankute
65e60a16d3
Merge pull request #18497 from DevajMody/fix/vertex-ai-anthropic-image-urls
fix(vertex_ai): convert image URLs to base64 for Vertex AI Anthropic
2026-01-02 14:50:04 +05:30
Sameer Kankute
81cbd7a8d8 Preserve system instructions for gemini 2026-01-02 14:39:25 +05:30
YutaSaito
e9365c496d
Merge pull request #18580 from BerriAI/litellm_feat_support_metaurl_on_ui
feat: add UI support for configuring meta URLs
2026-01-02 17:54:26 +09:00
Yuta Saito
da05b56756 feat: add user email to cloudzero 2026-01-02 17:48:16 +09:00
YutaSaito
4b131a77a0
Merge pull request #18573 from BerriAI/litellm_fix_normalize-model-name
fix: unify model names to provider-defined names
2026-01-02 17:37:28 +09:00
Lukas de Boer
edc8413f1e
Add Kubernetes ServiceAccount JWT authentication support (#18055)
* Allow get_nested_value dot notation to support escaping for Kubernetes JWT Support

* Add support for team and org alias fields, add docs, tests

* Fix lint issue with max statements in handle jwt logic
2026-01-02 14:02:31 +05:30
Yuta Saito
89ce8091bb fix: test 2026-01-02 16:32:33 +09:00
Sameer Kankute
57c373c5d8 Add validation for negative budget 2026-01-02 12:57:39 +05:30