The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test(proxy): expect 422 for per-model budget rejections on cursor route
yassin92d3a1d87de6
diff --git a/tests/test_litellm/proxy/response_api_endpoints/test_endpoints.py b/tests/test_litellm/proxy/response_api_endpoints/test_endpoints.pyindex f7abb209015..4153bf7d7ee 100644--- a/tests/test_litellm/proxy/response_api_endpoints/test_endpoints.py+++ b/tests/test_litellm/proxy/response_api_endpoints/test_endpoints.py@@ -2099,7 +2099,7 @@ class TestCursorVariantPerModelBudgetEnforcement:response = _post_cursor_with_real_auth(valid_token, attrs, request_model="claude-opus-5-thinking-high")- assert response.status_code == 429, response.text+ assert response.status_code == 422, response.texterror = response.json()["error"]assert error["type"] == "budget_exceeded"assert "exceeded budget for model=claude-opus-5" in error["message"]@@ -2110,8 +2110,8 @@ class TestCursorVariantPerModelBudgetEnforcement:base_response = _post_cursor_with_real_auth(valid_token, attrs, request_model="claude-opus-5")alias_response = _post_cursor_with_real_auth(valid_token, attrs, request_model="claude-opus-5-fast")- assert base_response.status_code == 429, base_response.text- assert alias_response.status_code == 429, alias_response.text+ assert base_response.status_code == 422, base_response.text+ assert alias_response.status_code == 422, alias_response.textassert alias_response.json() == base_response.json()diff --git a/tests/test_litellm/proxy/test_proxy_server.py b/tests/test_litellm/proxy/test_proxy_server.pyindex f71f9c20f3b..950a6cc3c40 100644--- a/tests/test_litellm/proxy/test_proxy_server.py+++ b/tests/test_litellm/proxy/test_proxy_server.py@@ -10872,7 +10872,7 @@ async def test_realtime_session_rejected_in_pre_call_releases_the_budget_reserva"""A rate-limit or guardrail rejection happens before route_request, so therelay never runs and no success log can own the reservation. The endpointmust release it on that exit too, or the key stays pinned at the reserved- amount and its next requests 429 with budget_exceeded while /key/info shows+ amount and its next requests 422 with budget_exceeded while /key/info showsspend 0 (reproduced live with rpm_limit=1). The client still gets thepre-call error event and the 1011 close it got before."""reservation: Final = {"reserved_cost": 0.55, "input_cost": 0.0, "finalized": False, "entries": []}