Commit graph

29549 commits

Author SHA1 Message Date
amangupta-20
399579f8ea
feat: Add Levo AI integration (#18529) 2026-01-05 08:49:21 +05:30
yuneng-jiang
359b8df8b2
Merge pull request #18619 from BerriAI/litellm_ui_keys_loading_2
[Feature] UI - Virtual Keys Table Loading State Between Pages
2026-01-03 19:30:32 -08:00
yuneng-jiang
1112974112 Virtual Keys Table Loading State 2026-01-03 19:22:38 -08:00
yuneng-jiang
280085edaa
Merge pull request #18618 from BerriAI/litellm_ui_unit_test_coverage
[Infra] UI - Unit Tests: Adding Tests to Increase Coverage
2026-01-03 17:55:53 -08:00
yuneng-jiang
816124a40b Fixign build 2026-01-03 17:39:59 -08:00
yuneng-jiang
1184db079e fixing tests 2026-01-03 17:30:52 -08:00
yuneng-jiang
60c39255d5 Adding unit testing coverage 2026-01-03 17:25:46 -08:00
yuneng-jiang
c07ff5d9ee
Merge pull request #18617 from BerriAI/litellm_ui_sso_loading_state
[Feature] UI - SSO Settings Loading State + Deprecate Previous SSO Flow
2026-01-03 16:33:51 -08:00
yuneng-jiang
d6296411ec SSO Settings Loading, deprecate previous flow 2026-01-03 16:23:10 -08:00
Alexsander Hamir
b6d601c2f0
perf(utils): lazy load 15+ unused imports (#18616)
- Move BaseBatchesConfig, BaseContainerConfig, BaseEmbeddingConfig, BaseImageEditConfig, BaseImageGenerationConfig, BaseImageVariationConfig, BasePassthroughConfig, BaseRealtimeConfig, BaseRerankConfig, BaseVectorStoreConfig, BaseVectorStoreFilesConfig, BaseVideoConfig to lazy loading
- Move ANTHROPIC_API_ONLY_HEADERS, AnthropicThinkingParam, RerankResponse to lazy loading
- Move ChatCompletionDeltaToolCallChunk, ChatCompletionToolCallChunk, ChatCompletionToolCallFunctionChunk, LiteLLM_Params to lazy loading
- Add type stubs to TYPE_CHECKING block for mypy support
- Add lazy loading handlers in __getattr__ method
- These imports are not used in utils.py runtime code, only in type annotations (safe with from __future__ import annotations)
2026-01-03 16:16:17 -08:00
Alexsander Hamir
dd1ccec734
refactor(utils): lazy load 15 additional imports to improve import time (#18613)
* refactor(utils): lazy load 15 additional imports to improve import time

- Move Rules, AsyncHTTPHandler, HTTPHandler to lazy loading via __getattr__
- Move get_num_retries_from_retry_policy, reset_retry_policy to lazy loading
- Move get_secret to lazy loading
- Move cached_imports functions (get_coroutine_checker, get_litellm_logging_class, get_set_callbacks) to lazy loading
- Move core_helpers functions (get_litellm_metadata_from_kwargs, map_finish_reason, process_response_headers) to lazy loading
- Move dot_notation_indexing functions (delete_nested_value, is_nested_path) to lazy loading
- Move get_litellm_params functions to lazy loading
- Move _ensure_extra_body_is_safe, get_formatted_prompt, get_response_headers, update_response_metadata to lazy loading
- Move executor to lazy loading
- Move BaseAnthropicMessagesConfig, BaseAudioTranscriptionConfig to lazy loading
- Add type stubs in TYPE_CHECKING block for mypy type checking
- These functions/classes are exported for other modules but not used internally in utils.py, so lazy loading is safe and improves startup performance

* fix(utils): use getattr for Rules and get_coroutine_checker in client decorator

- Update Rules() instantiation in client decorator to use getattr for lazy loading
- Update Rules.has_pre_call_rules() usage in function_setup to use getattr
- Update get_coroutine_checker() usage in client decorator to use getattr
- Fixes NameError: name 'Rules' is not defined error that occurs when Rules is lazy-loaded

* fix(utils): use getattr for get_litellm_logging_class in function_setup

- Update get_litellm_logging_class() usage in function_setup to use getattr for lazy loading
- Fixes NameError: name 'get_litellm_logging_class' is not defined error that occurs when get_litellm_logging_class is lazy-loaded

* fix(utils): use getattr for get_set_callbacks in function_setup

- Update get_set_callbacks() usage in function_setup to use getattr for lazy loading
- Fixes NameError: name 'get_set_callbacks' is not defined error that occurs when get_set_callbacks is lazy-loaded

* fix(utils): use getattr for all lazy-loaded imports in utils.py

- Update update_response_metadata (4 occurrences) to use getattr
- Update executor.submit (1 occurrence) to use getattr
- Update get_num_retries_from_retry_policy (2 occurrences) to use getattr
- Update reset_retry_policy (2 occurrences) to use getattr
- Update is_nested_path and delete_nested_value (1 occurrence each) to use getattr
- Update _ensure_extra_body_is_safe (1 occurrence) to use getattr

Fixes NameError errors that occur when these functions/classes are lazy-loaded but used directly in utils.py

* fix(utils): use getattr for _get_base_model_from_litellm_call_metadata in _get_base_model_from_metadata

- Update _get_base_model_from_litellm_call_metadata usage to use getattr for lazy loading
- Fixes NameError: name '_get_base_model_from_litellm_call_metadata' is not defined

* fix(utils): use getattr for second _get_base_model_from_litellm_call_metadata usage

- Fix the second occurrence of _get_base_model_from_litellm_call_metadata on line 7052
- Both occurrences in _get_base_model_from_metadata now use getattr for lazy loading

* fix(utils): fix indentation in _get_base_model_from_metadata function

* fix(utils): use getattr for get_litellm_metadata_from_kwargs in _get_litellm_params

- Update get_litellm_metadata_from_kwargs usage to use getattr for lazy loading
- Fixes NameError: name 'get_litellm_metadata_from_kwargs' is not defined

* fix(utils): fix syntax error in get_litellm_metadata_from_kwargs fix

- Move getattr call before cast statement to fix syntax error
2026-01-03 15:50:53 -08:00
yuneng-jiang
bbae987b02
Merge pull request #18615 from BerriAI/litellm_ui_admin_add_model_1
[Infra] UI - E2E Tests: Add Model - See Models from Selected Provider
2026-01-03 15:46:53 -08:00
yuneng-jiang
a6c3fb1fb5 E2E test see models for specific provider 2026-01-03 15:10:52 -08:00
Alexsander Hamir
1c5c303e98
refactor(utils): implement lazy loading for provider configs, model info classes, streaming handlers, and redact utilities (#18611)
* refactor(utils): lazy load redact_messages imports to improve import time

- Move LiteLLMLoggingObject and redact_message_input_output_from_logging to lazy loading via __getattr__
- Add type stubs in TYPE_CHECKING block for mypy type checking
- These are only used in type annotations (with from __future__ import annotations), so lazy loading works correctly

This reduces import time by deferring the redact_messages module import until these are actually accessed.

* refactor(utils): lazy load CustomStreamWrapper to improve import time

- Move CustomStreamWrapper from streaming_handler to lazy loading via __getattr__
- Add type stub in TYPE_CHECKING block for mypy type checking
- CustomStreamWrapper is not used internally in utils.py, only exported for other modules

This reduces import time by deferring the streaming_handler module import until CustomStreamWrapper is actually accessed.

* refactor(utils): lazy load BaseGoogleGenAIGenerateContentConfig to improve import time

- Move BaseGoogleGenAIGenerateContentConfig from google_genai.transformation to lazy loading via __getattr__
- Add type stub in TYPE_CHECKING block for mypy type checking
- BaseGoogleGenAIGenerateContentConfig is only used in type annotations (with from __future__ import annotations), so lazy loading works correctly

This reduces import time by deferring the google_genai.transformation module import until BaseGoogleGenAIGenerateContentConfig is actually accessed.

* refactor(utils): lazy load BaseOCRConfig, BaseSearchConfig, and BaseTextToSpeechConfig

- Move BaseOCRConfig, BaseSearchConfig, and BaseTextToSpeechConfig to lazy loading via __getattr__
- Add type stubs in TYPE_CHECKING block for mypy type checking
- These config classes are only used in quoted type annotations (forward references), so lazy loading works correctly

This reduces import time by deferring the transformation module imports until these config classes are actually accessed.

* refactor(utils): lazy load BedrockModelInfo, CohereModelInfo, and MistralOCRConfig

- Move BedrockModelInfo, CohereModelInfo, and MistralOCRConfig to lazy loading via __getattr__
- Add type stubs in TYPE_CHECKING block for mypy type checking
- Update internal usages to use getattr pattern for accessing lazy-loaded classes
- These provider-specific model info classes are only used in specific code paths, so lazy loading reduces initial import time

This reduces import time by deferring the bedrock, cohere, and mistral module imports until these classes are actually accessed.

* fix(utils): remove duplicate MistralOCRConfig import in TYPE_CHECKING block
2026-01-03 14:07:57 -08:00
Alexsander Hamir
2cbcaf2abf
refactor(utils): lazy load heavy imports to improve import time and memory usage (#18610)
* refactor(utils): lazy load heavy imports to improve import time

- Move BaseVectorStore, CredentialAccessor, and exception_mapping_utils imports to lazy loading via __getattr__
- Add _get_utils_globals() helper function following pattern from _lazy_imports.py
- Refactor __getattr__ to use consistent caching pattern matching __init__.py
- Update load_credentials_from_list to use lazy-loaded CredentialAccessor

This reduces import time and memory usage by only loading these modules when they're actually accessed, not during module import.

* refactor(utils): lazy load additional heavy imports to improve import time

- Move get_llm_provider, _is_non_openai_azure_model to lazy loading
- Move get_supported_openai_params to lazy loading
- Move convert_dict_to_response functions (LiteLLMResponseObjectHandler, convert_to_model_response_object, etc.) to lazy loading
- Move get_api_base and ResponseMetadata to lazy loading
- Move _parse_content_for_reasoning to lazy loading
- Update all internal usages to access via getattr(sys.modules[__name__], ...)

This reduces import time and memory usage by only loading these modules when they're actually accessed, not during module import.

* fix(utils): suppress PLR0915 linter warning for __getattr__ function

The __getattr__ function intentionally has many statements to handle
multiple lazy-loaded imports. Add noqa comment to suppress the warning.

* fix(utils): add type stubs for lazy-loaded functions in TYPE_CHECKING block

Add type imports and declarations in TYPE_CHECKING block to help mypy
understand the types of lazy-loaded functions accessed via __getattr__.
This follows the same pattern used in __init__.py for lazy-loaded items.
2026-01-03 13:34:17 -08:00
yuneng-jiang
d0b030f753
Merge pull request #18609 from BerriAI/litellm_resolve_xai_key
[Refactor] UI - SSO Settings Page Edit Path
2026-01-03 12:56:27 -08:00
yuneng-jiang
5c7523b11e Fixing tests 2026-01-03 12:43:13 -08:00
yuneng-jiang
4904ed394e Edit path for SSO Settings 2026-01-03 12:36:26 -08:00
Alexsander Hamir
1452f01505
refactor: lazy load get_llm_provider and remove_index_from_tool_calls (#18608) 2026-01-03 12:12:24 -08: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
Anders Kaseorg
89b4a6d67c
Allow installation with current grpcio on old Python (#18473)
Instead of limiting grpcio < 1.68.0, specifically exclude the versions
affected by the reconnect bug, and allow installation with either
older or newer versions.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2026-01-04 00:45:15 +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
ゆり
dc62cdb300
fix: handle empty error objects in response conversion (#18493)
Some OpenAI-compatible providers (e.g., Apertis) return empty error
objects even on successful responses. The previous check only verified
that error was not None, causing spurious APIErrors.

Now the code checks if the error object contains meaningful data:
- For dict errors: non-empty message OR non-null code
- For string errors: non-empty string
- Other truthy values are still treated as errors

Fixes #18407

🤖 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:37:52 +05:30
Deepak Walia
3a4ebf173f
fix(sap): honor allowed_openai_params in transform_request (#18432) 2026-01-04 00:35:53 +05:30
Mehmet Can Şakiroğlu
a3503e59c2
Litellm feat helm lifecycle support (#18517)
* feat(helm): add lifecycle hook support for helm

* add tests
2026-01-04 00:22:50 +05:30
Krish Dholakia
969790c463
Iam roles anywhere docs (#18559)
* Add documentation for IAM Roles Anywhere

Co-authored-by: krrishdholakia <krrishdholakia@gmail.com>

* Refactor Bedrock provider docs for IAM Roles Anywhere

Co-authored-by: krrishdholakia <krrishdholakia@gmail.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-01-04 00:10:07 +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
Krish Dholakia
87fe62229f
feat: Add adopters page and data structure (#18605)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-01-03 21:51:19 +05:30
Krish Dholakia
0aae5153b6
docs: Clarify Bedrock AgentCore documentation (#18603)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-01-03 16:06:07 +05:30
yuneng-jiang
921f3167a0
Merge pull request #18602 from BerriAI/litellm_ui_useful_links_2
[Fix] UI - Useful Links Remove Modal on Adding Links
2026-01-02 19:31:01 -08:00
yuneng-jiang
e6da33dc4a Remove modal in useful links 2026-01-02 19:22:56 -08:00
yuneng-jiang
dacfe153ba
Merge pull request #18601 from BerriAI/litellm_ui_test_coverage_xd
[Infra] UI - Adding Unit Tests to Increase Coverage
2026-01-02 18:56:45 -08:00
yuneng-jiang
b7aac24653
Merge pull request #18600 from BerriAI/litellm_ui_sso_refactor
[Feature] UI - SSO Settings Page
2026-01-02 18:52:01 -08:00
yuneng-jiang
f4c712506d Unit tests to increase test coverage 2026-01-02 18:49:01 -08:00
yuneng-jiang
470e4c26c3
Merge pull request #18593 from BerriAI/litellm_ui_sso_role_mapping
[Feature] UI - Allow Adding Role Mappings for SSO
2026-01-02 18:31:11 -08:00
yuneng-jiang
546fba9849 tests 2026-01-02 18:28:10 -08:00
yuneng-jiang
f16fb63434 New SSO Settings Page 2026-01-02 18:22:37 -08:00
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
101fa6bdc6 refactor: extract http request helper for mcp openapi tools 2026-01-03 09:07:59 +09:00
Yuta Saito
6168e500a8 fix: add checking path param 2026-01-03 08:57:54 +09:00
Alexsander Hamir
2983b556d3
Lazy load 9 heavy imports in litellm/utils.py (#18595) 2026-01-02 14:54:09 -08:00
yuneng-jiang
0f0da07661 fixing build 2026-01-02 14:00:55 -08:00
yuneng-jiang
0a2e241651 Allow adding role mapping in UI 2026-01-02 13:57:28 -08:00
Alexsander Hamir
3b1792d728
feat: lazy load heavy imports to reduce memory usage at import time (#18592)
- Lazy load remove_index_from_tool_calls via __getattr__
- Lazy load _service_logger module via __getattr__ in __init__.py
- Lazy load audio_utils.utils with module-level caching in utils.py
- Remove direct imports that trigger heavy module loading

These changes reduce import-time memory usage by deferring imports
until they are actually needed, while maintaining performance through
caching for subsequent accesses.
2026-01-02 13:51:28 -08:00
kevinpauer
705b54bf04
Feat/add watsonx fields (#18569) 2026-01-03 02:53:17 +05:30