litellm/tests/test_litellm/integrations
Tim Ren dd4a41951f
fix(utils): allowed_openai_params must not forward unset params as None (#25777)
* feat(proxy): add NO_OPENAPI env var to disable /openapi.json endpoint (#25696)

* feat(proxy): add NO_OPENAPI env var to disable /openapi.json endpoint - Fixes #25538

* test(proxy): add tests for _get_openapi_url

---------

Co-authored-by: Progressive-engg <lov.kumari55@gmail.com>

* feat(prometheus): add api_provider label to spend metric (#25693)

* feat(prometheus): add api_provider label to spend metric

Add `api_provider` to `litellm_spend_metric` labels so users can
build Grafana dashboards that break down spend by cloud provider
(e.g. bedrock, anthropic, openai, azure, vertex_ai).

The `api_provider` label already exists in UserAPIKeyLabelValues and
is populated from `standard_logging_payload["custom_llm_provider"]`,
but was not included in the spend metric's label list.

* add api_provider to requests metric + add test

Address review feedback:
- Add api_provider to litellm_requests_metric too (same call-site as
  spend metric, keeps label sets in sync)
- Add test_api_provider_in_spend_and_requests_metrics following the
  existing pattern in test_prometheus_labels.py

* fix: ensure `litellm_metadata` is attached to `pre_call` guardrail to align with `post_call` guardrail (#25641)

* fix: ensure `litellm_metadata` is attached to pre_call to align with post_call

* refactor: remove unused BaseTranslation._ensure_litellm_metadata

* refactor: module level imports for ensure_litellm_metadata and CodeQL

* fix: update based off of Codex comment

* revert: undo usage of `_guardrail_litellm_metadata`

* feat: add pricing entry for openrouter/google/gemini-3.1-flash-lite-preview (#25610)

* fix(bedrock): skip synthetic tool injection for json_object with no schema (#25740)

When response_format={"type": "json_object"} is sent without a JSON
schema, _create_json_tool_call_for_response_format builds a tool with an
empty schema (properties: {}). The model follows the empty schema and
returns {} instead of the actual JSON the caller asked for.

This patch:
- Skips synthetic json_tool_call injection when no schema is provided.
  The model already returns JSON when the prompt asks for it.
- Fixes finish_reason: after _filter_json_mode_tools strips all
  synthetic tool calls, finish_reason stays "tool_calls" instead of
  "stop". Callers (like the OpenAI SDK) misinterpret this as a pending
  tool invocation.

json_schema requests with an explicit schema are unchanged.

Co-authored-by: Claude <noreply@anthropic.com>

* fix(utils): allowed_openai_params must not forward unset params as None

`_apply_openai_param_overrides` iterated `allowed_openai_params` and
unconditionally wrote `optional_params[param] = non_default_params.pop(param, None)`
for each entry. If the caller listed a param name but did not actually
send that param in the request, the pop returned `None` and `None` was
still written to `optional_params`. The openai SDK then rejected it as
a top-level kwarg:

    AsyncCompletions.create() got an unexpected keyword argument 'enable_thinking'

Reproducer (from #25697):

    allowed_openai_params = ["chat_template_kwargs", "enable_thinking"]
    body = {"chat_template_kwargs": {"enable_thinking": False}}

Here `enable_thinking` is only present nested inside
`chat_template_kwargs`, so the helper should forward
`chat_template_kwargs` and leave `enable_thinking` alone. Instead it
wrote `optional_params["enable_thinking"] = None`.

Fix: only forward a param if it was actually present in
`non_default_params`. Behavior is unchanged for the happy path (param
sent → still forwarded), and the explicit `None` leakage is gone.

Adds a regression test exercising the helper in isolation so the test
does not depend on any provider-specific `map_openai_params` plumbing.

Fixes #25697

---------

Co-authored-by: lovek629 <59618812+lovek629@users.noreply.github.com>
Co-authored-by: Progressive-engg <lov.kumari55@gmail.com>
Co-authored-by: Ori Kotek <ori.k@codium.ai>
Co-authored-by: Alexander Grattan <51346343+agrattan0820@users.noreply.github.com>
Co-authored-by: Mohana Siddhartha Chivukula <103447836+iamsiddhu3007@users.noreply.github.com>
Co-authored-by: Amiram Mizne <amiramm@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
2026-04-16 19:04:26 +05:30
..
arize fix(arize-phoenix): enable nested traces coexistence with otel callback 2026-02-26 04:59:17 -05:00
azure_storage
bitbucket
cloudzero
datadog fix: drain datadog batches safely (#25663) 2026-04-14 23:37:49 +05:30
dotprompt
focus [Fix] Use cached async HTTP client in Vantage destination 2026-03-14 12:23:40 -07:00
gcs_bucket
gcs_pubsub
gitlab build: migrate packaging, CI, and Docker from Poetry to uv (#25007) 2026-04-09 11:46:23 -07:00
langfuse fix: prevent sys.modules["langfuse"] import failures in langfuse unit tests 2026-02-18 08:22:23 -03:00
levo
litellm_agent Agent Builder - support new experimental agent builder, to ensure agents pass compliance checks (#21817) 2026-02-21 15:32:47 -08:00
open_telemetry/data
SlackAlerting feat: add optional digest mode for Slack alert types (#21683) 2026-02-21 15:19:17 -08:00
websearch_interception fix(websearch_interception): ensure spend/cost logging runs when stream=True 2026-04-09 18:48:38 +05:30
test_agentops.py
test_anthropic_cache_control_hook.py Merge branch 'main' into litellm_oss_staging_03_04_2026 2026-03-11 18:31:20 +05:30
test_athina.py
test_azure_sentinel.py
test_braintrust_logging.py
test_braintrust_span_name.py
test_custom_guardrail_recursion.py fix: recursive pydantic issue (#19531) 2026-01-22 19:56:41 -08:00
test_custom_guardrail.py fix(guardrails): address PR #25575 review feedback + sync kill switch with opt-out list 2026-04-11 17:48:16 -07:00
test_custom_prompt_management.py
test_deepeval.py
test_langfuse_otel.py fix: prevent sys.modules["langfuse"] import failures in langfuse unit tests 2026-02-18 08:22:23 -03:00
test_langfuse.py Align Langfuse trace_id fallback with DB session_id for failed requests 2026-03-02 20:55:31 +05:30
test_langsmith_init.py Merge branch 'main' into litellm_oss_staging_03_17_2026 2026-03-20 08:42:41 +05:30
test_mlflow.py
test_openmeter.py
test_opentelemetry_dynamic_imports.py
test_opentelemetry.py Code review 2026-03-18 16:25:42 -05:00
test_prometheus_cache_metrics.py build: migrate packaging, CI, and Docker from Poetry to uv (#25007) 2026-04-09 11:46:23 -07:00
test_prometheus_client_ip_user_agent.py Litellm oss staging 04 02 2026 p1 (#25055) 2026-04-08 21:37:10 -07:00
test_prometheus_invalid_key_filtering.py
test_prometheus_labels.py fix(utils): allowed_openai_params must not forward unset params as None (#25777) 2026-04-16 19:04:26 +05:30
test_prometheus_metric_name_consistency.py
test_prometheus_missing_metrics.py add callbacks and labels to prometheus (#19708) 2026-01-25 23:03:23 -08:00
test_prometheus_none_metadata.py fix: guard against None metadata in prometheus metrics (#21489) 2026-02-18 12:40:45 -08:00
test_prometheus_queue_guardrail_metrics.py
test_prometheus_services.py Reduce default latency histogram bucket cardinality (#25527) 2026-04-11 09:34:45 -07:00
test_prometheus_spend_logs_metadata.py test(prometheus): add tests for spend_logs_metadata in custom labels 2026-03-23 11:02:21 -07:00
test_prometheus_stream_label.py feat(prometheus): add opt-in stream label to litellm_proxy_total_requests_metric (#22023) 2026-02-24 11:51:42 -08:00
test_prometheus_user_team_metrics.py Reduce default latency histogram bucket cardinality (#25527) 2026-04-11 09:34:45 -07:00
test_responses_background_cost.py fix(test): update test_responses_background_cost assertions for pagination and stale cleanup 2026-03-13 16:18:15 -07:00
test_s3_v2.py Merge branch 'main' into litellm_oss_staging_04_04_2026 2026-04-14 20:23:06 +05:30
test_weave_otel.py