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
improve gigachat proxy route error handling
KnyazSheff086d8e00b
diff --git a/litellm/llms/gigachat/authenticator.py b/litellm/llms/gigachat/authenticator.pyindex 1821a209fed..ce6d4b3eca9 100644--- a/litellm/llms/gigachat/authenticator.py+++ b/litellm/llms/gigachat/authenticator.py@@ -163,12 +163,13 @@ async def get_access_token_async(# Request new tokentoken, expires_at = await _request_token_async(credentials, scope, auth_url)- # Cache token- ttl_seconds = max(- 0, (expires_at - TOKEN_EXPIRY_BUFFER_MS - time.time() * 1000) / 1000- )- if ttl_seconds > 0:- _token_cache.set_cache(cache_key, (token, expires_at), ttl=ttl_seconds)+ if expires_at:+ # Cache token+ ttl_seconds = max(+ 0, (expires_at - TOKEN_EXPIRY_BUFFER_MS - time.time() * 1000) / 1000+ )+ if ttl_seconds > 0:+ _token_cache.set_cache(cache_key, (token, expires_at), ttl=ttl_seconds)return tokendiff --git a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.pyindex aa4951bc258..ed9a4ac3028 100644--- a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py+++ b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py@@ -2403,23 +2403,28 @@ async def gigachat_proxy_route(## check for streamingrequest_body = await get_request_body(request)- is_router_model = is_passthrough_request_using_router_model(- request_body, llm_router- )+ is_router_model = Falsemodel = request_body.get("model")- if not model:- msg = "Model is required"- raise ValueError(msg)+ if model:+ is_router_model = is_passthrough_request_using_router_model(+ request_body, llm_router+ )+ elif any(word in endpoint for word in ("completions", "embeddings")):+ raise HTTPException(+ status_code=400, detail={"error": "Model is required in request body"}+ )+# If router model, use dedicated router passthrough handler# This uses the same common processing path as non-router models- if is_router_model and llm_router:+ if model and is_router_model and llm_router:return await handle_gigachat_passthrough_router_model(model=model,endpoint=endpoint,request=request,request_body=request_body,+ fastapi_response=fastapi_response,llm_router=llm_router,user_api_key_dict=user_api_key_dict,proxy_logging_obj=proxy_logging_obj,@@ -2490,6 +2495,7 @@ async def handle_gigachat_passthrough_router_model(endpoint: str,request: Request,request_body: dict,+ fastapi_response: Response,llm_router: litellm.Router,user_api_key_dict: UserAPIKeyAuth,proxy_logging_obj,@@ -2587,7 +2593,7 @@ async def handle_gigachat_passthrough_router_model(try:result = await base_llm_response_processor.base_passthrough_process_llm_request(request=request,- fastapi_response=FastAPIResponse(),+ fastapi_response=fastapi_response,user_api_key_dict=user_api_key_dict,proxy_logging_obj=proxy_logging_obj,llm_router=llm_router,