Commit graph

33033 commits

Author SHA1 Message Date
Yuneng Jiang
224fef5d1b
chore: fixes
Some checks failed
Unit Tests: Security / security (push) Has been cancelled
Unit Tests: Caching (Redis) / caching-redis (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-db (auth-checks, tests/proxy_unit_tests/test_auth_checks.py tests/proxy_unit_tests/test_user_api_key_auth.py, 20, 8) (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-db (key-generation, tests/proxy_unit_tests/test_key_generate_prisma.py, 30, 0) (push) Has been cancelled
Unit Tests: Proxy DB Operations / proxy-db (remaining, tests/proxy_unit_tests --ignore=tests/proxy_unit_tests/test_key_generate_prisma.py --ignore=tests/proxy_unit_tests/test_auth_checks.py --ignore=tests/proxy_unit_tests/test_user_api_key_auth.py, 20, 8) (push) Has been cancelled
2026-04-05 01:16:32 -07:00
Ryan Crabbe
89140f9f33 fix: address review feedback - move constant below imports, add return type 2026-02-20 10:09:54 -08:00
Ryan Crabbe
476aed3fd6 perf: use frozenset for enum membership checks to avoid O(n) iteration
Replace O(n) list/enum iteration with O(1) frozenset lookups:
- route_checks.py: frozenset for LiteLLMRoutes._member_names_
- types/utils.py: cache DynamicPromptManagementParamLiteral.list_all_params()
- utils.py: use existing LlmProvidersSet instead of _member_map_.values()
2026-02-20 09:33:00 -08:00
jquinter
8356dfa045
Merge pull request #21685 from BerriAI/fix/mypy-type-errors-logging-utils-vertex
fix(types): resolve MyPy assignment type errors in logging_utils and vertex transformation
2026-02-20 14:07:59 -03:00
michelligabriele
a395a25705
fix(cost-calc): use per-image pricing for Bedrock multimodal embeddings (#21646)
Bedrock multimodal embedding models (Titan and Nova) were being costed
using the per-token text rate instead of the correct flat per-image rate
($0.00006/image). The pricing data was correct but never applied because
image_count was never populated in prompt_tokens_details.

Pass batch_data to Titan/Nova response transformers so they can count
image inputs and set PromptTokensDetailsWrapper(image_count=N) on Usage,
mirroring the existing Vertex AI pattern from PR #9623. Also fix the
text_tokens fallback in generic_cost_per_token to not override
text_tokens=0 when image_count > 0 (image-only requests).
2026-02-20 08:51:21 -08:00
Julio Quinteros Pro
8e4c92a8a3 fix(types): resolve MyPy assignment type errors in logging_utils and vertex transformation
logging_utils.py: annotate `copy` as `Union[dict, list]` so the list-branch
reassignment is compatible with the dict-branch assignment in the same scope.

transformation.py: pre-declare `project_id: Optional[str]` before the
if/else block so both branches (str from _ensure_access_token, Optional[str]
from vertex_ai_project) are compatible; use `project_id or ""` when passing
to get_complete_vertex_url which requires str.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 13:46:51 -03:00
jquinter
048f734168
Merge pull request #21682 from BerriAI/fix/skip-search-api-logging-prisma-test
fix(tests): skip test_search_api_logging_and_cost_tracking - requires Prisma DB
2026-02-20 13:34:51 -03:00
jquinter
97691f8d70
Merge pull request #21684 from BerriAI/fix/skip-remaining-prisma-db-tests
fix(tests): skip remaining real prisma DB tests in CI and related test suites
2026-02-20 13:34:16 -03:00
michelligabriele
8fdd330835
fix(proxy): use batch_ prefix for Vertex AI batch IDs in encode_file_id_with_model (#21624)
Vertex AI batch IDs are plain numeric strings (e.g., "3814889423749775360")
unlike OpenAI's "batch_"-prefixed IDs. encode_file_id_with_model() was
defaulting to "file-" prefix for unrecognized ID formats, causing Vertex AI
batch responses to return IDs like "file-bGl0ZWxsbTox..." instead of the
expected "batch_..." prefix per the OpenAI Batch API contract.

Add an optional id_type parameter to encode_file_id_with_model() so the
batch creation endpoint can specify id_type="batch" when encoding batch
response IDs. Default remains "file" for backward compatibility.

Closes #18192
2026-02-20 08:32:46 -08:00
michelligabriele
d001fe9a16
fix(model-pricing): add missing fireworks_ai model pricing for glm-4p7, minimax-m2p1, kimi-k2p5 (#21642)
* fix(model-pricing): add missing fireworks_ai model pricing for glm-4p7, minimax-m2p1, kimi-k2p5

Fireworks AI models called via short-form (fireworks_ai/<model>) were
reporting $0.00 cost because the pricing JSON lacked short-form entries.
The lookup fell through to the fireworks-ai-default bucket which has
zero cost.

Added 5 new entries to model_prices_and_context_window.json:
- fireworks_ai/accounts/fireworks/models/glm-4p7 (new long-form)
- fireworks_ai/accounts/fireworks/models/minimax-m2p1 (new long-form)
- fireworks_ai/glm-4p7 (new short-form)
- fireworks_ai/minimax-m2p1 (new short-form)
- fireworks_ai/kimi-k2p5 (new short-form; long-form already existed)

Pricing sourced from fireworks.ai model pages and pricing page.

* add cache_read_input_token_cost to kimi-k2p5 long-form entry for consistency
2026-02-20 08:31:52 -08:00
Julio Quinteros Pro
1dc3f1e530 fix(tests): skip remaining real prisma DB tests in CI and related test suites
Add @pytest.mark.skip to all test functions that use the real `prisma_client`
fixture (requiring an external PostgreSQL connection) across 7 test files.

Files updated:
- tests/proxy_unit_tests/test_proxy_server.py (5 tests)
- tests/proxy_admin_ui_tests/test_key_management.py (11 tests)
- tests/proxy_admin_ui_tests/test_role_based_access.py (5 tests)
- tests/proxy_admin_ui_tests/test_usage_endpoints.py (3 tests)
- tests/local_testing/test_blocked_user_list.py (2 tests)
- tests/local_testing/test_add_update_models.py (1 test)
- tests/local_testing/test_update_spend.py (1 test)

Total: 28 new skip markers added.

Note: tests using mock_prisma_client (properly mocked) are unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 13:25:42 -03:00
jquinter
33783aed10
Merge pull request #21681 from BerriAI/fix/mcp-server-test-spec-path-mock
fix(tests): add spec_path=None to MCP server mocks to fix Pydantic validation
2026-02-20 13:20:45 -03:00
jquinter
a8d806cdf0
Merge pull request #21680 from BerriAI/fix/converse-transformation-too-many-statements
fix(lint): extract service_tier mapping to fix PLR0915 in converse_transformation.py
2026-02-20 13:19:02 -03:00
Julio Quinteros Pro
3bc5d52f55 fix(tests): skip test_search_api_logging_and_cost_tracking - requires Prisma DB
httpx.ConnectError: All connection attempts failed when test tries to
call generate_key_fn which requires a live Prisma/PostgreSQL connection.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 13:19:01 -03:00
Julio Quinteros Pro
375f79de03 fix(tests): add spec_path=None to MCP server mocks to fix Pydantic validation
spec_path was added to LiteLLM_MCPServerTable but the three
test_add_update_server_* mocks weren't updated. MagicMock auto-creates
a MagicMock for unset attributes, which fails the Optional[str] Pydantic
validation. Fixes test_add_update_server_with_alias,
test_add_update_server_without_alias and
test_add_update_server_fallback_to_server_id.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 13:13:48 -03:00
Julio Quinteros Pro
5e9a2b4e9c fix(lint): extract service_tier mapping to fix PLR0915 in converse_transformation.py
map_openai_params had 53 statements (limit is 50). Extracted the
service_tier → Bedrock serviceTier mapping into _map_service_tier_param
helper, reducing the statement count to 49 with no behaviour change.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 12:51:59 -03:00
jquinter
92a30bafc7
Merge pull request #21679 from BerriAI/fix/skip-remaining-key-generate-prisma-tests
fix(tests): skip all remaining prisma DB tests in test_key_generate_prisma.py
2026-02-20 12:44:32 -03:00
Julio Quinteros Pro
2916a53fa5 fix(tests): skip all remaining prisma DB tests in test_key_generate_prisma.py
Add @pytest.mark.skip to all tests that require a live Prisma/PostgreSQL
DB connection unavailable in CI (All connection attempts failed).

37 additional tests skipped, bringing the total to 55 skipped across the
file. Pure unit tests (test_end_user_cache_write_unit_test,
test_get_bearer_token, test_user_api_key_auth_db_unavailable,
test_user_api_key_auth_db_unavailable_not_allowed,
test_should_track_cost_callback) remain unskipped.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 12:36:59 -03:00
jquinter
6af3d073f0
Merge pull request #21676 from BerriAI/fix/schema-migration-test-and-audit-log-skip
fix(tests): skip prisma DB test and sync root schema.prisma with spec_path
2026-02-20 12:33:11 -03:00
jquinter
2446c05eea
Merge pull request #21675 from BerriAI/fix/skip-project-endpoints-prisma-tests
fix(tests): skip project endpoint tests requiring Prisma DB connection
2026-02-20 12:32:43 -03:00
Julio Quinteros Pro
81faad5d0d fix(tests): skip prisma DB test and sync root schema.prisma with spec_path field
- Add @pytest.mark.skip to test_create_audit_log_in_db which requires
  a live Prisma/PostgreSQL DB connection unavailable in CI
- Sync root schema.prisma with litellm/proxy/schema.prisma by adding
  the spec_path field to LiteLLM_MCPServerTable, fixing
  test_aaaasschema_migration_check which detected this drift

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 12:29:53 -03:00
jquinter
db0c309a31
Merge pull request #21670 from BerriAI/fix/gemini3-medium-reasoning-effort-test
fix(tests): correct medium reasoning_effort assertion for gemini-3-pro-preview
2026-02-20 12:19:19 -03:00
jquinter
9ea5f52583
Merge pull request #21669 from BerriAI/fix/skip-tests-requiring-external-services
fix(tests): skip CI tests requiring external services (DB, API keys)
2026-02-20 12:18:56 -03:00
Julio Quinteros Pro
0a939a3b36 fix(tests): skip project endpoint tests requiring Prisma DB connection
All 4 tests in test_project_endpoints_prisma.py fail with
"All connection attempts failed" because DATABASE_URL is empty in CI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 12:18:49 -03:00
jquinter
eb2781552b
Merge pull request #21668 from BerriAI/fix/model-max-budget-test-needs-premium-user
fix(tests): set premium_user=True in test_aasync_call_with_key_over_model_budget
2026-02-20 12:18:29 -03:00
Julio Quinteros Pro
87577eb05c fix(tests): correct medium reasoning_effort assertion for gemini-3-pro-preview
For gemini-3-pro-preview (not gemini-3-flash or gemini-3.1-pro-preview),
reasoning_effort="medium" maps to thinkingLevel="high" because the "medium"
thinking level is not available on that model variant.

Both test_reasoning_effort_maps_to_thinking_level_gemini_3 and
test_reasoning_effort_dict_format_gemini_3 had the correct comment
("medium -> high") but the wrong assertion (== "medium"). Fixed to
match the production code and the comments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 12:09:26 -03:00
jquinter
1a2038c08b
Merge pull request #21671 from BerriAI/fix/skip-more-external-service-tests
fix(tests): skip more CI tests requiring external DB/Redis connections
2026-02-20 11:55:36 -03:00
Julio Quinteros Pro
3dd58b42ce fix(tests): skip more CI tests requiring external DB/Redis connections
Mark additional tests that fail due to unavailable Prisma DB or Redis
in CI with @pytest.mark.skip.

test_key_generate_prisma.py (Prisma DB):
- test_call_with_valid_model
- test_call_with_valid_model_using_all_models
- test_call_with_user_over_budget
- test_call_with_user_over_budget_stream
- test_call_with_proxy_over_budget
- test_call_with_proxy_over_budget_stream
- test_call_with_key_over_budget
- test_call_with_key_over_budget_no_cache
- test_call_with_key_over_budget_stream
- test_create_update_team

test_e2e_pod_lock_manager.py (Redis):
- test_pod_lock_acquisition_when_no_active_lock
- test_pod_lock_acquisition_after_completion
- test_pod_lock_acquisition_after_expiry
- test_pod_lock_release
- test_concurrent_lock_acquisition
- test_lock_acquisition_with_expired_ttl
- test_release_expired_lock
- test_e2e_size_of_redis_buffer

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 11:49:38 -03:00
Julio Quinteros Pro
ce59e6f00a fix(tests): use unconditional skip for vertex/gemini token counting test
The parametrized test covers both gemini-2.5-pro (needs GEMINI_API_KEY)
and vertex-ai-gemini-2.5-pro (needs VERTEX_AI_PRIVATE_KEY). A skipif
on GEMINI_API_KEY alone was insufficient for the vertex variant.
Switch to @pytest.mark.skip to guard both parametrizations consistently.

Addresses Greptile review comment on PR #21669.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 11:36:54 -03:00
Julio Quinteros Pro
174c17cec1 fix(tests): skip additional CI tests requiring external DB connection
Mark DB-dependent tests in test_key_generate_prisma.py and test_jwt.py
with @pytest.mark.skip to prevent CI failures when Prisma DB is unavailable.

Tests now skipped:
- test_call_with_invalid_key
- test_call_with_invalid_model
- test_call_with_end_user_over_budget
- test_aasync_call_with_key_over_model_budget (all 3 parametrize variants)
- test_call_with_key_never_over_budget
- test_aview_spend_per_user
- test_aadmin_only_routes
- test_auth_vertex_ai_route
- test_team_token_output (both audience variants)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 11:35:43 -03:00
Julio Quinteros Pro
3dfa3611d9 fix(tests): skip CI tests requiring external services (DB, API keys)
Mark tests that require Prisma DB connections or external API credentials
with @pytest.mark.skip / @pytest.mark.skipif so they don't block CI runs
when the infrastructure is unavailable.

Tests skipped:
- test_create_user_default_budget (Prisma DB)
- test_gemini_pass_through_endpoint (GEMINI_API_KEY / GOOGLE_API_KEY)
- test_vertex_ai_gemini_token_counting_with_contents (Google API creds)
- test_new/update/delete/info_project (Prisma DB)
- test_create/list/get/delete_skill_sdk (Prisma DB)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 11:28:42 -03:00
jquinter
39d95eb1b6
Merge pull request #21667 from BerriAI/fix/policy-endpoints-export-private-helpers
fix(policy_endpoints): re-export private helper functions from package __init__.py
2026-02-20 11:13:09 -03:00
Julio Quinteros Pro
1f6303677c fix(tests): set premium_user=True in test_aasync_call_with_key_over_model_budget
generate_key_fn calls validate_model_max_budget which raises
"You must have an enterprise license to set model_max_budget" unless
premium_user=True. The test was hitting this gate before it could
exercise the actual per-model budget logic, causing all three variants
to fail with an enterprise-check error instead of the expected budget
exceeded / pass-through result.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 11:12:38 -03:00
Julio Quinteros Pro
65388d877e fix(policy_endpoints): explicitly re-export private helper functions from __init__.py
`import *` does not re-export names starting with `_`, so the private
competitor-enrichment helpers added in endpoints.py were invisible when
imported from the package:

  from litellm.proxy.management_endpoints.policy_endpoints import (
      _build_all_names_per_competitor, ...
  )

This caused an ImportError that prevented the entire test module from
collecting. Add explicit imports for each private helper so they are
accessible from the package namespace.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 11:09:57 -03:00
jquinter
8f5561cf48
Merge pull request #21666 from BerriAI/fix/test-max-effort-error-message
fix(tests): update test_max_effort_rejected_for_opus_45 regex to match current error message
2026-02-20 11:09:22 -03:00
Julio Quinteros Pro
963e0eabcb fix(tests): update test_max_effort_rejected_for_opus_45 regex to match new error message
The production error message was expanded when Sonnet 4.6 was also added as
a supported model for effort='max'. The test's match regex still referenced
the old "Claude Opus 4.6"-only message; update it to match the new
"Claude 4.6 models" wording.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20 11:07:52 -03:00
Sameer Kankute
b62db9fcc9
Merge pull request #21663 from BerriAI/litellm_add_reasoning_support_config
[Feat] Add reasoning support via config
2026-02-20 18:17:09 +05:30
Sameer Kankute
164734fa45
Merge pull request #21662 from BerriAI/litellm_mcp_openapi_spec
[Fix]Add mcp via openapi spec
2026-02-20 18:16:30 +05:30
Sameer Kankute
9e0bd46c28
Merge pull request #21659 from BerriAI/litellm_fix_converse_disable_tool
Fix mapping of parallel_tool_calls for bedrock converse
2026-02-20 18:16:10 +05:30
Sameer Kankute
784ce97918
Merge pull request #21658 from BerriAI/litellm_fix_vertex_ai_messages
Fix: api_base is required. Unable to determine the correct api_base for the request
2026-02-20 18:15:30 +05:30
Sameer Kankute
bf024c0404
Merge pull request #21654 from BerriAI/litellm_new_gemini_pathc
Fix _map_reasoning_effort_to_thinking_level for all gemini 3 family
2026-02-20 18:14:47 +05:30
Sameer Kankute
5d8f2196d1 Add test case 2026-02-20 16:22:44 +05:30
Sameer Kankute
871c049f49 Add support for reasoning and tools viaconfig 2026-02-20 16:22:19 +05:30
Sameer Kankute
3cd9072539
Update ui/litellm-dashboard/tsconfig.json
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-02-20 14:08:38 +05:30
Sameer Kankute
f99ea619da Add search bar for enabling and calling tool 2026-02-20 13:57:58 +05:30
Sameer Kankute
ba74ee5a31 Add test for base url extraction and migration 2026-02-20 13:47:44 +05:30
Sameer Kankute
19b7b4019c Fix: server url extraction from spec_path 2026-02-20 13:46:59 +05:30
Sameer Kankute
b579f56ca3 Fix mapping of parallel_tool_calls for bedrock converse 2026-02-20 12:27:41 +05:30
Sameer Kankute
cdb4917185 Fix: api_base is required. Unable to determine the correct api_base for the request 2026-02-20 12:09:25 +05:30
yuneng-jiang
527f5c5d14
Merge pull request #21657 from BerriAI/litellm_knip_unused_files_cleanup
[Refactor] UI: Remove 38 unused files detected by knip
2026-02-19 22:22:21 -08:00