MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _spend_error_for_model

Function _spend_error_for_model

uncommon_route/proxy.py:4951–4963  ·  view source on GitHub ↗
(model_name: str)

Source from the content-addressed store, hash-verified

4949 _sync_virtual_debug_headers()
4950
4951 async def _spend_error_for_model(model_name: str) -> JSONResponse | None:
4952 if not is_virtual:
4953 return None
4954 _next_main_cost, total_cost = _estimated_total_cost_for(model_name)
4955 check = await _spend_reservation.update_reserve(request_id, total_cost)
4956 if check.allowed:
4957 return None
4958 _append_blocked_attempt(
4959 model_name,
4960 error_code="spend_limit_exceeded",
4961 error_message=check.reason or "Spending limit exceeded",
4962 )
4963 return _spend_error(check, api_format=api_format, headers=debug_headers)
4964
4965 def _should_try_fallback(status_code: int, content: bytes) -> bool:
4966 if not is_virtual or not fallback_models:

Callers 2

_select_stream_responseFunction · 0.85
_handle_chat_coreFunction · 0.85

Calls 4

_append_blocked_attemptFunction · 0.85
_spend_errorFunction · 0.85
update_reserveMethod · 0.80

Tested by

no test coverage detected