Commit Graph
1859 Commits
Author SHA1 Message Date
Jugal D. BhattandGitHub d8525ecbfa Remove extra test file (#10889) 2025-05-16 18:34:22 -07:00
Jugal D. BhattandGitHub 44c100d05d [Feat] handle multi-pod deployment for SpendLogs Retention (#10895)
* handle multi-pod deployment

* fix utc and ruff errors

* add constants.py

* add lock duration acc to interval

* add lock duration on pod lock manager

* update tests to use redis

* update comments from review

* update config_Settings.md

* lint errors

* remove custom ttl setting

* add constants.py

* add constants.py

* add check for pod lock manager, and allow otherwise

* remove dup try except and move to finally

remove args
2025-05-16 18:18:51 -07:00
Ishaan JaffandGitHub bd1e0634bf [Feat] Add Lakera v2 Guardrail Support (#10880)
* feat: add types for lakera v2

* feat: add call v2 guard for lakera

* feat: add call v2 guard for lakera

* feat: add LAKERA_V2

* feat: add LAKERA_V2 params

* feat: add initialize_lakera_v2

* fix: lakera pii masking

* test: lakera pii masking

* fix: lakera pii masking with tracing

* fix: lakera pii masking with tracing

* fix: fix linting errors

* fix: lakera ai docs
2025-05-16 17:08:21 -07:00
tanjiroandGitHub dc8945cce8 key hash filter added (#10903) 2025-05-16 16:53:52 -07:00
Ishaan JaffandGitHub 1a7932a262 Feat: add guardrail tracing to OTEL, Arize phoenix (#10896)
* feat: add guardrail tracing to OTEL, Arize phoenix

* fix: code qa check

* test: trace guard on OTEL

* fix: linting
2025-05-16 13:38:11 -07:00
Ishaan JaffandGitHub 298912bd38 [UI] - Add Guardrail Tracing to LiteLLM SpendLogs (#10893)
* feat: trace guardrail SLP in spendLogs

* test: trace guardrail SLP in spendLogs

* add guardrail viewer

* checkpoint - working guardrail view on logs

* ui add guardrail view to SpendLogs

* test: fixes guardrails

* trace: fixes guardrails
2025-05-16 12:20:20 -07:00
Ishaan JaffandGitHub b9460dfe37 [Feat] Add Tracing for guardrails in StandardLoggingPayload, Langfuse (#10890)
* test:test_standard_logging_payload_includes_guardrail_information

* feat: add tracing for presidio pii masking

* feat: add tracing for guardrails on langfuse

* test: test_langfuse_trace_includes_guardrail_information

* feat: add tracing for guardrails on langfuse

* fix: working guardrail trace

* test: guardrail trace lands on langfuse

* fix: linting

* fix: code qa check

* test: fixes for presidio test

* test: fixes for presidio test

* test: guardrail trace lands on langfuse

* test: guardrail trace lands on langfuse

* test: guardrail trace lands on langfuse

* test: guardrail trace lands on langfuse
2025-05-16 10:47:12 -07:00
Krrish Dholakia cec4535cd8 fix: fix unit tests 2025-05-16 10:33:44 -07:00
f335bb91dd Model filter added on logs tab. (#10877) (#10891)
* model filter added

* Make status logic it's own helper + add a unit test in test_spend_management_endpoints

Co-authored-by: tanjiro <56165694+NANDINI-star@users.noreply.github.com>
2025-05-16 10:04:02 -07:00
Jugal D. BhattandGitHub d5d5166777 Feat log retention cleanup (#10872)
* Batch deletion with tasks

* reset utils

* change print to logger

* remove print for lint

* fix lint

* local testing

* remove constants.py var

* ruff fix

* type fix

* - make sure job doesn't get added if maximum_spend_logs_retention_period is not set
- enable user to override scheduler time
- Upper bound on while true

* update and fix test
2025-05-15 22:43:39 -07:00
Krish DholakiaandGitHub fdfef04d93 Gemini Multimodal Live API support (#10841)
* fix: initial commit

* refactor(gemini/realtime/transformation.py): initial instrumentation

* fix: fix default api base if not set

* feat(gemini/): passes initial user request to backend

* feat(realtime_streaming.py): support transforming message input before sending it

enables gemini realtime streaming to be sent in correct format

* feat: initial working commit of setup message being sent + working

* fix(gemini/): initial commit supporting realtime response transformation

* feat(gemini/realtime): transform session.created event correctly

* fix(realtime_streaming.py): more gemini/realtime response mapping - handle new message

* test(gemini/realtime/test_): add more unit tests

* feat(gemini/realtime): handles consecutive deltas

* feat(gemini/realtime): support openai 'response.text.done' event

* feat(gemini/realtime): add openai 'response.text.done' and 'response.content_part.done' event support

* fix(gemini/realtime): add openai 'response.done' event support

unified realtime api support

* fix: fix linting errors

* fix: fix linting error

* fix: fix linting error

* fix: handle infinite loop

* fix: fix linting error

* fix: fix recursive detector

* fix: fix file

* fix: fix linting error

* fix: fix linting error
2025-05-15 22:39:09 -07:00
93639df4c3 Feat/support anonymize in aim guardrail (#10757)
* Enable update/delete org members on UI  (#8560)

* feat(organization_endpoints.py): expose new `/organization/delete` endpoint. Cascade org deletion to member, teams and keys

Ensures any org deletion is handled correctly

* test(test_organizations.py): add simple test to ensure org deletion works

* feat(organization_endpoints.py): expose /organization/update endpoint, and define response models for org delete + update

* fix(organizations.tsx): support org delete on UI + move org/delete endpoint to use DELETE

* feat(organization_endpoints.py): support `/organization/member_update` endpoint

Allow admin to update member's role within org

* feat(organization_endpoints.py): support deleting member from org

* test(test_organizations.py): add e2e test to ensure org member flow works

* fix(organization_endpoints.py): fix code qa check

* fix(schema.prisma): don't introduce ondelete:cascade - breaking change

* docs(organization_endpoints.py): document missing params

* support anonymize and deanonymize

* use new response schema

* don't use detected because action already means there are detections

* log to debug

* CR fixes

* lint

* add tests

* use single quotes in deanonymiztion

* remove engage action case

* set max entities to 100 to prevent memory leak

* add test case for de-anonymization of llm response

---------

Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2025-05-15 22:18:58 -07:00
Krrish Dholakia b54e2ae98b test: update unit test 2025-05-15 22:18:15 -07:00
Damian GleumesandGitHub 384a7ba94d [Feat]: Configure LiteLLM to Parse User Headers from Open Web UI (#9802)
* add user_header_name

* docs: add per-user tracking to Open WebUI with LiteLLM doc

* docs: standardize "OpenWeb UI" spelling across openweb_ui.md

* docs: improve wording for openweb_ui guide

* fix end_user_id not being set

- move user header parsing to add_litellm_data_to_request
- also set  user_api_key_dict.end_user_id from user header
2025-05-15 22:01:12 -07:00
Krish DholakiaandGitHub 32478de7a9 fix(proxy/_types.py): add missing comma for /v2/rerank (#10861)
* fix(proxy/_types.py): add missing comma for `/v2/rerank`

Enables non admins to access `/v2/rerank` endpoint

* fix(proxy_track_cost_callback.py): add patch to handle scenario where both 'litellm_metadata' and 'metadata' exist
2025-05-15 21:37:46 -07:00
Ishaan JaffandGitHub dc16e47df6 [UI] Allow adding Bedrock, Presidio, Lakera, AIM guardrails on UI (#10874)
* ui fix bedrock guard

* polish: logo should appear after selecting provider

* fix ui config bedrock

* fix: refactor - use specific configs per provider

* fix: refactor - use specific configs per provider

* feat: ui, show provider specific params for guardrails

* fix: updated type of LiteLLM params for guardrails

* fix: updated type of LiteLLM params for guardrails

* ui, use endpoint for adding presidio, bedrock guardrails

* fix: linting error

* add llama guard and secret detector on UI

* add aim on ui

* allow adding lakera AI on litellm ui

* fix: fixes for params to init guardrails

* test: test_guardrail_info_response

* test: test_initialize_presidio_guardrail

* fix: init guardrails

* fix: init guardrails

* add showSearch

* working bedrock guard
2025-05-15 21:22:56 -07:00
Krrish Dholakia c6d36e8912 test: fix test 2025-05-15 15:40:00 -07:00
Ishaan JaffandGitHub 263f447795 [CI/CD] Test: fix mapped tests (#10870)
* test: fix mapped tests

* test: fix mapped tests

* test: fix mapped tests

* test: fix mapped tests
2025-05-15 15:36:15 -07:00
Ishaan JaffandGitHub 3d37cc68f6 [Feat - Guardrails] Expose /apply_guardrail endpoint for directly calling guardrail (#10867)
* refactor: add types for mask pii request/response

* feat: add mask pii hook for guardrails

* feat: rename to apply_guardrail

* test: test_presidio_apply_guardrail

* fix: code QA

* fix: linting error

* feat: allow non-admins to access apply_guardrail routes
2025-05-15 14:52:24 -07:00
Ishaan JaffandGitHub faed9860c0 [Refactor] Move enterprise_routes within litellm_enterprise (#10860)
* fix: move enterprise routes to litellm_enterprise

* refactor: move enterprise routes to litellm_enterprise

* fix: litellm_enterprise routes

* fix test litellm on github workflow
2025-05-15 10:34:26 -07:00
Ishaan JaffandGitHub 42e6e664b2 [Refactor] Make Pagerduty a free feature (#10857)
* refactor: make pagerduty free

* refactor: make pagerduty free

* fix: pagerduty loc

* fix: linting error
2025-05-15 10:12:06 -07:00
Jugal D. BhattandGitHub 16280d9fa9 added fix to resolve delete API (#10845)
* added fix to resolve delete API

* add get requests to ignore model and add test cases
2025-05-15 08:31:37 -07:00
Anibal AnguloandGitHub 0434ca1781 Updated bedrock invoke transform for mistral to support pixtral models (#10439) 2025-05-14 23:08:37 -07:00
Marc AbramowitzandGitHub 322b67833b Add models import command (#10581)
* Add --only-models-matching-regex option

to `models import` which only processes models where
`litelllm_params.model` matches the regex

* Add test_models_import_only_models_matching_regex

* Print each model we're importing

* Add --only-access-groups-matching-regex option

to `models import` which only processes models where at least one item
in `model_info.access_groups` matches the regex. Add a unit test.

* Add `models import` examples to README.md

Add `models import` examples to proxy/client/cli/README.md

* ruff format litellm/proxy/client/cli/commands/models.py

* Make `models import` display tabular output

* models import refactoring

* Fix failing tests in test_models_commands.py

* Refactor import_models to make it shorter and more readable

* Extract from `import_models` a function called `get_model_list_from_yaml_file`

* Fix mypy error

* Add more specific typing

for better understandability and Intellisense

* More import_models refactoring

* More refactoring

* More refactoring

* Write unit tests for format_iso_datetime_str

* Add more unit tests

* ruff format tests/litellm/proxy/client/cli/test_models_commands.py

* ruff format litellm/proxy/client/cli/commands/models.py

* Make test_format_timestamp use UTC time
2025-05-14 23:05:07 -07:00
Camille FarineauandGitHub b88e56ebde Fix/issue 10113 embeddings use non default tokenizer (#10629)
* fix(embeddings): use non default tokenizer when passing list of lists of tokens (int)

* feat(embeddings): allow for passthrough of list of lists of tokens to hosted_vllm models

* Revert "fix(embeddings): use non default tokenizer when passing list of lists of tokens (int)"

This reverts commit a48acd95f860c4fc85853e20668eabffff07cae7.

* refactor(embeddings): use a list to verify if provider accept as input a list of tokens

* fix(embeddings): verify the model name before validating if provider accept a arrays of tokens as input

When passing a list of tokens as input, verify the provider of the model by going through the list of models (`llm_model_list`). First, it check for model name then get the provider and verify if it accept or not arrays of tokens. If yes, then pass, else decode.
Previously, it was verifying provider and model name at the same time resulting in decoding even if the current model checked was not the target one (looping onto `llm_model_list`)

* test(embedding): add unit test to bypass decode for some providers with input as array of tokens

Ref: https://github.com/BerriAI/litellm/issues/10113
2025-05-14 22:55:49 -07:00
Krish DholakiaandGitHub 5146b2903f Anthropic unified web search + tool cost tracking support (#10846)
* fix(duration_parser.py): support `mo` unit

* test(test_key_management_endpoints.py): add test confirming generate_key_helper_fn uses predictable budgets

Closes https://github.com/BerriAI/litellm/issues/10800

* fix(anthropic/chat/transformation.py): add tool use cost tracking

* fix(anthropic/): refactor how hosted tool usage tracking is done

keep it separate from prompt / completion token details

* fix(anthropic/): add web search tool cost tracking

accurate cost tracking

* feat(anthropic/chat/transformation.py): map openai 'web_search_options' param to anthropic hosted tool

Allows calling anthropic web search in same format as openai

* feat(anthropic/chat/transformation.py): support unified anthropic 'web_search_options' param

Allows calling anthropic's web search tool in the openai format

* feat(anthropic/chat/transformation.py): map openai 'search_context_size' to anthropic 'max_uses' param

Translate search effort across both providers

* fix: mark web_search_options param as supported by openai + azure

* fix: fix linting error

* fix: fix linting errors

* fix: fix linting error

* fix: check if usage hasattr

* fix: pass web search options param
2025-05-14 22:41:12 -07:00
Dima-MediatorandGitHub 11740ce144 Capture Gemini reasoning tokens usage in streaming mode - fix (#10789) 2025-05-14 22:23:54 -07:00
Ishaan Jaff 75e4d27885 test: test_embedding_performance 2025-05-14 21:31:07 -07:00
Jugal D. BhattandGitHub ca4390a166 fix failing test typo (#10843) 2025-05-14 20:46:52 -07:00
Ishaan Jaff a5a4453c77 test: fix groq/gemma2-9b-it 2025-05-14 19:24:20 -07:00
Ishaan Jaff 2ebd750289 test: test supports tool I 2025-05-14 18:49:27 -07:00
Ishaan Jaff abe7b71e6a Revert "Revert "[Fix] Allow overriding all constants using a .env variable (#10803)""
This reverts commit cf4b2ebda4.
2025-05-14 18:27:43 -07:00
Jugal D. BhattandGitHub a754a25828 Feat add retention config (#10815)
* add function to check config flag

* added unit tests

* convert to seconds support

* added in settings.md

* Updated config_settings.md

* remove extra point

* change config var

* resolve conflict
2025-05-14 18:16:25 -07:00
Ishaan JaffandGitHub 526e6aaaca patch: validate_team_org_change (#10835)
* fix: validate_team_org_change

* test: test_validate_team_org_change_same_org_id
2025-05-14 17:50:41 -07:00
Ishaan JaffandGitHub 2a994d7016 [Feat] Presidio Improvements - Allow adding presidio api base on UI, Test presidio on Test Key, fixes for running presidio hook (#10840)
* feat: add GuardrailProviderSpecificParams

* feat: add add apply_guardrail helper for presidio

* ui cleanup

* fixes pii config on ui

* fixes for adding presidio pii

* refactor: InitializeGuardrails

* feat: init guardrails from DB

* allow running guardrails from test key pg

* fix: running a request with guardrails on UI

* fix: types/guardrails.py

* test: test_presidio_pre_call_hook_with_different_call_types

* test: test_initialize_presidio_guardrail

* test: fix custom guardrail tests
2025-05-14 17:41:33 -07:00
Jugal D. BhattandGitHub 468b881ec5 add support to parse metadata (#10832)
* add support to parse metadata

* add safe loads

* remove depth checks
2025-05-14 12:03:49 -07:00
Krish DholakiaandGitHub 340a0453d3 Migrate cohere to /v2/embed - adds support for output_dimensions param (#10809)
* feat(cohere/embed): v2 embed api support

adds output_dimensions param support

* fix(cohere/embed): migrate to v2 embedding

Adds output dimension support

* fix: maintain /v1/embedding compatibility for bedrock cohere

Bedrock cohere is still using /v1 endpoints

* fix: fix linting error

* fix: fix passing extra headers

* test: update tests
2025-05-13 23:06:56 -07:00
Krish DholakiaandGitHub a421316e56 fix(litellm_logging.py): log custom headers in requester metadata (#10818)
* fix(litellm_logging.py): log custom headers in requester metadata

allows passing along custom headers from client to logging integration - e.g. `x-correlation-id`

* refactor: move enterprise code out of OSS package

work towards simplified CE version of docker image

* test: update test

* fix: fix linting error
2025-05-13 23:04:37 -07:00
Ishaan Jaff cf4b2ebda4 Revert "[Fix] Allow overriding all constants using a .env variable (#10803)"
This reverts commit de901bbf24.
2025-05-13 21:27:44 -07:00
Andy DaiandGitHub cab57b2d2f Fix: Separate Sync/Async Azure Client Cache to Prevent Type Mismatches (#10781)
* fix: Fix issues when mix sync and async call in AzureOpen

* misc: Keep original format

* misc: Add back missing file
2025-05-13 21:13:46 -07:00
Ishaan Jaff 33f11f1479 fix arize config tests 2025-05-13 20:21:14 -07:00
Ishaan JaffandGitHub 5e7869a778 [Bedrock] Fixes to only allow accepted fields for tool json schema (#10062)
* add test_function_calling_with_tool_response to base llm tests

* run test suite for nova

* update test_function_calling_with_tool_response

* allowed ToolJsonSchemaBlock keys

* fix ToolJsonSchemaBlock

* add back pytest fixture

* test: test_prompt_caching
2025-05-13 19:49:30 -07:00
Ishaan JaffandGitHub 8142c20c98 [Feat] Allow specifying PII Entities Config when using Presidio Guardrails (#10810)
* refactor: use analyze_text, anonymize_text

* feat: allow defining pii_entities_config for presidio

* feat: use entities config for presidio analyze request

* feat: add test_presidio_pii.py

* testing: add guardrails testing job

* feat: allow blocking specific entities pii

* test: use 1 file for presidio guard tests

* fix: presidio pii tests

* test: presidio blocked entity

* clean up docs

* docs presidio pii parsing

* fix: raise_exception_if_blocked_entities_detected

* fix: linting errors
2025-05-13 19:48:56 -07:00
Ishaan Jaff c5277b6714 test fixes: TestArizePhoenixConfig 2025-05-13 17:27:05 -07:00
Ishaan JaffandGitHub 5fbcd22604 [Fix] Allow overriding all constants using a .env variable (#10803)
* fix: bump: DEFAULT_MAX_RECURSE_DEPTH

* fix: bump: DEFAULT_MAX_RECURSE_DEPTH

* test: test_vertex_ai_complex_response_schema

* fix: allow all constants to be overriden

* fix: allow all numeric constants to be overriden with env vars

* fix: remove dup DEFAULT_MAX_TOKENS in constants.py

* document all constants env vars

* docs - DEFAULT_PROMPT_INJECTION_SIMILARITY_THRESHOLD
2025-05-13 16:10:55 -07:00
Ishaan JaffandGitHub 3bd2c91164 [Fix] Maximum Vertex Recursion Depth Reached when transforming response_format (#10798)
* fix: bump: DEFAULT_MAX_RECURSE_DEPTH

* fix: bump: DEFAULT_MAX_RECURSE_DEPTH

* test: test_vertex_ai_complex_response_schema
2025-05-13 14:29:23 -07:00
Dat Daryl NgoandGitHub f1136fd217 fix: URL encode OTEL_EXPORTER_OTLP_TRACES_HEADERS for Phoenix Integration (#10654)
* fix: URL encode OTEL_EXPORTER_OTLP_TRACES_HEADERS for Arize Phoenix integration

- Add URL encoding for Bearer token in authorization header
- Follow OpenTelemetry Protocol Exporter specification
- Fix header format validation error in Phoenix integration

* add mock test for arize phoenix
2025-05-13 09:45:39 -07:00
Ishaan JaffandGitHub 3130c4f8f9 [Refactor] Move LLM Guard, Secret Detection to Enterprise Pip packagea (#10782)
* refactor: move guardrails to pip

* refactor: move guardrails to pip

* testing fix: move guardrails to pip

* git commit setup_litellm_enterprise_pip
2025-05-13 09:42:22 -07:00
Krish DholakiaandGitHub ff68cbda8e Fix azure dall e 3 call with custom model name + Handle Bearer $LITELLM_API_KEY in x-litellm-api-key custom header (#10776)
* fix(main.py): use base model instead of user model if given

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

* feat(azure/image_generation/__init__.py): make azure image gen check more robust

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

* fix(user_api_key_auth.py): support bearer token auth for `x-litellm-api-key` header

Fixes earlier regression on vertex ai passthrough auth

* fix(user_api_key_auth.py): refactor get api key into separate function

enables easier testing

* fix: cleanup

* fix: fix linting error

* fix: cleanup

* test: update tests
2025-05-12 22:49:35 -07:00
Krish DholakiaandGitHub 53f6514f12 Support Anthropic web search tool + Add more google finish reason mapping (#10785)
* fix(vertex_and_google_ai_studio_gemini.py): handle additional google finish reasons

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

* test: add more unit tests

* fix(anthropic/chat/transformation.py): support anthropic web search

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

* fix(anthropic/chat/transformation.py): add anthropic web search 'max uses' param support

* docs(anthropic.md): add doc for web search tool calling

Closes https://github.com/BerriAI/litellm/issues/10664

* build(model_prices_and_context_window.json): add search tool pricing for anthropic

* fix: suppress linting error

* test: update tests

* fix: fix ruff check
2025-05-12 22:45:51 -07:00