Commit Graph

34808 Commits

Author SHA1 Message Date
Harshit28j ce052d07be Fix test helper hour=23 bug and add row-count batching test
- Use timedelta(hours=1) instead of replace(hour=hour+1) in _window()
  to avoid ValueError when hour=23
- Add test_should_batch_by_row_count covering the >10K rows batching
  path (previously only the 2 MB size-limit path was tested)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 18:12:27 +05:30
Harshit28j 358c2fd033 Add empty-string credential validator to VantageSettingsUpdate
Matches the existing validator on VantageInitRequest so that empty or
whitespace-only api_key/integration_token values are rejected at update
time rather than silently persisted and failing at the next export.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 17:41:23 +05:30
Harshit28j 212cd0e4aa Fix pod lock collision, empty credential validation, and interval parsing
- Override initialize_focus_export_job in VantageLogger to use
  VANTAGE_USAGE_DATA_JOB_NAME as the Redis pod lock key, preventing
  silent export skips when both Focus and Vantage loggers are configured
- Add field_validator to VantageInitRequest rejecting empty-string
  api_key and integration_token at init time instead of at export time
- Guard FocusLogger FOCUS_INTERVAL_SECONDS with try/except matching
  the pattern already used in VantageLogger

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 17:28:19 +05:30
Harshit28j 4a9d03f1b1 Fix FocusLogger dedup to use exact type match in litellm_logging.py
Use `type(cb) is FocusLogger` instead of `isinstance(cb, FocusLogger)`
in both _init_custom_logger_compatible_class and
get_custom_logger_compatible_class so that a VantageLogger already in
_in_memory_loggers is not incorrectly returned for a "focus" lookup.
This ensures users with both "vantage" and "focus" in success_callbacks
get separate loggers for each export destination.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 17:01:16 +05:30
Harshit28j 3cc2ccec4a Fix double-scheduling bug and Decimal CSV serialization
- Guard FocusLogger.init_focus_export_background_job with exact type
  check (type(cb) is FocusLogger) to exclude VantageLogger subclass,
  preventing duplicate hourly exports when VantageLogger is registered
  programmatically before startup
- Cast pl.Decimal columns to Float64 in FocusCsvSerializer so CSV
  output uses standard floating-point notation instead of fixed-point
  strings that Vantage's parser may reject

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 16:42:35 +05:30
Harshit28j 9200b28078 Fix dry-run summary alignment, token logging, and upload error handling
- Align dry-run summary to use pre-transform columns (spend, total_tokens,
  team_id, model) matching FocusExportEngine internals
- Reduce token exposure in debug logs to first 4 chars
- Wrap raise_for_status in try/except to log httpx errors before re-raising

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 16:31:30 +05:30
Harshit28j d35abfb55f Fix data truncation, sub-batch resilience, and env var safety
- Split VantageExportRequest (limit=None) and VantageDryRunRequest
  (limit=500) so actual exports don't silently truncate large datasets
- Add try/except around each sub-batch upload in _upload_size_limited,
  consistent with _upload_batched's continue-on-failure guarantee
- Guard VANTAGE_EXPORT_INTERVAL_SECONDS against non-numeric values
  with try/except instead of bare int() cast

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 16:06:59 +05:30
Harshit28j 25c8658761 Fix oversized-row handling, batch error resilience, and callback registration
Vantage destination:
- Skip individual CSV rows exceeding 2MB limit with a warning instead of
  uploading an oversized batch that Vantage would reject
- Wrap each batch upload in try/except so remaining batches continue on
  failure; re-raise the first error after all batches are attempted

Callback registration:
- Use litellm.logging_callback_manager.add_litellm_callback() instead of
  raw litellm.callbacks.append() for DB-bootstrapped VantageLogger, ensuring
  proper dedup and manager visibility
- Add "vantage" init handler in litellm_logging.py (both creation and
  lookup branches) so config.yaml string callbacks are properly resolved

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 15:34:24 +05:30
Harshit28j 9e623ceaff Remove redundant empty-frame guard in FocusCsvSerializer
Polars write_csv already handles empty DataFrames correctly (outputs
header-only CSV), so the conditional branch was a no-op.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 15:16:49 +05:30
Harshit28j 230c85313b Fix dry-run HTTPException guard and VantageLogger instance detection
- Add missing except HTTPException: raise in vantage_dry_run_export
  (consistent with all other endpoints in the file)
- Fix is_vantage_setup_in_config() to detect both the string "vantage"
  and VantageLogger instances in litellm.callbacks, preventing duplicate
  logger registration on startup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 15:10:53 +05:30
Harshit28j 622d5dabba Fix HTTPException swallowed as 500 in /vantage/export endpoint
Add missing `except HTTPException: raise` guard so intentional 404
responses (e.g. when settings are not configured) are not caught by the
generic Exception handler and re-raised as 500 errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 14:59:52 +05:30
Harshit28j 9cc6df6b8d Fix Greptile round 4: preserve backward compat, add guards, fix defaults
- Revert FocusExportEngine.dry_run_export_usage_data to use original raw
  column names (spend, total_tokens, team_id, model) preserving backward
  compatibility for existing callers
- Vantage dry-run endpoint computes its own summary from FOCUS columns
  independently, avoiding coupling to the engine method
- Set VantageExportRequest.limit default to 500 (was None) matching docstring
- Add empty-settings guard in /vantage/export returning 404 instead of
  deferring ValueError to runtime
- Fix misleading docstring in _build_tags_expr about Rust-level execution
- Clarify Tags schema comment: parquet is self-describing so existing
  exports are unaffected

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 14:51:03 +05:30
Harshit28j 4583c90194 Address remaining Greptile feedback: mask token, reuse HTTP client, align columns
- Mask integration_token in GET /vantage/settings response (renamed field to integration_token_masked)
- Reuse single httpx.AsyncClient across all batch uploads in deliver()
- Align FocusExportEngine.dry_run_export_usage_data to use post-transform FOCUS columns (BilledCost, SubAccountId, ResourceType) matching the Vantage dry-run endpoint

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 14:38:19 +05:30
Harshit28j e07297fa87 Address Greptile round 3 feedback for improved security and consistency
- Encrypt integration_token alongside api_key in Vantage settings storage
- Align dry-run summary with FocusExportEngine helper methods
- Vectorize Tags JSON building using pl.struct + map_elements
- Reuse registered VantageLogger in /export endpoint instead of creating fresh instances

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 14:27:24 +05:30
Harshit28j e1c44fe088 Fix Greptile round 2 review issues
- DB-only Vantage config now registers VantageLogger at startup so
  background job actually schedules (was silently skipping)
- Add missing `except HTTPException: raise` in /vantage/init endpoint
- Use consistent batch filenames (always .partN suffix)
- Document Tags schema change from pl.Object to pl.String

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 14:17:03 +05:30
Harshit28j f683befeed Fix Greptile review issues in Vantage integration
- Enforce 10K row limit in single-shot upload path (not just 2MB size)
- Fix KeyError crash in update_vantage_settings when no settings exist
- Remove unreachable status_code==400 dead code branch
- Make dry-run endpoint work without Vantage credentials by using
  FOCUS database + transformer directly instead of VantageLogger

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 14:02:05 +05:30
Harshit28j 69a94a873c Add Vantage integration for FOCUS CSV export
Adds a pluggable Vantage destination to the existing FOCUS export pipeline,
enabling LiteLLM to export spend data in FOCUS format directly to Vantage's
cost-import API. Supports automatic hourly exports via scheduled background job,
with admin API endpoints for manual control and configuration. Includes CSV
serializer, batching for 10K row / 2MB API limits, and enriched Tags JSON with
team/user/key metadata for Vantage Token Allocation feature.

- Add CSV serializer (FocusCsvSerializer) for FOCUS data
- Add Vantage API destination with automatic batching
- Add VantageLogger that wraps FocusLogger with Vantage defaults
- Add proxy endpoints: /vantage/{init,settings,export,dry-run,delete}
- Register "vantage" callback in logger registry and literal type
- Wire up background job in proxy_server.py startup
- Populate Tags column with JSON metadata (team_id, user_id, user_email, etc.)
- Add 14 unit tests covering serializer, destination, and factory

All tests pass (23 focus tests total, no regressions).

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-11 13:51:36 +05:30
Sameer Kankute a788b21092 Merge pull request #23243 from BerriAI/litellm_bedrock-completion-tokens-details
fix(bedrock): populate completion_tokens_details in Responses API
2026-03-10 18:19:28 +05:30
Sameer Kankute cd80213f1c Merge pull request #23151 from BerriAI/litellm_preserve-reasoning-summary-for-responses-api
fix(openai): preserve reasoning_effort summary field for Responses API
2026-03-10 18:18:46 +05:30
Sameer Kankute b3c4326845 Merge pull request #23131 from BerriAI/litellm_vertex_ai_extra_body_cache_fix
fix(vertex_ai): strip LiteLLM-internal keys from extra_body before merging to Gemini request
2026-03-10 18:17:29 +05:30
Sameer Kankute 9bc7357e7c Merge pull request #23222 from BerriAI/litellm_oss_staging_02_18_2026
Litellm oss staging 02 18 2026
2026-03-10 17:46:06 +05:30
Sameer Kankute b211b67cea Merge pull request #23164 from BerriAI/litellm_oss_staging_03_09_2026
oss staging 03/09/2026
2026-03-10 17:45:17 +05:30
Sameer Kankute d0d1291c15 Merge pull request #22628 from BerriAI/litellm_oss_staging_03_02_2026
Litellm oss staging 03 02 2026
2026-03-10 17:40:31 +05:30
Sameer Kankute 9bee76c30d Merge pull request #23253 from BerriAI/main
merge main
2026-03-10 17:25:01 +05:30
Sameer Kankute 72fc2f77cf Merge pull request #23252 from BerriAI/main
merge main
2026-03-10 17:24:19 +05:30
Sameer Kankute 3f17a63b81 Merge branch 'main' into litellm_oss_staging_03_02_2026 2026-03-10 17:19:37 +05:30
Sameer Kankute 94b002066e Merge pull request #23244 from BerriAI/litellm_skills_api_folder_name_match
fix(skills): match zip folder name to skill name in SKILL.md for Anthropic API
v1.82.1-nightly v1.82.1.rc.1
2026-03-10 14:11:49 +05:30
Sameer Kankute 88c4079b16 fix(skills): match zip folder name to skill name in SKILL.md for Anthropic API
Made-with: Cursor
2026-03-10 14:11:11 +05:30
Sameer Kankute 0122abfa2b fix(bedrock): populate completion_tokens_details in converse _transform_usage
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-03-10 13:17:28 +05:30
Sameer Kankute 3e1f343d1a Merge pull request #23242 from BerriAI/litellm_fix_redaction_and_charity_engine_provider
fix(tests): update cache hit redaction assertion to expect choices fo…
2026-03-10 12:27:59 +05:30
yuneng-jiang d39a3a90b4 Merge pull request #23241 from BerriAI/litellm_/elastic-gagarin
[Feature] UI - Virtual Keys: Add refetch button, keep stale data during refetch
2026-03-09 23:52:11 -07:00
yuneng-jiang 129ed1014b [Fix] UI - Virtual Keys: Reset refetch button on error so user can retry
When a fetch fails, the button now exits the loading state instead of
staying stuck on "Fetching" indefinitely.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:46:45 -07:00
Sameer Kankute f33f446476 Merge pull request #23240 from BerriAI/litellm_bedrock-nova-output-config-spend-tracking
fix(bedrock): strip output_config from Converse requests; fix spend tracking redaction test
2026-03-10 12:15:06 +05:30
Sameer Kankute 30fde1de7f fix(tests): update cache hit redaction assertion to expect choices format
Made-with: Cursor
2026-03-10 12:14:24 +05:30
yuneng-jiang 9ee489863d [Feature] UI - Virtual Keys: Add refetch button and keep stale data during refetch
Show a Fetch/Fetching button next to "Showing X of Y results" that acts as
both a manual refetch trigger and a loading indicator. The "Loading keys..."
message now only appears on initial load; subsequent refetches keep the table
visible with stale data (via React Query's keepPreviousData).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 23:30:55 -07:00
yuneng-jiang b8886568f0 Merge pull request #23236 from BerriAI/litellm_/flamboyant-leakey
[Fix] All Proxy Models Not Including Model Access Groups in Key Creation
2026-03-09 23:27:38 -07:00
Sameer Kankute 200b001633 fix(bedrock): strip output_config from Converse requests; fix spend tracking redaction test
Made-with: Cursor
2026-03-10 11:53:36 +05:30
Sameer Kankute d9d81175b6 Merge pull request #23238 from BerriAI/litellm_mcp_openapi_tool_fixes
fix(mcp): OpenAPI tool listing and execution for relative URLs and camelCase
2026-03-10 11:48:33 +05:30
Sameer Kankute db99fdeff3 fix(mcp): OpenAPI tool listing and execution for relative URLs and camelCase
- Fix case-insensitive tool name matching in _tool_name_matches() so that
  OpenAPI operationIds (camelCase) match lowercase registered tool names
  when filtering by allowed_tools
- Fix get_base_url() to resolve relative server URLs (e.g. /api/v3) by
  deriving full base URL from spec_path when OpenAPI spec has relative URLs
- Add tests for case-insensitive matching and filter_tools_by_allowed_tools

Made-with: Cursor
2026-03-10 11:34:23 +05:30
yuneng-jiang 1755a281bd Fix mutation bug: copy lists in get_key_models to prevent corrupting cached UserAPIKeyAuth
`all_models = user_api_key_dict.models` was creating an alias, so
`_get_models_from_access_groups` (which uses `.pop()`/`.extend()`) would
mutate the cached object in-place. Now both `.models` and `.team_models`
assignments create copies via `list()`.

Added test to verify the input is not mutated.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 22:55:53 -07:00
yuneng-jiang 1cf191d9ad [Fix] Deduplicate model lists and remove dead assignment
Adds dedup to get_key_models and get_team_models to prevent duplicate
entries when access group member models overlap with proxy_model_list.
Removes dead assignment of all_models in get_team_models.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 22:44:45 -07:00
Sameer Kankute cf84072662 Merge pull request #23235 from BerriAI/litellm_fix_redaction_and_charity_engine_provider
fix(logging): preserve ModelResponse choices format in redacted standard_logging_object + add Charity Engine provider endpoint
2026-03-10 11:00:24 +05:30
yuneng-jiang c829733200 [Fix] Include model access groups when expanding All Proxy Models
When a team has "all-proxy-models", the model list expansion now includes
model access group names so they appear in the UI key creation form.
Also fixes get_key_models not forwarding include_model_access_groups to
_get_models_from_access_groups, and removes unused _unfurl_all_proxy_models.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 22:30:07 -07:00
Sameer Kankute b08445837b fix(logging): preserve ModelResponse choices format in redacted standard_logging_object + add Charity Engine provider endpoint
- Fix perform_redaction to handle dict representation of ModelResponse (from model_dump())
- Preserve full choices structure when redacting, redact content/audio in place
- Add _redact_standard_logging_object helper for standard_logging_object field
- Update test_logging_redaction_e2e_test assertions to expect choices format
- Add charity_engine to provider_endpoints_support.json

Fixes: test_standard_logging_payload, test_standard_logging_payload_audio
Made-with: Cursor
2026-03-10 10:22:57 +05:30
Sameer Kankute 09919a81b2 Merge pull request #23234 from BerriAI/revert-23224-cursor/get-optional-params-behavior-ed4a
Revert "Get optional params behavior"
2026-03-10 10:22:10 +05:30
Sameer Kankute 504e66ccd4 Revert "fix: forward recognized OpenAI params from kwargs in completion() (#2…"
This reverts commit dd6f0d6c55.
2026-03-10 10:22:00 +05:30
Sameer Kankute 32e7b22f05 Merge pull request #23233 from BerriAI/revert-23231-litellm_cicd_100326
Revert "Fix logging tests"
2026-03-10 10:00:04 +05:30
Sameer Kankute 3f30f6a49c Revert "Fix logging tests" 2026-03-10 09:59:53 +05:30
Sameer Kankute 9402a8b57e Merge pull request #23231 from BerriAI/litellm_cicd_100326
Fix logging tests
2026-03-10 09:59:00 +05:30
Sameer Kankute 7542845e8d Revert "fix: strip empty text content blocks in /v1/messages endpoint (#23097)"
This reverts commit 2c738cc939.
2026-03-10 09:56:39 +05:30