fix(vertex): api base url was malformed for self hosted models

This commit is contained in:
stvnksslr 2026-05-15 11:00:04 -04:00 committed by Steven Kessler
parent c2efe9e422
commit 18e7e0c39e
No known key found for this signature in database

View file

@ -120,31 +120,18 @@ class VertexAIModelGardenModels(VertexBase):
## CONSTRUCT API BASE
stream: bool = optional_params.get("stream", False) or False
optional_params["stream"] = stream
default_api_base = create_vertex_url(
vertex_location=vertex_location or "us-central1",
vertex_project=vertex_project or project_id,
stream=stream,
model=model,
)
if len(default_api_base.split(":")) > 1:
endpoint = default_api_base.split(":")[-1]
if api_base is not None:
# User provided a custom api_base (e.g. Model Garden mg-endpoint URL).
# Use it directly — OpenAILikeChatHandler appends /chat/completions.
pass
else:
endpoint = ""
_, api_base = self._check_custom_proxy(
api_base=api_base,
custom_llm_provider="vertex_ai",
gemini_api_key=None,
endpoint=endpoint,
stream=stream,
auth_header=None,
url=default_api_base,
model=model,
vertex_project=vertex_project or project_id,
vertex_location=vertex_location or "us-central1",
vertex_api_version="v1beta1",
)
api_base = create_vertex_url(
vertex_location=vertex_location or "us-central1",
vertex_project=vertex_project or project_id,
stream=stream,
model=model,
)
# Publisher/catalog models: model id must be sent in the JSON body (OpenAPI route).
# Single-segment endpoint ids: model is encoded in the URL path; body model stays empty.
if not _vertex_model_garden_model_id_in_json_body(model):