Commit Graph
43 Commits
Author SHA1 Message Date
Tomu Hirata 5879f6e930 comment 2025-08-20 15:46:53 +09:00
Tomu Hirata d64b579131 Include predicted output in tracing
Signed-off-by: Tomu Hirata <tomu.hirata@gmail.com>
2025-08-20 15:39:32 +09:00
Ishaan JaffandGitHub 195ea6515e [Feat] Datadog LLM Observability - Add support for tracing guardrail input/output (#13767)
* add guardrail information on DD LLM Obs

* test_guardrail_information_in_metadata
2025-08-19 10:26:25 -07:00
Ishaan JaffandGitHub ba1d2e8749 [Feat] DD LLM Observability - Add time to first token, litellm overhead, guardrail overhead latency metrics (#13734)
* fixes for DDLLMObsLatencyMetrics

* use _get_latency_metrics

* DD LLM Obs - track latency metrics

* fixes for bedrock guardrails

* DD unit tests

* test DD
2025-08-18 17:38:04 -07:00
Ishaan JaffandGitHub ef08e18c66 [Feat] Datadog LLM Observability - Add support for Failure Logging (#13726)
* add async_log_failure_event for DD LLM Obs

* update types

* DataDogLLMObsLogger  add failure logging support

* test_async_log_failure_event

* dd test failure
2025-08-18 15:19:48 -07:00
TomuHirataandGitHub f6e53deacd Update mlflow logger usage span attributes (#13561)
* test: sync mlflow request tags

* fix test
2025-08-14 15:20:50 -07:00
Ishaan JaffandGitHub 008ea864a7 [Feat] - Add key/team logging for Langfuse OTEL Logger (#13512)
* feat - add key/team logging for LF

* test_construct_dynamic_otel_headers_with_langfuse_keys

* update LangfuseOtelLogger

* test_construct_dynamic_otel_headers_with_langfuse_keys

* cleanup

* OpenTelemetryConfig fixes

* fix code qa checks

* TestLangfuseOtelIntegration
2025-08-11 22:06:25 -07:00
Edward D'AmatoandGitHub 30fc5b871c feat(integrations): allow setting of braintrust callback base url (#13368)
* feat(integrations): allow setting of braintrust callback base url

* chore(misc): remove extra additions due to merge
2025-08-07 08:40:11 -07:00
Krish DholakiaandGitHub 3119064e94 Prompt Management - add prompts on UI (#13240)
* fix(create_key_button.tsx): add prompts on UI

* feat(key_management_endpoints.py): support adding prompt to key via `/key/update`

* fix(key_info_view.tsx): show existing prompts on key in key_info_view.tsx

* fix(key_edit_view.tsx): UX - disable premium feature for non-premium users

prevent accidental clicking

* fix(create_key_button.tsx): disable premium features behind flag, prevent errors

* feat(prompts.tsx): add new ui component to view created prompts

enables viewing prompts created on config

* feat(prompt_info.tsx): add component for viewing the prompt information

* feat(prompt_endpoints.py): support converting dotprompt to json structure + accept json structure in promptmanager

allows prompt manager to work with api endpoints

* test(test_prompt_manager.py): add unit tests for json data input

* feat(dotprompt/__init__.py): add prompt data to dotpromptmanager

* fix(prompt_endpoints.py): working crud endpoints for prompt management

* feat(prompts/): support `prompt_file` for dotprompt

allows to precisely point to the prompt file a prompt should use

* feat(proxy/utils.py): resolve prompt id correctly

resolves user sent prompt id with internal prompt id

* feat(schema.prisma): initial pr with db schema for prompt management table

allows post endpoints to work with backend

* feat(prompt_endpoints.py): use db in patch_prompt endpoint

* feat(prompt_endpoints.py): use db for update_prompt endpoint

* feat(prompt_endpoints.py): use db on prompt delete endpoint

* build(schema.prisma): add prompt tale to schema.prisma in litellm-proxy-extras

* build(migration.sql): add new sql migration file

* fix(init_prompts.py): fix init

* feat(prompt_info_view.tsx): show the raw prompt template on ui

allows developer to know the prompt template they'll be calling

* feat(add_prompt_form.tsx): working ui add prompt flow

allows user to add prompts to litellm via ui

* build(ui/): styling fixes

* build(ui/): prompts.tsx

styling improvements

* fix(add_prompt_form.tsx): styling improvements

* build(prompts.tsx): styling improvements

* build(ui/): styling improvements

* build(ui/): fix ui error

* fix: fix ruff check

* docs: document new api params

* test: update tests
2025-08-02 22:33:37 -07:00
Krrish Dholakia d158a0344d test: update unit tests 2025-08-01 13:37:51 -07:00
Krrish Dholakia 72fd4e3d55 test: remove bad unit tests 2025-08-01 13:34:23 -07:00
Krrish Dholakia e3c9fc458d test: update tests 2025-08-01 09:19:31 -07:00
Krrish Dholakia fe24c270de Prompt Management - add local dotprompt file support 2025-07-31 22:28:29 -07:00
Cole McIntoshandGitHub 0666ede8e3 fix: correct patch path in langfuse test for MAX_LANGFUSE_INITIALIZED_CLIENTS (#13192)
The test was failing because it was trying to patch MAX_LANGFUSE_INITIALIZED_CLIENTS
at the wrong path. The constant is imported from litellm.constants into the langfuse
module namespace, so we need to use patch.object on the imported module reference.

Changes:
- Import langfuse module explicitly for patching
- Use patch.object instead of patch string path
- This fixes the AttributeError that was causing CI failures
2025-07-31 17:11:28 -07:00
Ishaan JaffandGitHub ee70d593c1 [Feat] Allow redacting message / response content for specific logging integrations - DD LLM Observability (#13158)
* fix redact_standard_logging_payload

* add StandardCustomLoggerInitParams

* allow defining DatadogLLMObsInitParams

* fix init DataDogLLMObsLogger

* fix import

* update redact_standard_logging_payload_from_model_call_details

* test_dd_llms_obs_redaction

* docs DD logging

* docs DD

* docs DD

* Redacting Messages, Response docs DD LLM Obs

* fix redaction logic

* fix create_llm_obs_payload

* fix logging response

* fixes

* ruff fix

* fix test

* test_dd_llms_obs_redaction

* test_create_llm_obs_payload

* redact_standard_logging_payload_from_model_call_details

* img - dd_llm_obs

* docs DD

* fix linting

* fix linting

* fix mypy

* test_create_llm_obs_payload

* test_create_llm_obs_payload

* fix mock_env_vars

* fix _handle_anthropic_messages_response_logging
2025-07-31 16:44:16 -07:00
Anand KhinvasaraandGitHub 212a339954 fix: support negative indexes in cache_control_injection_points for Anthropic Claude (#10226) (#13187) 2025-07-31 15:50:53 -07:00
Ishaan Jaff d10a5a69af fix test_mlflow_request_tags_functionality 2025-07-29 17:33:24 -07:00
Ishaan JaffandGitHub 5fa2b00c3f [Feat] MLFlow Logging - Allow adding tags for ML Flow logging requests (#13108)
* add mlflow tags

* fixes config

* add litellm mlflow

* test_mlflow_request_tags_functionality

* docs ML flow litellm proxy

* docs ml flow

* docs mlflow
2025-07-29 16:51:27 -07:00
Krish DholakiaandGitHub 5b50a12329 Revert "fix: Set user from token user_id for OpenMeter integration (#13029)" (#13107)
This reverts commit f8c09e44f6.
2025-07-29 15:49:20 -07:00
Better than breakfast.andGitHub f8c09e44f6 fix: Set user from token user_id for OpenMeter integration (#13029) 2025-07-29 15:41:50 -07:00
75ae43e667 feat(langfuse-otel): Add comprehensive metadata support to Langfuse OpenTelemetry integration (#12956)
* feat(langfuse-otel): Add comprehensive metadata support to Langfuse OpenTelemetry integration

This commit brings the langfuse_otel integration to feature parity with the vanilla Langfuse integration by adding support for all metadata fields.

Changes:
- Extended LangfuseSpanAttributes enum with all supported metadata fields:
  - Generation-level: generation_name, generation_id, parent_observation_id, version, mask_input/output
  - Trace-level: trace_user_id, session_id, tags, trace_name, trace_id, trace_metadata, trace_version, trace_release, existing_trace_id, update_trace_keys
  - Debug: debug_langfuse

- Implemented metadata extraction and mapping in langfuse_otel.py:
  - Added _extract_langfuse_metadata() helper to extract metadata from kwargs
  - Support for header-based metadata (langfuse_* headers) via proxy
  - Enhanced _set_langfuse_specific_attributes() to map all metadata to OTEL attributes
  - JSON serialization for complex types (lists, dicts) for OTEL compatibility

- Updated documentation:
  - Added 'Metadata Support' section explaining all fields are now supported
  - Provided usage example showing how to pass metadata
  - Clarified that traces are viewed in Langfuse UI (not generic OTEL backends)
  - Added opentelemetry-exporter-otlp to required dependencies

This allows users to pass metadata like:
metadata={
    'generation_name': 'my-generation',
    'trace_id': 'trace-123',
    'session_id': 'session-456',
    'tags': ['prod', 'v1'],
    'trace_metadata': {'user_type': 'premium'}
}

All metadata is exported as OpenTelemetry span attributes with 'langfuse.*' prefix for easy filtering and analysis in the Langfuse UI.

* Fix ruff linting error

* test(langfuse-otel): Fix failing test and add comprehensive metadata tests

- Fix test_set_langfuse_environment_attribute to use positional arguments
  instead of keyword arguments when asserting safe_set_attribute calls
- Add test_extract_langfuse_metadata_basic to verify metadata extraction
  from litellm_params
- Add test_extract_langfuse_metadata_with_header_enrichment to test
  integration with header-based metadata using a stubbed LangFuseLogger
- Add test_set_langfuse_specific_attributes_full_mapping to comprehensively
  test all metadata field mappings and JSON serialization of complex types

These tests ensure full coverage of the langfuse_otel metadata features
added in commit ab1dbe355 and fix the CI test failure.

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

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-07-28 16:53:36 -07:00
Krish DholakiaandGitHub 6d3ce76e1c Guardrails - support model-level guardrails (#12968)
* fix(custom_guardrail.py): initial logic for model level guardrails

* feat(custom_guardrail.py): working pre call guardrails

* fix(custom_guardrails.py): check if custom guardrails set before running event hook

* test(test_custom_guardrail.py): add unit tests for async pre call deployment hook on custom guardrail

* feat(custom_guardrail.py): add post call processing support for guardrails

allows model based guardrails to run on the post call event for that model only

* fix(utils.py): only run if call type is in enum

* test: update unit tests to work
2025-07-24 22:38:03 -07:00
Ishaan JaffandGitHub e3b752d3dc [Feat] LiteLLM CloudZero Integration updates - using LiteLLM_SpendLogs Table (#12922)
* use spend logs in transform.py

* fixes for using spend logs

* get_usage_data

* update get_usage_data_for_hour

* fix CloudZeroLogger

* fixes for cloudzero_dry_run_export

* working DB read

* fix _aggregate_to_hourly

* update cloudzero endpoints

* fix cloudzero_export

* fixes for CBF transformer

* use init_background_job on saving cz settings

* add is_cloudzero_setup_in_db

* init cz on startup

* fixes for CZ transform

* fix ruff check

* fix LOC violation
2025-07-23 18:46:50 -07:00
Ishaan JaffandGitHub 99ad24c683 [Feat] LiteLLM x Cloudzero integration - Allow exporting spend to cloudzero (#12908)
* add cz init

* add DataAnalyzer

* add CZRNGenerator -> LiteLLM resource generator

* add CloudZeroStreamer

* add CBFTransformer

* add cloudzero DB connection

* add config

* add cli.py

* cleanup

* add CloudZeroLogger

* add CloudZeroLogger

* update CloudZeroLogger

* add cloudzero_router to litellm proxy

* add CloudZeroInitRequest

* add cloudzero spend endpoints

* simple dry run endpoint

* refactor dir structure

* add well types CBFRecord

* TestCBFTransformer

* TestCloudZeroStreamer

* ruff fix

* add polars pip + docker requirements.txt

* _group_by_date

* update code qa check

* docs for CZ params
2025-07-23 13:00:58 -07:00
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
Ishaan JaffandGitHub d227085e03 [Bug fix] s3 v2 log uploader crashes when using with guardrails (#12733)
* fix - use safe dumps for s3 v2

* TestS3V2UnitTests

* fix code qa check
2025-07-18 08:57:07 -07:00
Ishaan JaffandGitHub 6a7aab7b84 [Bug Fix] StandardLoggingPayload on cache_hits should track custom llm provider + DD LLM Obs span type (#12652)
* bug fix - ensure custom llm provider is tracked on cache hit

* fix config.yaml

* test_cache_hit_includes_custom_llm_provider

* fix _get_datadog_span_kind

* test_datadog_span_kind_mapping

* fix ruff check

* test_datadog_span_kind_mapping
2025-07-16 15:43:15 -07:00
Krish DholakiaandGitHub 0730f61127 OTEL - OTEL_RESOURCE_ATTRIBUTES support + Model Hub - new model hub table view, new /public/model_hub endpoint, fix duplicates in /model_group/info (#12468)
* fix(opentelemetry.py): initial commit adding support for OTEL_RESOURCE_ATTRIBUTES

* test: update unit tests

* feat(ui/): initial commit with revamped model hub

* fix(model_hub_table.tsx): generic 'supports_' rendering as capabilities

* feat(model_hub_table.tsx): indicate if a model is publicly available

* refactor(model_hub_table.tsx): refactor to use common model data table component

* fix(model_hub_table.tsx): fix box sizes

* fix(model_hub_table.tsx): enable selecting / deselecting models in columns

* feat(public_endpoints.py): initial commit adding `/public/model_hub` endpoint

enables sharing public models

* feat(public_endpoints/): instrumentation for public model hub route

* feat(proxy_server.py): support request access form for model groups

allows user to request access to a model

* refactor: use a dictionary of text + link instead of 1 hardcoded request access form

* fix(proxy_server.py): prevent duplicates in model_group info

* fix: fix linting error

* fix(__init__.py): fix linting error
2025-07-09 22:00:57 -07:00
Ishaan JaffandGitHub 6055da09d0 [Bug Fix] DataDogLLMObsLogger push total_cost (#12467)
* push total cost

* fixes dd llm obs

* TestDataDogLLMObsLogger

* fix _get_time_to_first_token_seconds

* test_get_time_to_first_token_seconds

* fix linting
2025-07-09 18:23:01 -07:00
Ishaan JaffandGitHub 08f3b06d82 [Feat] Bump langfuse python SDK version and LANGFUSE_TRACING_ENVIRONMENT (#12376)
* bump langfuse to 2.59.7

* _set_langfuse_specific_attributes

* fix files

* test_set_langfuse_environment_attribute
2025-07-07 15:53:43 -07:00
Ishaan JaffandGitHub 090f847bd9 [Feat] QA - Arize Team based logging (#12331)
* add _get_tracer_with_dynamic_headers

* fix construct_dynamic_arize_headers

* [Feat] UI - Allow Viewing/Editing Team Based Callbacks (#12329)

* add logging settings view on UI

* fix change ordering

* add construct_dynamic_otel_headers for arize

* refactor common code

* test_construct_dynamic_arize_headers

* otel unit tests

* test_arize_dynamic_params

* test_arize_dynamic_headers_in_grpc_requests
2025-07-04 18:17:09 -07:00
Krish DholakiaandGitHub a03390ccc7 Litellm dev 07 03 2025 p2 (#12301)
* fix(langfuse_prompt_management.py): add langfuse prompt version param support

Adds prompt versioning support

* test(test_langfuse_prompt_management.py): add unit test

* fix: fix linting errors

* fix: add prompt_version instrumentation

* fix(langfuse_otel.py): correctly read env var

* docs(langfuse_integration.md): clarify v3 recommendation is to use langfuse_otel

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

* docs(langfuse_otel_integration.md): cleanup docs

* test: fix test

* test: update tests

* fix: fix linting error
2025-07-03 22:40:21 -07:00
Ishaan JaffandGitHub eef0623443 [Feat] Add Arize Team Based Logging (#12264)
* working KeyAndTeamLoggingSettings

* add arize_space_id to StandardCallbackDynamicParams

* add construct_dynamic_arize_headers

* add construct_dynamic_arize_headers to

* update otel arize logging

* fix imports

* test_construct_dynamic_arize_headers

* dynamic key/team settings

* test_get_dynamic_logging_metadata_with_arize_team_logging
2025-07-02 17:15:35 -07:00
Ishaan JaffandGitHub 66fafa3a7f [Feat] Polish - add better error validation when users configure prometheus metrics and labels to control cardinality (#12182)
* self._pretty_print_invalid_metric_error

* docs prometheus.md

* test prom validation checks

* update metric name

* fix _pretty_print_validation_errors

* fix linting

* test prometheus

* test fixes - prometheus
2025-07-01 20:17:17 -07:00
Samuel BoydandGitHub a5c2475ecf OpenMeter integration error handling fix (#12147)
* fix - tuple was never falsy so never triggered the exception

* test - add test suite for openmeter integration

* refactor - move tests for openmeter integration
2025-07-01 18:12:54 -07:00
Krish DholakiaandGitHub 308e82d885 LiteLLM SDK <-> Proxy improvement (don't transform message client-side) + Bedrock - handle qs:.. in base64 file data + Tag Management - support adding public model names (#11908)
* fix(factory.py): handle qs:.. in mime type

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

* feat(litellm_proxy/): don't transform messages client-side

leave litellm proxy messages untouched - allow proxy to handle transformation

 prevents double transformation

* feat(tag_management_endpoints.py): support adding models to tag by adding model_name

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

* test(test_tag_management_endpoints.py): add unit tests for adding new model by public model name

* test: update test
2025-06-19 22:34:18 -07:00
Krish DholakiaandGitHub c92b6c175c Prometheus - fix request increment + add route tracking for streaming requests (#11731)
* fix(prometheus.py): remove request increment from inside the log success event

it's only done on post-call success/failure

* fix(litellm_logging.py): add additional validation step for checking if 'stream' is true

prevent double counting on non-stream requests

* test: add unit testing to ensure stream is not incorrectly set to true

* feat(litellm_logging.py): emit request route in standard logging payload

used by prometheus streaming metrics for route

* fix: fix otel test

* fix: fix linting errors

* test: update test

* fix: fix linting error
2025-06-14 16:26:48 -07:00
Ishaan JaffandGitHub b091c1ac4d [Feat] Prometheus - Allow controlling exposed metrics and labels (#11489)
* feat: init prometheus_metrics_config

* feat: add prometheus_metrics_config

* test prometheus

* feat: use factor to init metrics

* fix - pretty print allowed metrics controls

* fix config

* fix - working get_labels_for_metric

* test_no_prometheus_config

* docs update prometheus
2025-06-14 13:56:40 -07:00
Krish DholakiaandGitHub 7df76175b4 fix(prometheus.py): fix total token increment + add semantic tests for prometheus metrics (#11718)
fixes regression where total requests was incremented by token value
2025-06-13 16:43:00 -07:00
Walt WellsandGitHub f782cc7e4d update GCSBucketBase to handle GSM project ID if passed (#11409) 2025-06-04 10:02:26 -07:00
Ishaan JaffandGitHub a1f3a1c5dc [Feat] Performance - Don't create 1 task for every hanging request alert (#11385)
* feat: add async_get_oldest_n_keys in memory cache

* fix: add add_request_to_hanging_request_check

* test: alerting

* feat: v2 hanging request check

* fix: HangingRequestData

* fix: AlertingHangingRequestCheck

* fix: check_for_hanging_requests

* fix: use correct metadata location for hanging requests

* fix: formatting alert

* test hanging request check

* fix: add guard flags for background tasks alerting
2025-06-03 21:12:54 -07:00
0590b1eb3a [Fix] Prometheus Metrics - Do not track end_user by default + expose flag to enable tracking end_user on prometheus (#11192)
* fix: testing for disabling end user on metrics

* fix: fixes for test_prometheus_factory

* Delete litellm/model_prices_and_context_window_backup.json

* fix: issues with merge conflicts

* fix: test_get_end_user_id_for_cost_tracking_prometheus_only

* Update tests/test_litellm/integrations/test_prometheus.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-27 17:06:58 -07:00
Krish DholakiaandGitHub 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