mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
(Feat) pass through vertex - allow using credentials defined on litellm router for vertex pass through (#8100)
* test_add_vertex_pass_through_deployment * VertexPassThroughRouter * fix use_in_pass_through * VertexPassThroughRouter * fix vertex_credentials * allow using _initialize_deployment_for_pass_through * test_add_vertex_pass_through_deployment * _set_default_vertex_config * fix verbose_proxy_logger * fix use_in_pass_through * fix _get_token_and_url * test_get_vertex_location_from_url * test_get_vertex_credentials_none * run pt unit testing again * fix add_vertex_credentials * test_adding_deployments.py * rename file
This commit is contained in:
parent
892581ffc3
commit
b6d61ec22b
7 changed files with 490 additions and 19 deletions
|
@ -4133,8 +4133,48 @@ class Router:
|
|||
litellm_router_instance=self, model=deployment.to_json(exclude_none=True)
|
||||
)
|
||||
|
||||
self._initialize_deployment_for_pass_through(
|
||||
deployment=deployment,
|
||||
custom_llm_provider=custom_llm_provider,
|
||||
model=deployment.litellm_params.model,
|
||||
)
|
||||
|
||||
return deployment
|
||||
|
||||
def _initialize_deployment_for_pass_through(
|
||||
self, deployment: Deployment, custom_llm_provider: str, model: str
|
||||
):
|
||||
"""
|
||||
Optional: Initialize deployment for pass-through endpoints if `deployment.litellm_params.use_in_pass_through` is True
|
||||
|
||||
Each provider uses diff .env vars for pass-through endpoints, this helper uses the deployment credentials to set the .env vars for pass-through endpoints
|
||||
"""
|
||||
if deployment.litellm_params.use_in_pass_through is True:
|
||||
if custom_llm_provider == "vertex_ai":
|
||||
from litellm.proxy.vertex_ai_endpoints.vertex_endpoints import (
|
||||
vertex_pass_through_router,
|
||||
)
|
||||
|
||||
if (
|
||||
deployment.litellm_params.vertex_project is None
|
||||
or deployment.litellm_params.vertex_location is None
|
||||
or deployment.litellm_params.vertex_credentials is None
|
||||
):
|
||||
raise ValueError(
|
||||
"vertex_project, vertex_location, and vertex_credentials must be set in litellm_params for pass-through endpoints"
|
||||
)
|
||||
vertex_pass_through_router.add_vertex_credentials(
|
||||
project_id=deployment.litellm_params.vertex_project,
|
||||
location=deployment.litellm_params.vertex_location,
|
||||
vertex_credentials=deployment.litellm_params.vertex_credentials,
|
||||
)
|
||||
else:
|
||||
verbose_router_logger.error(
|
||||
f"Unsupported provider - {custom_llm_provider} for pass-through endpoints"
|
||||
)
|
||||
pass
|
||||
pass
|
||||
|
||||
def add_deployment(self, deployment: Deployment) -> Optional[Deployment]:
|
||||
"""
|
||||
Parameters:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue