Skip to content

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]

fix(realtime): resolve the vertex token resolver at call time

Mateod643136895d6
diff --git a/litellm/realtime_api/main.py b/litellm/realtime_api/main.py
index 56b3931711e..4e02be36daa 100644
--- a/litellm/realtime_api/main.py
+++ b/litellm/realtime_api/main.py
@@ -2,7 +2,7 @@
import asyncio
import os
-from typing import Any, Final, cast
+from typing import Any, Final, Literal, cast
import litellm
from litellm.constants import (
@@ -43,7 +43,6 @@ openai_realtime: Final = OpenAIRealtime()
bedrock_realtime: Final = BedrockRealtime()
xai_realtime: Final = XAIRealtime()
vertex_llm_base: Final = VertexBase()
-vertex_access_token_resolver: Final[VertexAccessTokenResolver] = vertex_llm_base._ensure_access_token_async
base_llm_http_handler = BaseLLMHTTPHandler()
@@ -288,6 +287,18 @@ async def arealtime_calls(
)
+async def vertex_access_token_resolver(
+ credentials: VERTEX_CREDENTIALS_TYPES | None,
+ project_id: str | None,
+ custom_llm_provider: Literal["vertex_ai", "vertex_ai_beta", "gemini"],
+) -> tuple[str, str]:
+ return await vertex_llm_base._ensure_access_token_async(
+ credentials=credentials,
+ project_id=project_id,
+ custom_llm_provider=custom_llm_provider,
+ )
+
+
async def _resolve_vertex_access_token_bounded(
credentials: VERTEX_CREDENTIALS_TYPES | None,
project_id: str | None,