Commit graph

33582 commits

Author SHA1 Message Date
Yuneng Jiang
c9f8111219
chore: fixes 2026-04-04 22:58:49 -07:00
Cursor Agent
8285a786e3 docs: add WebSocket Mode section to /responses documentation
Adds comprehensive documentation for the Responses API WebSocket mode:
- Feature table, supported providers
- Proxy config + startup
- Python, Node.js, and websocat code examples
- Multi-turn continuation with previous_response_id
- Event type reference table
- Key differences from HTTP streaming
- Architecture/extensibility notes for adding new providers

Also adds WebSocket Mode to the feature summary table at the top.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
2026-02-25 23:10:32 +00:00
Cursor Agent
4f042374a5 refactor: make WebSocket responses extensible via BaseResponsesAPIConfig transforms
Architecture now matches the realtime API pattern (BaseLLMHTTPHandler +
BaseRealtimeConfig transforms):

BaseResponsesAPIConfig (new non-abstract hooks with passthrough defaults):
  - get_websocket_url()         — HTTP→WSS URL, override for custom paths
  - transform_websocket_client_message()  — client→backend message transform
  - transform_websocket_backend_message() — backend→client message transform

BaseLLMHTTPHandler.async_responses_websocket():
  - Generic handler that accepts any BaseResponsesAPIConfig
  - Calls config.transform_* hooks on every message
  - Same pattern as async_realtime() with BaseRealtimeConfig

ResponsesWebSocketStreaming:
  - Now accepts optional provider_config, calls transforms in the loop

When Azure (or any provider) ships WebSocket mode on /responses, they
just override the 3 hooks on their config — zero handler code changes.

Deleted: litellm/responses/websocket_handler.py (logic moved to
BaseLLMHTTPHandler)

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
2026-02-25 22:51:49 +00:00
Cursor Agent
4738911e8f refactor: move websocket code into litellm/responses/ to match existing organization
- litellm/responses/websocket.py: entry point reusing ProviderConfigManager
  and BaseResponsesAPIConfig.validate_environment/get_complete_url for
  credential resolution — same pattern as responses/main.py
- litellm/responses/websocket_handler.py: handler receives resolved URL +
  auth headers, only owns WS-specific concerns (protocol upgrade, SSL,
  bidirectional forwarding)
- litellm/responses/websocket_streaming.py: moved from litellm_core_utils/

Removed:
- litellm/realtime_api/responses_websocket.py (duplicated provider logic)
- litellm/llms/openai/responses/websocket_handler.py (duplicated credential
  resolution)

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
2026-02-25 22:35:41 +00:00
Cursor Agent
1e394db9e9 test: add E2E and live integration tests for Responses WebSocket
- test_responses_websocket_e2e.py: 6 tests exercising the full proxy
  WebSocket route via Starlette TestClient with mocked backends,
  including complete message flow simulation
- test_responses_websocket_live.py: 2 tests for live OpenAI WebSocket
  (auto-skipped when OPENAI_API_KEY is not set)
- Fix websockets v15 deprecation: use InvalidStatus instead of
  InvalidStatusCode in handler and proxy_server

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
2026-02-25 19:45:11 +00:00
Cursor Agent
51e5d9d3bc feat: add OpenAI Responses API WebSocket mode support
Implements WebSocket transport for the OpenAI Responses API endpoint
(wss://api.openai.com/v1/responses) as documented at:
https://developers.openai.com/api/docs/guides/websocket-mode/

New files:
- litellm/llms/openai/responses/websocket_handler.py: OpenAI WS handler
- litellm/litellm_core_utils/responses_websocket_streaming.py: bidirectional
  streaming forwarder for the Responses API WebSocket protocol
- litellm/realtime_api/responses_websocket.py: _aresponses_websocket entry
  point (analogous to _arealtime)
- tests/test_litellm/proxy/response_api_endpoints/test_responses_websocket.py:
  19 unit tests covering handler, streaming, routing, and endpoint registration

Modified files:
- litellm/__init__.py: export _aresponses_websocket
- litellm/router.py: register _aresponses_websocket route
- litellm/proxy/route_llm_request.py: add route type
- litellm/proxy/proxy_server.py: WebSocket endpoints at /v1/responses,
  /responses, /openai/v1/responses
- AGENTS.md: add Cursor Cloud specific instructions

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
2026-02-25 19:34:48 +00:00
yuneng-jiang
edd00c025c
Merge pull request #22112 from BerriAI/litellm_credential_tag_docs
[Docs] Credential Usage Tracking
2026-02-25 10:55:52 -08:00
yuneng-jiang
7daeaf8106 [Docs] Add Credential Usage Tracking documentation
Add new document explaining automatic credential usage tracking and tagging. When models use reusable credentials, LiteLLM automatically injects a Credential: <name> tag on requests, enabling credential-level spend tracking on the Usage page with no additional configuration.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-02-25 10:52:24 -08:00
yuneng-jiang
243771f99a
Merge pull request #22108 from BerriAI/litellm_pricing_calc_tests
[Test] UI - Pricing Calculator: Add comprehensive unit tests
2026-02-25 10:51:12 -08:00
Krish Dholakia
5662228e20
feat(ui): add user filtering to usage page (#22059)
* feat(ui): add user filtering to usage page

Adds "User Usage" as a new view option in the usage page dropdown,
allowing admins to view and filter usage data by individual users
via the existing /user/daily/activity backend endpoint.

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

* feat(ui/): working usage filtering

* fix(ui): use single-select for user filter and add tests

The user entity type's backend endpoint only accepts a single user_id,
so the filter now uses single-select mode instead of multi-select.
Added tests for the new user entity type in EntityUsage and
UsageViewSelect. Updated CLAUDE.md and AGENTS.md with guidance on
UI/backend contract consistency and test coverage for new entity types.

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

* revert: remove unintended package-lock.json changes

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

* revert: restore package-lock.json to merge base state

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

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 10:37:45 -08:00
yuneng-jiang
a38993b871
Merge pull request #22107 from BerriAI/litellm_fix_ui_duplicate_import_v2
fix(ui): remove duplicate antd import in ToolPolicies
2026-02-25 10:25:56 -08:00
yuneng-jiang
6ae7e84a0b [Test] UI - Pricing Calculator: Add comprehensive unit tests
Added unit tests for all pricing calculator components with 64 passing tests across 5 test files:
- multi_export_utils.test.ts (16 tests for PDF/CSV export functions)
- use_multi_cost_estimate.test.ts (15 tests for cost estimation hook)
- multi_export_dropdown.test.tsx (8 tests for export dropdown component)
- multi_cost_results.test.tsx (15 tests for results display and UI states)
- index.test.tsx (10 tests for main calculator component)

Also fixed missing page description for tool-policies page in page_metadata.ts.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-02-25 10:25:25 -08:00
Shin
115b9a2d29 fix(ui): remove duplicate antd import in ToolPolicies
Duplicate import was causing UI build to fail:
- Line 4: import { Select, Switch, Tooltip } from 'antd'
- Line 5: import { Select, Tooltip } from 'antd' (duplicate)

Removed the duplicate line 5.
2026-02-25 18:09:17 +00:00
Sameer Kankute
47c24ef8ae
Merge pull request #22094 from BerriAI/litellm_bump_openai_25_02
[chore] bump OpenAI package version
2026-02-25 18:46:10 +05:30
Sameer Kankute
05165779ac
Merge pull request #22081 from BerriAI/litellm_fix_bedrock_batch_health_check
Fix: Test connect failing for bedrock batches mode
2026-02-25 18:46:01 +05:30
Sameer Kankute
ebe35aad9a
Merge pull request #22080 from BerriAI/litellm_vllm_response_fix
Fix None (TypeError: 'NoneType' object is not a mapping)
2026-02-25 18:45:54 +05:30
Sameer Kankute
ec3ae25a3a
Merge pull request #22070 from BerriAI/litellm_forward_auth_headers
[Feat]Add forward auth headers of provider
2026-02-25 18:45:38 +05:30
Harshit Jain
fbffa9a215
Merge pull request #22095 from Harshit28j/litellm_fix_RCE_issues
fix Unauthenticated RCE and Sandbox Escape in Custom Code Guardrail
2026-02-25 18:23:04 +05:30
Harshit28j
c3e32b450e Address CR feedback: fix auth dependency duplication, correct logger wording, clean imports 2026-02-25 18:02:12 +05:30
Harshit28j
e50b4486d0 fix Unauthenticated RCE and Sandbox Escape in Custom Code Guardrail 2026-02-25 17:57:32 +05:30
Sameer Kankute
ec9ec6b771 remove comment 2026-02-25 17:40:46 +05:30
Sameer Kankute
955b85015f Bump openai package 2026-02-25 17:40:41 +05:30
Harshit Jain
d2aeb3e513
Merge pull request #22084 from Harshit28j/litellm_presidio-non-json-response-handling
fix(guardrails): prevent presidio crash on non-json responses
2026-02-25 16:37:39 +05:30
Harshit28j
6a8052295b fix(guardrails): prevent presidio crash on non-json responses 2026-02-25 16:11:24 +05:30
Harshit Jain
66c49dbb9c
Merge pull request #22077 from Harshit28j/litellm_gemini_trace_id_missingv2
Litellm gemini trace id missingv2
2026-02-25 15:09:42 +05:30
Sameer Kankute
61f9222156 Fix: Test connect failing for bedrock batches mode 2026-02-25 15:03:27 +05:30
Sameer Kankute
45c87a714e Fix None (TypeError: 'NoneType' object is not a mapping) 2026-02-25 14:39:12 +05:30
Harshit Jain
23e84eb789 fix: Metadata / Trace ID Missing in S3 Streaming Callbacks 2026-02-25 14:16:42 +05:30
Harshit Jain
897b472011 fix: Metadata / Trace ID Missing in S3 Streaming Callbacks 2026-02-25 14:16:21 +05:30
Sameer Kankute
83afa310d6 Fix clean header logger 2026-02-25 12:31:35 +05:30
Sameer Kankute
0e806c83c1 Fix docs 2026-02-25 12:13:56 +05:30
Sameer Kankute
a43d6139c7 Fix docs 2026-02-25 12:13:07 +05:30
Sameer Kankute
1f8f66de69 add docs for Authentication Headers forwarding 2026-02-25 12:10:12 +05:30
Sameer Kankute
886f9d6a70 Add support for forwarding provider's auth headers 2026-02-25 12:08:25 +05:30
Krish Dholakia
00ab4d2067
feat: add new code execution dataset (#22065) 2026-02-24 20:58:23 -08:00
yuneng-jiang
ec7dc44e73
Merge pull request #22049 from BerriAI/litellm_spend_log_key_info
[Fix] Enrich Failure Spend Logs With Key/Team Metadata
2026-02-24 20:56:51 -08:00
shin-bot-litellm
b2c0bec5c5
fix(test): Update status enum values to match Google Interactions OpenAPI spec (#22061)
Google's Interactions API spec changed the status enum:
- Values are now lowercase (was uppercase)
- 'UNSPECIFIED' value was removed

Updated test to match the current spec from:
https://ai.google.dev/static/api/interactions.openapi.json
2026-02-24 20:26:11 -08:00
yuneng-jiang
aa48a7ec00 Allow DB fallback for failure metadata enrichment lookups
Accurate logging is more important than avoiding the rare DB lookup
on the async failure path. Remove check_cache_only=True so lookups
fall back to DB when the key/team is not in cache.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 19:43:55 -08:00
yuneng-jiang
7a8b3daff5 address greptile review feedback (greploop iteration 2)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 19:22:45 -08:00
yuneng-jiang
bf77a114cc address greptile review feedback (greploop iteration 1)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 19:10:01 -08:00
yuneng-jiang
8f118fbbce
Merge pull request #22053 from atapia27/healthcheck-typo-fix
removed extra comma typo
2026-02-24 19:06:53 -08:00
Ishaan Jaff
60bcb26dc8
feat(agents): assign virtual keys to agents (#22045)
* feat(agents): assign virtual keys to agents

- Add agent_id field to LiteLLM_VerificationToken (schema.prisma + _types.py)
- Pass agent_id through key generation endpoint so keys can be scoped to an agent
- Refactor Add Agent wizard to 3-step flow (Configure → Assign Key → Ready)
  - Configure: all agent fields, custom/other type with just name+description
  - Assign Key: create new key or reassign existing key to agent
  - URL is now optional for easy discovery
- Add "Agent" ownership option to Create Key modal on Virtual Keys page
  with agent selector dropdown
- Extract CreatedKeyDisplay into shared component, reused in both flows
- Add keyCreateForAgentCall networking helper
- Add test for agent_id key generation

* fix(agents): code quality fixes from self-review

- Fix test_generate_key_helper_fn_agent_id: remove bare except clause,
  use explicit assert mock_insert.called, use .kwargs for clean arg access
- Remove no-op conditional in handleNext (both branches were identical)
- Validate selectedExistingKey before calling keyUpdateCall
- Validate selectedAgentId before setting on formValues in create_key_button

* fix(ui): replace deprecated Tremor Button with Ant Design Button in CreatedKeyDisplay
2026-02-24 18:28:16 -08:00
Ishaan Jaff
4e84e4c607
fix(ui): show real tool names in logs for Anthropic format tools (#22048) 2026-02-24 18:16:04 -08:00
Alejandro Tapia
b1423bc8bf removed extra comma typo 2026-02-24 17:37:00 -08:00
yuneng-jiang
3f1554c099
Merge pull request #21071 from atapia27/feat/healthcheck-model_id-fix
healthcheck-model_id-fix
2026-02-24 17:15:07 -08:00
yuneng-jiang
f4e23c97fd [Fix] Enrich failure spend logs with key/team metadata
Failure spend logs were missing key metadata (key alias, user ID, team ID,
team alias) in two scenarios:

1. Auth errors (401 ProxyException): auth_exception_handler creates a
   minimal UserAPIKeyAuth with only api_key and request_route set — all
   other fields are null. The failure hook now looks up the full key object
   from cache/DB using the key hash to populate the missing fields.

2. Post-auth failures (provider errors, rate limits): key fields are
   present but team_alias is always null because LiteLLM_VerificationTokenView
   SQL view does not include team_alias. The failure hook now looks up the
   team object from cache to populate team_alias.

Both lookups are non-fatal and wrapped in try/except.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 17:14:37 -08:00
Alejandro Tapia
80c09295ad Merge upstream/main - resolve health check conflicts 2026-02-24 17:09:05 -08:00
yuneng-jiang
9837a1bd2a
Merge pull request #22047 from BerriAI/litellm_key_info_page_email
[Feature] UI - Virtual Keys: Add KeyInfoHeader component
2026-02-24 17:04:17 -08:00
ryan-crabbe
fa87291bd9
Merge pull request #20397 from ryan-crabbe/fix/openai-prompt-cache-params
fix: add prompt_cache_key and prompt_cache_retention support for OpenAI
2026-02-24 16:51:10 -08:00
yuneng-jiang
50ba6986ef [Feature] UI - Virtual Keys: Add KeyInfoHeader component with metadata display
Add a reusable KeyInfoHeader component to replace the inline header in KeyInfoView.
Extract LabeledField as a common component for labeled metadata display with copyable
support, default_user_id handling, and empty value placeholders.

- Migrate all icons from lucide-react/heroicons to @ant-design/icons
- Use antd native copyable with descriptive tooltips (Copy Key Alias, Copy Key ID, etc.)
- Show DefaultProxyAdminTag for default_user_id values
- Add canModifyKey, regenerateDisabled, regenerateTooltip props for permission gating
- Add tests for KeyInfoHeader (19 tests) and LabeledField (8 tests)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-24 16:46:26 -08:00