Commit graph

46149 commits

Author SHA1 Message Date
mateo-berri
6b2ada2a78 fix(bedrock): per-response realtime usage deltas, spend-log event filter, single transcript completed 2026-08-31 11:49:09 -07:00
Mateo Wang
c09fa5b712
Merge pull request #38883 from BerriAI/litellm_docs_user_spend_endpoint_semantics
docs(proxy): clarify spend semantics on /v2/user/info and /user/daily/activity
2026-08-31 11:47:41 -07:00
milan
ade21da9d0 refactor(responses): simplify tool call argument serializer
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-08-31 18:43:36 +00:00
milan
9125a5b7a0 fix(responses): json-encode object tool call arguments in the chat completions bridge
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-08-31 18:43:36 +00:00
Mateo Wang
3905c9d9df
Merge pull request #38381 from mubashir1osmani/litellm_close_unacknowledged_duplicate_issues
feat(ci): close duplicate issues after a 3-day grace period
2026-08-31 11:38:12 -07:00
Devin AI
7b4b92f54f fix(registry): update veo 3.1 pricing with resolution tiers
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-08-31 18:37:26 +00:00
mateo-berri
e938e89d13 docs(proxy): account for budget rollover and daily upserts in spend wording 2026-08-31 11:19:11 -07:00
mateo-berri
797848dd82 fix(cost): bill OCR annotation pages via annotation_cost_per_page 2026-08-31 11:18:59 -07:00
mateo-berri
219b4ebe46 Merge branch 'litellm_bedrock_messages_disconnect_billing' of https://github.com/nuernber/litellm into litellm_pr36008_head
# Conflicts:
#	basedpyright-code-budget.json
#	type-discipline-budget.json
2026-08-31 11:16:20 -07:00
mateo-berri
0e78c5bff7 fix(anthropic_messages): dispatch deferred spend logging when the client disconnects mid-relay
When the pump finishes draining while the client is still connected,
billing is deferred to the proxy's post-response hook, which only fires
on a normally completed response. A client disconnect before the relay
consumed the queued tail tore the generator down past that hook, so the
request logged no spend at all. The relay teardown now dispatches the
stored deferred billing whenever it never reached the end-of-stream
sentinel.

Also drops the live pass_through_tests script: that CI job runs against
a fixed config with no Bedrock model or AWS credentials, so it could
only fail there. The scenario is covered by unit tests on the
relay/pump seam.
2026-08-31 10:17:27 -07:00
mateo-berri
8a6f47a6d4 merge: litellm_internal_staging into litellm_fix_nova_sonic_realtime_user_asr_usage 2026-08-31 10:17:12 -07:00
Mateo Wang
c03a38d501
Merge pull request #38801 from BerriAI/devin_ai_1788036971-stale-cost-map-sources
fix: update stale source URLs and deprecation dates in model cost map
2026-08-31 10:04:25 -07:00
yucheng-berri
30f3228510
test(newrelic): cover static default_team_settings per-team routing (#38857)
* test(newrelic): cover static default_team_settings per-team routing

The dynamic POST /team/{team_id}/callback path for New Relic is tested, but
the static default_team_settings twin had no regression coverage. Add a test
that drives default_team_settings -> add_team_based_callbacks_from_config and
asserts the resolved trusted vars dispatch to BOTH the per-team metrics logger
(cost/usage) and the trace logger (LLM/agent spans), so a config-file customer
gets the same per-team routing as the API customer.

Also correct the /team/callback docstring: callback_name is a str validated
against the credential-capable callbacks, not a fixed langfuse/langsmith/gcs
Literal, and document the newrelic_api_key / newrelic_region vars.

* chore(ui): sync schema.d.ts with the /team/callback docstring

Regenerate the dashboard OpenAPI types for the add_team_callbacks description
change: callback_name is a validated str (not a langfuse/langsmith/gcs
Literal) and the newrelic_api_key / newrelic_region vars are documented.

* docs(newrelic): note LITELLM_OTEL_V2 prerequisite, trim test comments

Address review: team-scoped New Relic config is rejected with a 400 unless the
proxy runs with LITELLM_OTEL_V2=true, so document that in the /team/callback
endpoint and sync schema.d.ts. Drop the narrative setup comments in the new
test per the repo comment convention; the test name and docstring already say why.
2026-08-31 16:58:35 +00:00
mateo-berri
39473745dd fix(docker): bump wolfi-base for glibc 2.44 and pin apk python to 3.13 in migrations image 2026-08-31 09:53:01 -07:00
mateo-berri
6e59ce1773 Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_pr36008_head
# Conflicts:
#	basedpyright-code-budget.json
#	type-discipline-budget.json
2026-08-31 09:41:15 -07:00
Mateo Wang
d6cce13308
Merge pull request #38772 from BerriAI/litellm_claude_md_test_behavior_not_structure
docs(claude.md): require tests to check behavior, not code structure
2026-08-31 09:32:48 -07:00
nuernber
2f50988fed fix(anthropic): resolve TRY300 lint violation and ratchet budgets after litellm_internal_staging merge 2026-08-31 09:30:29 -07:00
devin-ai-integration[bot]
f079e4061b
fix(proxy): deliver budget alerts on webhook-only alerting and accept ALERTING_WEBHOOK_URL (#38441)
* fix(proxy): deliver budget alerts on webhook-only alerting and accept ALERTING_WEBHOOK_URL

ProxyLogging.budget_alerts forwarded to the alerting pipeline only when
'slack' was in general_settings.alerting, so alerting: ['webhook'] plus
WEBHOOK_URL silently never delivered a budget alert (the config
/health/services?service=webhook exists to test). Forward when 'webhook'
is present too; SlackAlerting.send_alert already fans out per channel.

Also accept a provider-neutral ALERTING_WEBHOOK_URL env fallback for the
Slack-format channel (any Slack-compatible receiver works), mark it as a
sensitive var, and de-brand the admin UI alerting copy.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(ui): format settings.tsx with prettier

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* chore(ui): regenerate schema.d.ts for updated alerting description

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* ci: retrigger checks after ALERTING_WEBHOOK_URL docs merged

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: yassin <yassin@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-08-31 09:22:36 -07:00
nuernber
b5affa63aa Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_bedrock_messages_disconnect_billing
# Conflicts:
#	basedpyright-code-budget.json
#	type-discipline-budget.json
2026-08-31 09:22:00 -07:00
nuernber
8e92f98905 docs(constants): clarify which env var the cap=0 fallback note applies to 2026-08-31 09:18:12 -07:00
nuernber
79fd2f4872 test(anthropic): cover ANTHROPIC_MESSAGES_MAX_DETACHED_STREAM_DRAINS=0 fallback to partial billing 2026-08-31 09:15:36 -07:00
nuernber
e1fece511a test(anthropic): fix PT012 lint violation in upstream-error regression test 2026-08-31 09:11:51 -07:00
nuernber
b2df72f980 chore: ratchet down lint/type budgets after disconnect-billing merge fix 2026-08-31 09:05:37 -07:00
Mateo Wang
32291c9ad2
Merge pull request #38942 from BerriAI/litellm_lite_claude_enable_tool_search-8eee
feat(cli): set ENABLE_TOOL_SEARCH=true for lite claude
2026-08-31 09:02:48 -07:00
nuernber
95a2586228 Merge remote-tracking branch 'origin/main' into litellm_bedrock_messages_disconnect_billing
# Conflicts:
#	basedpyright-code-budget.json
#	litellm/llms/anthropic/experimental_pass_through/messages/streaming_iterator.py
#	tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_streaming_iterator.py
#	type-discipline-budget.json
2026-08-31 08:58:37 -07:00
Srivatsa03
cc3ea1fb08 docs(cost): state that a naive off-peak current_time is read as UTC
An aware value is converted, a naive one is taken to already be UTC rather
than localised. Nothing signals the difference, so a caller passing
datetime.now() instead of datetime.now(timezone.utc) shifts every window by
the host's offset and bills silently wrong. Say so where a caller will read it.

Reported by @xyzs996 in review.
2026-08-31 10:29:10 -05:00
Srivatsa03
27aefade5f fix(cost): treat an equal-ended off-peak window as the whole day
A window whose start equals its end is the natural way to spell off-peak all
day, and the docstring's promise that a window may wrap past midnight invites
it. It took the non-wrap branch instead, where start <= now < end can never
hold, so it matched nothing. It parses cleanly, so it never reached the branch
that ignores malformed windows: no exception, no log, and the model billed at
standard rates around the clock while the config said otherwise. Let equality
fall through to the wrap branch, which covers every instant, and say so in the
docstring.

Reported by @xyzs996 in review.
2026-08-31 10:29:10 -05:00
Srivatsa03
4f174ffdd1 fix(cost): apply off-peak rates on the tiered-pricing path
Tiered pricing resolves its own base rates and returns early, before the
off-peak swap ran, so a model carrying both tiered_pricing and off_peak_pricing
billed the tier rate around the clock. Route every base-cost path through one
helper so the window applies wherever the rates came from, and say plainly in
the docstring that an off-peak rate replaces the rate it lands on rather than
discounting it
2026-08-31 10:29:10 -05:00
Srivatsa03
d302301a4e test(cost): move off-peak tests beside the related cost tests
They sat at the end of the file, which is where everyone else appends
too, so this branch picked up a conflict there on nearly every rebase.
Grouping them with the other _get_token_base_cost test keeps them clear
of that churn and next to the code they cover. Pure move, no test changes
2026-08-31 10:29:09 -05:00
Srivatsa03
c813386bb2 refactor(cost): conform off-peak pricing to current lint budgets
Rebasing onto litellm_internal_staging picked up stricter ceilings than this
branch was written against. Bind the off-peak results to fresh names instead
of reassigning the base costs, mark the new locals Final, avoid rebinding the
current_time parameter, and make the window parse explicit about UTC so
DTZ007, LIT010 and LIT011 all stay within budget
2026-08-31 10:27:56 -05:00
Srivatsa03
f2c663515c fix(cost): evaluate off-peak windows in UTC for timezone-aware inputs
_is_within_off_peak_window used current_time.time(), which drops tzinfo, so a caller passing a non-UTC aware datetime had the window compared against local wall-clock instead of UTC. That silently mispriced off-peak requests. Normalize aware datetimes to UTC before comparing; naive datetimes stay as-is per the documented UTC contract. Added a regression test with a UTC+8 datetime that fails without the fix
2026-08-31 10:27:30 -05:00
Srivatsa03
9fc77f1222 feat(cost): support time-based off-peak pricing in cost calculation
Some providers charge different per-token rates depending on the time of
day. DeepSeek, for example, has historically discounted its chat and
reasoner models during an off-peak window (16:30-00:30 UTC). LiteLLM's
cost map only modeled static per-token pricing, so cost tracking could
not stay accurate for these providers.

This adds optional off-peak pricing to a model entry: input_cost_per_token_off_peak,
output_cost_per_token_off_peak, cache_read_input_token_cost_off_peak, and an
off_peak_hours_utc window expressed as "HH:MM-HH:MM" in UTC (the window may
wrap past midnight). When the current UTC time falls inside the window, the
cost calculator uses the off-peak rates and otherwise falls back to the
standard rates, so existing models are unaffected. The fields are also
accepted as custom pricing on a deployment, so they can be set from the
proxy config or the SDK.

The window check is a pure function that takes the current time as an
argument, which keeps the regression tests deterministic without patching
the clock.
2026-08-31 10:27:29 -05:00
Devin AI
4291afbfa5 fix(registry): correct OpenAI preview shutdown dates, add whisper/transcribe and Bedrock/Vertex deprecation dates
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-08-31 13:08:06 +00:00
Devin AI
f111262e54 Merge remote-tracking branch 'origin/litellm_internal_staging' into devin_ai_1788036971-stale-cost-map-sources 2026-08-31 13:03:35 +00:00
Devin AI
dd031f1036 fix(ci): parse paginated gh api output without splitting on unicode line breaks
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-08-31 09:42:07 +00:00
Devin AI
b81bca2696 Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_deflake_20260830 2026-08-31 09:18:31 +00:00
Devin AI
69fc449666 chore(techdebt): drop restating comments from the 2026-08-30 window
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-08-31 07:54:31 +00:00
Devin AI
f3d0da10d1 chore: merge litellm_internal_staging into litellm_techdebt_20260830
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-08-31 07:46:09 +00:00
Cursor Agent
43c64e2471
fix(cli): keep an existing ENABLE_TOOL_SEARCH value
Default remains true so lite claude turns tool search back on through
a proxy. An explicit false or auto in the env or settings is left alone

Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
2026-08-31 06:00:45 +00:00
Cursor Agent
096e016baf
fix(cli): sort claude_settings __all__ for ruff RUF022
Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
2026-08-31 05:58:00 +00:00
Cursor Agent
cafdfda8ba
feat(cli): set ENABLE_TOOL_SEARCH=true for lite claude
Claude Code turns tool search off when ANTHROPIC_BASE_URL is a proxy.
lite claude, lite up, login --config-claude, and autoroute now force
ENABLE_TOOL_SEARCH=true so MCP tools stay deferred through the proxy

Co-authored-by: Mateo Wang <mateo-berri@users.noreply.github.com>
2026-08-31 05:52:17 +00:00
feng.tsai
dc034a086a docs: trim the _image_sources docstring
It restated the source union that the type definition already carries.
2026-08-31 13:26:02 +08:00
feng.tsai
bb51c121cf docs: reference the source union by type instead of a line number
The line number went stale when the base moved.
2026-08-31 12:21:24 +08:00
samtsai15
0e7562dbc6 test(guardrails): cover every Anthropic image source shape in the extractor's own suite
_image_sources had no test asserting what it extracts. The existing image tests
live on the Bedrock side and all use base64 without a media_type, which is the one
path the fix left unchanged, so both behaviors it does change went unverified: the
url shape reaching the guardrail at all, and base64 arriving as a data URI.

Against the pre-fix extractor the url case sees [] and the media_type case sees
['AAAA'] instead of ['data:image/png;base64,AAAA'].

The remaining three assert behavior the fix deliberately preserves -- bare base64
passed through, a file source yielding nothing, a malformed source dropped rather
than handed on for a consumer to choke on.

Each message carries a text block because a message with no text never reaches the
guardrail, which would make every source shape look equally dropped.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 10:37:51 +08:00
samtsai15
1f80f93750 fix(guardrails): carry Anthropic url and file image sources through to guardrails
_image_sources returned source["data"] only. An Anthropic image block has three
shapes (types/llms/anthropic.py:259) and only the base64 one carries "data", so
{"type": "url", "url": ...} yielded nothing and the image never reached any
guardrail at all.

This is not Bedrock-specific. Five guardrails consume
GenericGuardrailAPIInputs["images"] (vigil_guard, custom_code, deepkeep, straiker,
generic_guardrail_api) and every one of them was blind to url sources on
/v1/messages.

base64 now returns a data URI rather than the bare payload. A consumer otherwise
has no way to recover media_type, and an API like Bedrock's ApplyGuardrail needs
the format to build its request.

The file shape stays unresolvable here: the bytes live behind the Files API and
this extractor has no client to fetch them. Documented rather than silently
dropped, so a consumer treating a missing entry as "no image to scan" is a known
gap and not a surprise.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 10:37:51 +08:00
mateo-berri
de1f38820a fix(passthrough): flush interrupted streams on client disconnect and reuse cached gigachat http clients 2026-08-30 13:36:51 -07:00
mateo-berri
14f392bb9b fix(docker): bump wolfi-base for glibc 2.44 and pin apk python to 3.13 2026-08-30 13:11:32 -07:00
mateo-berri
a5fa8ebfa7 fix(passthrough): keep upstream error body readable for streaming error status mapping 2026-08-30 12:59:18 -07:00
mateo-berri
fb9ec79d7c Merge branch 'litellm_internal_staging' into litellm_decrease_anys_opus5_r2 2026-08-30 12:49:29 -07:00
mateo-berri
99a6dd02af fix(proxy): narrow audio_speech response before reading upstream content-type 2026-08-30 12:46:11 -07:00