Commit Graph

27 Commits

Author SHA1 Message Date
yuneng-jiang 9bb292f478 V2 login route 2025-12-03 12:41:45 -08:00
Ishaan Jaff c7cf18cf67 [Feat] Prompt Management - Allow storing prompt version in DB (#16848)
* test_dotprompt_auto_detection_with_model_only

* fix _auto_detect_prompt_management_logger

* test_dotprompt_with_prompt_version

* add v1, v2 tests

* add _compile_prompt_helper

* fix _compile_prompt_helper

* test_dotprompt_with_prompt_version

* test_dotprompt_with_prompt_version, test_get_prompt_with_version

* add version in schema

* feat add _get_prompt_spec_for_db_prompt

* add _get_prompt_spec_for_db_prompt

* feat add _get_prompt_spec_for_db_prompt

* update prompt table

* add version in prompt DB

* test_get_prompt_spec_for_db_prompt_with_versions
2025-11-19 13:19:56 -08:00
Alexsander Hamir c7847125c2 [Perf] Embeddings: Use router's O(1) lookup and shared sessions (#16344)
* Refactor proxy embeddings to use shared processor

- allow ProxyBaseLLMRequestProcessing to accept the aembedding route so embeddings requests reuse the base pipeline hooks

- route embeddings requests through base_process_llm_request, sharing logging, hook execution, retries, and header handling with chat/responses

- tighten token array decoding logic by using router deployment lookups and the unified error handler

* Fix: Correctly process embedding requests with token arrays

The `test_embedding_input_array_of_tokens` test was failing due to a regression that caused embedding requests with token arrays to be processed incorrectly. This prevented the `aembedding` function from being called as expected.

This was caused by a combination of three distinct issues:

1.  In `litellm/proxy/common_request_processing.py`, the `function_setup` utility was called with `aembedding` as the `original_function` for embedding routes. This has been corrected to `embedding` to ensure proper request setup.

2.  In `litellm/proxy/proxy_server.py`, a `TypeError` occurred because the `get_deployment` method was called with the `model_name` keyword argument instead of the expected `model_id`. This has been corrected. Additionally, the check for token arrays was improved to validate that all elements in the input subarray are integers.

3.  In `litellm/proxy/litellm_pre_call_utils.py`, the check for the `enforced_params` enterprise feature was too strict. It blocked valid requests even when the `enforced_params` list was empty. The condition has been adjusted to trigger the check only for non-empty lists.

Finally, the `test_embedding_input_array_of_tokens` assertion was updated to be more robust. The previous `assert_called_once_with` was overly strict, causing failures when unrelated internal parameters were added to the function call. The test now first asserts that `aembedding` is called and then separately verifies the `model` and `input` arguments. This makes the test more resilient to future changes without sacrificing its ability to catch regressions.

* test: align proxy embedding assertions

Update the embedding proxy test to match the new request pipeline: keep the data the proxy builds, expect the extra control kwargs, let the post-call hook return the actual response, and assert the normalized 'embeddings' hook type. This proves the refactor still forwards metadata and returns the mocked payload.

* Update proxy exception test

The proxy now forwards additional kwargs (request_timeout, litellm_call_id, litellm_logging_obj) to llm_router.aembedding. The test needs to accept these to match the real call signature and keep validating the error path instead of the kwargs list.

* testing: unsure of this change

I don't remember why I changed this, will revert and see if any tests fail since the manual test isn't failing without it.

* fix: remove unrelated change

This change was not related to the embeddings refactor and actually belonged to a different branch.
2025-11-14 09:21:45 -08:00
yuneng-jiang 720ba865fb [Infra] Litellm Backend SSO Changes (#16029)
* SSO Backend changes

* Encrypt and Decrypt, load into os env

* Linting and addressing comments
2025-10-30 14:32:08 -07:00
Ishaan Jaff 527c8f59fa [Feat] Tag Management - Add support for setting tag based budgets (#15433)
* feat: add LiteLLM_TagTable

* fix: use new table for tag management

* fix - allow setting budgets for tags

* working tag creation

* fix schema.prisma

* add tag info

* ui fixes

* ui fix tag info

* TAG_CACHE_IN_MEMORY_TTL_SECONDS

* add Litellm_EntityType

* fix get_aggregated_db_spend_update_transactions

* fix: _update_entity_spend_in_db

* fix _tag_max_budget_check

* add tag budget check

* add tag_list_transactions

* test_get_tag_objects_batch

* test_update_tag_db_without_prisma_client

* fix get_tags_from_request_body

* get_tags_from_request_body

* fix get_tags_from_request_body

* fix spend tracking utils

* get_tags_from_request_body

* test_get_tags_from_request_body_with_metadata_tags

* feat: add _update_tag_cache spend tracking

* fix _PROXY_track_cost_callback

* test_tag_cache_update_multiple_tags

* fix tag info

* docs fix

* docs tag budgets

* doc fix

* docs fix

* fix tag budget

* docs tag budgets

* docs fix

* ruff fix
2025-10-10 19:24:50 -07:00
Achintya Rajan 169c1f0f21 moved test to test_proxy_server 2025-10-08 19:24:16 -07:00
Ishaan Jaff 1d468a59f3 [MCP Gateway] Fine-grained Database Object Storage Control (#15255)
* add supported_db_objects

* add _should_load_db_object

* add docs on storing MCP objects in DB

* test_should_load_db_object_with_supported_db_objects

* type fix
2025-10-06 19:31:44 -07:00
Ishaan Jaff 388761f52d [Fix] LiteLLM UI - Ensure OTEL settings are saved in DB after set on UI (#15118)
* fix: fix _add_callback_from_db_to_in_memory_litellm_callbacks

* test_add_callback_from_db_to_in_memory_litellm_callbacks

* fix otel

* fix: fix _add_callback_from_db_to_in_memory_litellm_callbacks
2025-10-01 15:33:22 -07:00
Ishaan Jaff 69a464fc97 [Fix Security] Ensure OCI secret fields not shared on /models and /v1/models endpoints (#15085)
* fix: remove_sensitive_info_from_deployment

* fix: remove_sensitive_info_from_deployment

* test_model_info_v1_oci_secrets_not_leaked
2025-09-30 14:55:54 -07:00
Krrish Dholakia b23e35f75e test: update tests 2025-08-23 12:09:19 -07:00
Krrish Dholakia e5c3e006c2 fix(proxy_server.py): fix merge config + db router settings logic 2025-08-20 16:33:31 -07:00
Jugal D. Bhatt 67833590d6 [Proxy changes] Litellm add model price reload schedule for multi-pod (#13470)
* added mcp guardrails doc in mcp.md

* add button to reload models

* Added button changes

* added button for scheduling reload

* add multi pod support to reloading the model price json

* fix ruff
2025-08-09 16:12:13 -07:00
Jugal D. Bhatt 1270df08a4 [Proxy + UI] Litellm add reload model api and button (#13464)
* added mcp guardrails doc in mcp.md

* add button to reload models

* Added button changes

* remove the model_reload
2025-08-09 13:52:56 -07:00
Jugal D. Bhatt 10a1fe21c5 [LLM Translation] Litellm azure o series drop params (#13353)
* added route check

* fix ruff

* Added support for dropping o_series params

* Added ruff fix

* fix tests
2025-08-09 13:52:45 -07:00
Krish Dholakia 0da25fadc0 Exclude none fields on /chat/completion - fixes n8n bug + Allow calling /v1/models when end user over budget (#13320)
* fix(proxy_server.py): exclude none fields before returning

Fixes https://github.com/BerriAI/litellm/issues/13055

* test: add unit tests

* feat(auth_checks.py): allow info routes to work when end user over budget

Fixes https://github.com/BerriAI/litellm/issues/13286
2025-08-05 21:39:46 -07:00
Krish Dholakia 4b50566d6d [FEAT] Model-Guardrails: Add on UI (#13006)
* feat(proxy_server.py): working guardrails on streaming output

ensures guardrail actually raises an error if flagged during streaming output

* test: add unit tests

* feat(advanced_settings.tsx): add guardrails option as ui component on model add

enables setting guardrails on model add

* feat(add_model_tab.tsx): fix add model form

* feat(model_info_view.tsx): support adding guardrails on model update

* fix(add_model_tab.tsx/): working health check when guardrails selected

* fix(proxy_server.py): fix yield
2025-07-26 11:42:03 -07:00
Krish Dholakia 0c461b2719 Litellm fix proxy unit testing p2 (#12779)
* test: update tests

* test: update test

* test: update unit tests
2025-07-19 16:35:05 -07:00
Krish Dholakia d202ce229b Prevent writing default user setting updates to yaml (error in non-root env) + Use central team member budget when max_budget_in_team set on UI (#12533)
* fix(proxy_setting_endpoints.py): require store model in db is enabled for setting user default settings

* test(test_proxy_server.py): update test

* fix(reset_budget_job.py): initial commit adding reset budget logic for team members

* test: update unit testing

* test(test_proxy_budget_reset.py): validate team member budget was reset

* test(test_reset_budget_job.py): update unit tests

* test: update tests
2025-07-12 10:13:07 -07:00
Ishaan Jaff a0d6900223 [Bug Fix] fix parsing environment_variables from config.yaml (arize logger integration fix) (#12482)
* fix parsing environment_variables from config.yaml

* add tests
2025-07-10 09:15:07 -07:00
Ishaan Jaff 17ea770ab5 [Feat] SSO - Allow users to run a custom sso login handler (#12465)
* fix return_ui_sso_redirect_response_after_sign_in

* add CustomSSOLoginHandler

* add handle_custom_ui_sso_sign_in

* fix handle_custom_ui_sso_sign_in

* fixes for /sso/key/generate

* add test_handle_custom_ui_sso_sign_in_success

* fixed for loading config

* add example custom handler

* test_custom_ui_sso_sign_in_handler_config_loading

* docs - custom sso

* move to enterprise folder

* EnterpriseCustomSSOHandler

* handle_custom_ui_sso_sign_in

* docs custom sso

* docs sso

* docs custom sso

* get_redirect_response_from_openid

* fix mock tests
2025-07-09 16:36:30 -07:00
Ishaan Jaff d720b3d369 [Bug fix] Multiple API Keys Created on Startup When max_budget is Enabled (#12436)
* fix _add_proxy_budget_to_db

* fix if table_name is not None and table_name == "user":

* revert earlier change

* test_add_proxy_budget_to_db_only_creates_user_no_keys

* lint fix
2025-07-08 16:46:05 -07:00
Krish Dholakia ee9dd158dd Fix - handle empty config.yaml + Fix gemini /models - replace models/ as expected, instead of using 'strip' (#12189)
* fix(proxy_server.py): handle empty config yaml

Fixes https://github.com/BerriAI/litellm/issues/12163

* fix(gemini/common_utils.py): replace models/ as expected, instead of using 'strip'

Fixes https://github.com/BerriAI/litellm/issues/12160

* fix(anthropic/experimental_pass_through/messages/transformation.py): check for env var when selecting api key

* docs(config_settings.md): add api key to docs
2025-06-30 21:56:03 -07:00
Krish Dholakia cec7e4941a UI QA Fixes - prevent team model reset on model add + return team-only models on /v2/model/info + render team member budget correctly (#12144)
* fix(team_endpoints.py): prevent overwriting current list of team models on new model add

* fix(networking.tsx): fix default proxy base url

* fix(proxy_server.py): include team only models when retrieving all deployments on `/v2/model/info` helper util

ensures team only models are shown to user

* fix(router.py): check model name by team public model name when team id given

Fixes issue where team member could not see team only models when clicking into that team on `Models + Endpoints`

* fix(team_member_view.tsx): fix rendering team member budget, when budget is set

* test: update tests

* test: update unit test
2025-06-28 22:04:49 -07:00
Krish Dholakia e2f6fb2d7c Managed Files + Batches - filter deployments to only those where file was written + save all model file id mappings in DB (prev just 1st one) (#12048)
* test(test_router.py): initial unit test confirming router.afile_content uses dynamic api key / api base

* fix(managed_files.py): filter deployments for only those within file id mapping

ensure call works - only route to models where the file was written

* fix(proxy_server.py): fix loading in model ids from config, if config id is int

* fix(router.py): return all model file id mappings on create_file

if multiple deployments - this ensures all the file id mappings are bubbled up

Fixes issue when trying to use loadbalanced deployments - only 1 file id mapping was being stored
2025-06-25 21:27:06 -07:00
Krish Dholakia 7f3d8bb9c5 Management Fixes - don't apply default internal user settings to admins + preserve all model access for teams with empty model list, when team model added + /v2/model/info fixes (#11957)
* fix(internal_user_endpoints.py): don't apply default internal user params if role is admin

prevent internal user restrictions from being applied to admin

* fix(proxy_server.py): fix model info v2 endpoint check - handle user_id being none

* fix(team_endpoints.py): ensure team doesn't lose all model access if set as empty string and new team model added

* fix(proxy_server.py): ensure model with team id is only added as valid for team which has that id
2025-06-21 20:33:10 -07:00
Krish Dholakia 2404d3fb1b Show user all models they can call (Across teams) on UI (#11948)
* fix(proxy_cli.py): check for module not found error on proxy import

Fixes https://github.com/BerriAI/litellm/issues/11836

* feat(proxy_server.py): utility function to get all models across all teams user is in

Allows user to see all team models on UI

* feat(proxy_server.py): return models accessible via team id's in `/v2/model/info`

Allows UI to tell user which team they can use to access model

* feat(columsn.tsx): initial PR to add 'accessible via Team ID's on model hub

allows user to know what teams they can access a model through

* Revert "feat(columsn.tsx): initial PR to add 'accessible via Team ID's on model hub"

This reverts commit f844c79383ec6739ed712f59e33a524a26b3d35a.

* fix(proxy_server.py): backend model info endpoint improvements

* UI Improvements for Default User access (#11952)

* feat(ui/): add a 'current team' and 'view' filters to the models page

allow user to see what all models they have access to within a specific team

* feat: working ui for seeing models in teams

* fix(model_dashboard.tsx): make current team filter more prominent

* style(model_dashboard.tsx): add a helpful note telling user how to create a model for the team they've selected

* style(model_dashboard.tsx): only show helpful note when current view is team, not for global

* fix(team_dropdown.tsx): allow searching by team id on create key modal

* feat(create_key_button.tsx): add helpful message when team selection is required

* fix: fix linting checks

* fix: fix ui linting error

* docs(team_endpoints.py): document new param
2025-06-21 15:29:25 -07:00
Krish Dholakia ef42461c1e Litellm fix GitHub action testing (#11163)
* test: add __init__.py files

* refactor: rename test folder to avoid naming conflict

* test: update workflows

* test: update tests

* test: update imports

* test: update tests

* test: remove unused import

* ci(test-litellm.yml): add pytest retry to github workflow

* test: fix test
2025-05-26 14:41:42 -07:00