Commit Graph

62 Commits

Author SHA1 Message Date
yuneng-jiang dbe6f66baf updating promethus tests 2026-01-22 11:01:01 -08:00
yuneng-jiang f92f231954 Merge remote-tracking branch 'origin' into litellm_user_promethus_metrics 2026-01-13 16:27:08 -08:00
Sameer Kankute a727aa9980 Merge pull request #18340 from Point72/ephrimstanley/fix-batch
Fix batch deletion and retrieve
2026-01-13 08:13:43 +05:30
Ishaan Jaffer 69aaad5e69 Revert "added extraction of top level metadata for custom lables in prometheus callbacks (#18087)"
This reverts commit 14a4a9c031.
2026-01-10 14:00:54 -08:00
yuneng-jiang 1d06cb90e2 Fixing test 2026-01-09 11:51:07 -08:00
Sameer Kankute 386ea1354a fix: async def test_bedrock_apply_guardrail_blocked() 2026-01-06 14:15:06 +05:30
Ephrim Stanley 103633c794 Fix linter errors: remove unused imports and variables 2025-12-23 12:59:22 -05:00
Ephrim Stanley 479e40672e Add end to end integration tests for batches 2025-12-23 12:55:09 -05:00
Shivam Rawat 14a4a9c031 added extraction of top level metadata for custom lables in prometheus callbacks (#18087) 2025-12-17 11:17:12 +05:30
Vinnie Giarrusso 78012ad9a9 fix(prometheus): add 'exception_status' to prometheus logger (#17847)
* fix(prometheus): add 'exception_status' to prometheus logger

* use existing prometheuslogger

* remove unneeded test
2025-12-12 03:57:46 -08:00
Alexsander Hamir 655e04f16c Fix: apply_guardrail method and improve test isolation (#17555)
* Fix Bedrock guardrail apply_guardrail method and test mocks

Fixed 4 failing tests in the guardrail test suite:

1. BedrockGuardrail.apply_guardrail now returns original texts when guardrail
   allows content but doesn't provide output/outputs fields. Previously returned
   empty list, causing test_bedrock_apply_guardrail_success to fail.

2. Updated test mocks to use correct Bedrock API response format:
   - Changed from 'content' field to 'output' field
   - Fixed nested structure from {'text': {'text': '...'}} to {'text': '...'}
   - Added missing 'output' field in filter test

3. Fixed endpoint test mocks to return GenericGuardrailAPIInputs format:
   - Changed from tuple (List[str], Optional[List[str]]) to dict {'texts': [...]}
   - Updated method call assertions to use 'inputs' parameter correctly

All 12 guardrail tests now pass successfully.

* fix: remove python3-dev from Dockerfile.build_from_pip to avoid Python version conflict

The base image cgr.dev/chainguard/python:latest-dev already includes Python 3.14
and its development tools. Installing python3-dev pulls Python 3.13 packages
which conflict with the existing Python 3.14 installation, causing file
ownership errors during apk install.

* fix: disable callbacks in vertex fine-tuning tests to prevent Datadog logging interference

The test was failing because Datadog logging was making an HTTP POST request
that was being caught by the mock, causing assert_called_once() to fail.
By disabling callbacks during the test, we prevent Datadog from making any
HTTP calls, allowing the mock to only see the Vertex AI API call.

* fix: ensure test isolation in test_logging_non_streaming_request

Add proper cleanup to restore original litellm.callbacks after test execution.
This prevents test interference when running as part of a larger test suite,
where global state pollution was causing async_log_success_event to be
called multiple times instead of once.

Fixes test failure where the test expected async_log_success_event to be
called once but was being called twice due to callbacks from previous tests
not being cleaned up.
2025-12-05 12:59:35 -08:00
Krish Dholakia 32013f63a0 Guardrail API - support tool call checks on OpenAI /chat/completions, OpenAI /responses, Anthropic /v1/messages (#17459)
* fix(unified_guardrail.py): correctly map a v1/messages call to the anthropic unified guardrail

* fix: add more rigorous call type checks

* fix(anthropic_endpoints/endpoints.py): initialize logging object at the beginning of endpoint

ensures call id + trace id are emitted to guardrail api

* feat(anthropic/chat/guardrail_translation): support streaming guardrails

sample on every 5 chunks

* fix(openai/chat/guardrail_translation): support openai streaming guardrails

* fix: initial commit fixing output guardrails for responses api

* feat(openai/responses/guardrail_translation): handler.py - fix output checks on responses api

* fix(openai/responses/guardrail_translation/handler.py): ensure responses api guardrails work on streaming

* test: update tests

* test: update tests

* fix: support multiple kinds of input to the guardrail api

* feat(guardrail_translation/handler.py): support extracting tool calls from openai chat completions for guardrail api's

* feat(generic_guardrail_api.py): support extracting + returning modified tool calls on generic_guardrails_api

allows guardrail api to analyze tool call being sent to provider - to run any analysis on it

* fix(guardrails.py): support anthropic /v1/messages tool calls

* feat(responses_api/): extract tool calls for guardrail processing

* docs(generic_guardrail_api.md): document tools param support

* docs: generic_guardrail_api.md

improve documentation
2025-12-03 21:20:39 -08:00
Krish Dholakia 8edcc4ecc3 Guardrails API - add streaming support (#17400)
* fix(initial-commit): adding a way to get the right response type based on the api route

* feat(unified_guardrail.py): support streaming guardrails

* test: update tests

* fix: fix linting errors

* test: update tests
2025-12-02 22:52:09 -08:00
YutaSaito da5b81c1ff feat: add experimental latest-user filtering for Bedrock (#17282)
* feat: add experimental latest-user filtering for Bedrock

* doc: add experimental bedrock latest-message flag
2025-12-01 20:02:28 -08:00
Sameer Kankute 7cebc151b0 Add managed files support for responses API (#16733)
* Fix responses api with managed files

* fix litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py mypy

* fix litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py mypy

* fix mypy errors
2025-11-17 18:41:26 -08:00
Krish Dholakia 586f126395 Prometheus - make OSS (#16689)
* refactor: remove enterprise license from prometheus metrics

* refactor: complete refactoring imports

* refactor: complete prometheus refactoring

* bump: version 1.80.0 → 1.80.1

* bump: version 1.80.1 → 1.80.2

* build: update litellm lock file

* docs(enterprise.md): cleanup enterprise docs

* docs: more docs cleanup

* docs: doc cleanup

* fix: fix imports

* fix: fix linting error
2025-11-15 11:06:34 -08:00
Sameer Kankute bb86c94df4 Add Prometheus metric to track callback logging failures in S3 (#16209)
* Add v1 cut of container api

* fix lint errors

* Add proxy support to container apis & logging support (#16049)

* Add proxy support to container apis

* Add logging support

* Add cost tracking support for containers and documentation

* Add new constant documentation

* Add container cost in model map

* fix failing azure tests

* Update tests based on model map changes

* fix model map tests

* fix model map tests

* Container modeshould be container

* Container tests fix

* Merge branch 'main' into litellm_sameer_oct_staging_2

* Add Prometheus metric to track callback logging failures in S3 (#16102)

* Add proxy support to container apis

* Add logging support

* prometheus metric  measures how often s3_v2 is failing

* remove not needed files

* remove not needed files

* remove not needed files

* fix mypy errors

* Use logging_callback_manager to get all the callbacks

---------

Co-authored-by: Ishaan Jaffer <ishaanjaffer0324@gmail.com>
2025-11-03 18:46:52 -08:00
Ishaan Jaffer b0a2e08a60 fixes test 2025-10-28 17:43:04 -07:00
Ishaan Jaffer 74e4d3f6da fixes for mock tests 2025-10-28 17:31:54 -07:00
Ishaan Jaffer 2acedb4826 test_bedrock_apply_guardrail_with_masking 2025-10-25 12:59:19 -07:00
Ishaan Jaffer 0bedf1c0a7 fix tests 2025-10-25 10:19:24 -07:00
Sameer Kankute c638f45213 Implement Bedrock Guardrail apply_guardrail endpoint support (#15892)
* Add bedrock support for apply gaurdrails

* Add bedrock support doc

* remove unused variable

* remove unused variable
2025-10-24 10:24:03 -07:00
Copilot f5359ba007 Fix apply_guardrail endpoint returning raw string instead of ApplyGuardrailResponse (#15436)
* Initial plan

* Fix apply_guardrail endpoint to return ApplyGuardrailResponse

Co-authored-by: ishaan-jaff <29436595+ishaan-jaff@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ishaan-jaff <29436595+ishaan-jaff@users.noreply.github.com>
2025-10-11 17:50:37 -07:00
Krrish Dholakia bb5011597c test: fix minor test 2025-10-04 14:55:04 -07:00
Ishaan Jaffer c27beb74b9 test fix 2025-09-27 12:40:34 -07:00
Alexsander Hamir eaa04cd8ce fix: use fastuuid helper (#14903)
* fix: use fastuuid helper across the codebase

First batch of changes, simple drop in replacement.

* second batch of changes

* fixed: script mistake on helper file
2025-09-25 15:47:01 -07:00
Ishaan Jaffer 8b3e3c1882 tes fix 2025-09-20 17:00:30 -07:00
Ishaan Jaffer c656982f18 test fix 2025-09-20 16:55:23 -07:00
Ishaan Jaffer 979ca9287b test prometheus fix 2025-09-20 16:03:34 -07:00
Ishaan Jaffer f1a18b69a4 test_aincrement_top_level_request_and_spend_metrics 2025-09-20 15:33:08 -07:00
Ishaan Jaffer 8ec73db36b test fix 2025-09-20 15:32:59 -07:00
Ishaan Jaffer 6c966400dd fix test 2025-09-20 15:03:35 -07:00
Ishaan Jaffer d4a2a4a608 test fix 2025-09-20 14:10:40 -07:00
Ishaan Jaffer 18d5177aec test fix 2025-09-20 14:09:24 -07:00
Krrish Dholakia 459e66a9cd fix: fix test 2025-09-13 13:38:35 -07:00
Ishaan Jaff e0e356e328 test mapped test fixes 2025-08-23 17:04:23 -07:00
Krrish Dholakia ba9f6894b7 test: update tests 2025-08-23 10:42:41 -07:00
Jugal D. Bhatt 3a38912bce [Proxy] Litellm fix mapped tests (#13634)
* Fix - add safe divide by 0 for most places to prevent crash

* mock prisma client

* Revert "Fix - add safe divide by 0 for most places to prevent crash"

This reverts commit 265d40e39051e148996b9fb7f354730c57ff23ac.
2025-08-14 14:19:36 -07:00
Ishaan Jaff 4d941c914e [Feat] Responses API Session Handling - Multi media support (#13347)
* rename ResponsesSessionHandler

* use ResponsesSessionHandler

* test session handler

* refactor ResponsesSessionHandler

* fix get_proxy_server_request_from_spend_log

* use constant for LITELLM_TRUNCATED_PAYLOAD_FIELD

* add _should_check_cold_storage_for_full_payload

* add get_class_type_for_custom_logger_name

* get_active_custom_logger_for_callback_name

* add get_proxy_server_request_from_cold_storage to CustomLogger

* add ColdStorageHandler

* start using cold storage integration

* add get_proxy_server_request_from_cold_storage

* fixes from manual testing

* s3 v2 fix getting region name

* ChatCompletionImageUrlObject

* use _get_configured_cold_storage_custom_logger

* fixes for _should_check_cold_storage_for_full_payload

* fix _download_object_from_s3

* test_s3_v2_with_cold_storage

* add cold_storage_object_key to StandardLoggingMetadata

* use get_proxy_server_request_from_cold_storage_with_object_key

* add cold_storage_object_key to SpendLogsMetadata

* add cold_storage_object_key

* get_proxy_server_request_from_cold_storage_with_object_key

* use get_proxy_server_request_from_cold_storage_with_object_key

* test responses API

* add get_proxy_server_request_from_cold_storage_with_object_key

* session handler fixes

* test session handler

* fix ruff checks

* _download_object_from_s3

* cleanup

* test

* lint fix

* test_e2e_cold_storage_successful_retrieval

* test_e2e_generate_cold_storage_object_key_successful

* test_async_gcs_pub_sub_v1

* test fix

* test fix

* test fix

* test_standard_logging_metadata_has_cold_storage_object_key_field

* test_sanitize_request_body_for_spend_logs_payload_basic

* test_transform_input_image_item_to_image_item_with_image_data
2025-08-07 10:59:53 -07:00
Ishaan Jaff dab8ba03e3 [Feat] - When using custom tags on prometheus allow using wildcard patterns (#13316)
* _tag_matches_wildcard_configured_pattern

* test_get_custom_labels_from_tags_wildcard_patterns

* docs Custom Tags

* docs how custom tags work

* fix
2025-08-05 17:46:13 -07:00
Ishaan Jaff ba1882fdd5 [Bug Fix] Prometheus - fix for litellm_input_tokens_metric, litellm_output_tokens_metric - Note this updates the metric name (#13271)
* fixes for litellm_tokens_metric

* test_prometheus_token_metrics_with_prometheus_config
2025-08-04 17:22:21 -07:00
Jugal D. Bhatt a46b9d376f [Prometheus] Move Prometheus to enterprise folder (#12659)
* fix tools fetch for keys

* add promethues to enterprise

* remove old prom

* remove old prom

* fix tests

* safe imports

* add if

* fix enterprise test

* rename imports

* added label import

* added label import

* move tests to enterprise

* fix tests

* add log

* build: update versions

---------

Co-authored-by: Krrish Dholakia <krrishdholakia@gmail.com>
2025-07-18 11:54:47 -07:00
yeahyung 782969bb05 (#11794) use upsert for managed object table rather than create to avoid UniqueViolationError (#11795)
* (#11794) use upsert for managed object table rather than create to avoid UniqueViolationError

* (#11794) use upsert for managed object table rather than create to avoid UniqueViolationError
2025-07-15 20:20:01 -07:00
Krish Dholakia 7c392475e6 Control Plane + Data Plane support (#12601)
* feat(route_checks.py): allow admin to disable proxy management endpoints on instance

useful for preventing multiple instances from doing admin actions

* docs(scaling_multiple_instances.md): add architecture doc on scaling multiple litellm instances

provide guidance on scaling proxy

* docs(scaling_multiple_instances.md): add doc on scaling across multiple regions for litellm

* fix(route_checks.py): allow disabling llm api endpoints on an instance

allows pure admin instance to exist

* refactor(enterprise/route_checks.py): refactor env var checks

* refactor: finish refactoring

* docs(control_plane_and_data_plane.md): refactor docs

* test: update tests
2025-07-14 21:31:56 -07:00
Krish Dholakia 569ddde9fe [Enterprise] Support tag based mode for guardrails (#12508)
* feat(custom_guardrail.py): allow admin to run guardrails on specific modes based on request tags

Enables pre-call checks for openwebui but logging for claude code guardrails

* refactor(custom_guardrail.py): move tag based mode to enterprise

* test(test_custom_guardrail.py): update test

* feat(quick_start.md): add doc on tag-based guardrail mode

* docs(quick_start.md): cleanup doc

* docs: cleanup

* docs(openweb_ui.md): add tutorial to doc

* fix(custom_guardrail.py): ensure user is premium user

* test: update test
2025-07-10 22:27:30 -07:00
Krrish Dholakia c3857e60f2 Store batch output file id in DB + Store batch file status in DB + (experimental) BATCH API COST TRACKING 2025-06-25 22:41:22 -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
Ishaan Jaff 84bacef587 test_internal_user_endpoints.py 2025-06-21 16:45:14 -07:00
Krish Dholakia 84999ddef3 UI - Fix remaining users activity if no limit + allow filtering by model access groups (#11730)
* feat(enterprise/): fix remaining users check on license

* fix(usage_indicator.tsx): if no max user set, don't render remaining user info card

only for users with user limits on their license

* fix(leftnav.tsx): only show remaining users to admin

* feat(columns.tsx): don't allow sorting on model access groups

it's a list[str]

* feat(model_dashboard.tsx): add model access group filters
2025-06-14 13:38:58 -07:00
Krish Dholakia 4611b821ec Support returning virtual key in custom auth + Handle provider-specific optional params for embedding calls (#11346)
* feat(custom_auth_auto.py): support returning a litellm virtual key from custom auth

allows admin to remap old keys to litellm virtual keys

* fix(utils.py): correctly handle optional params for openai sdk calls

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

* test: update test

* fix(utils.py): handle edge cases
2025-06-03 07:24:13 -07:00