跳至主要內容

Vertex AI - 自行部署模型

透過 Model Garden 或自訂端點,在 Vertex AI 上部署並使用您自己的模型。

Model Garden

提示

Vertex Model Garden 中所有與 OpenAI 相容的模型皆受支援。

使用 Model Garden

幾乎所有 Vertex Model Garden 模型都與 OpenAI 相容。

屬性詳細資料
提供者路由vertex_ai/openai/{MODEL_ID}
Vertex 文件Model Garden LiteLLM 推論, Vertex Model Garden
支援的操作/chat/completions, /embeddings
from litellm import completion
import os

## set ENV variables
os.environ["VERTEXAI_PROJECT"] = "hardy-device-38811"
os.environ["VERTEXAI_LOCATION"] = "us-central1"

response = completion(
model="vertex_ai/openai/<your-endpoint-id>",
messages=[{ "content": "Hello, how are you?","role": "user"}]
)

Gemma 模型(自訂端點)

在具備 OpenAI 相容格式的自訂 Vertex AI 預測端點上部署 Gemma 模型。

屬性詳細資料
提供者路由vertex_ai/gemma/{MODEL_NAME}
Vertex 文件Vertex AI Prediction
必要參數api_base - 完整的預測端點 URL

Proxy 使用方式:

1. 新增至 config.yaml

model_list:
- model_name: gemma-model
litellm_params:
model: vertex_ai/gemma/gemma-3-12b-it-1222199011122
api_base: https://ENDPOINT.us-central1-PROJECT.prediction.vertexai.goog/v1/projects/PROJECT_ID/locations/us-central1/endpoints/ENDPOINT_ID:predict
vertex_project: "my-project-id"
vertex_location: "us-central1"

2. 啟動 proxy

litellm --config /path/to/config.yaml

3. 測試它

curl http://0.0.0.0:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-1234" \
-d '{
"model": "gemma-model",
"messages": [{"role": "user", "content": "What is machine learning?"}],
"max_tokens": 100
}'

SDK 使用方式:

from litellm import completion

response = completion(
model="vertex_ai/gemma/gemma-3-12b-it-1222199011122",
messages=[{"role": "user", "content": "What is machine learning?"}],
api_base="https://ENDPOINT.us-central1-PROJECT.prediction.vertexai.goog/v1/projects/PROJECT_ID/locations/us-central1/endpoints/ENDPOINT_ID:predict",
vertex_project="my-project-id",
vertex_location="us-central1",
)

MedGemma 模型(自訂端點)

在具備 OpenAI 相容格式的自訂 Vertex AI 預測端點上部署 MedGemma 模型。MedGemma 模型使用相同的 vertex_ai/gemma/ 路由。

屬性詳細資料
提供者路由vertex_ai/gemma/{MODEL_NAME}
Vertex 文件Vertex AI Prediction
必要參數api_base - 完整的預測端點 URL

Proxy 使用方式:

1. 新增至 config.yaml

model_list:
- model_name: medgemma-model
litellm_params:
model: vertex_ai/gemma/medgemma-2b-v1
api_base: https://ENDPOINT.us-central1-PROJECT.prediction.vertexai.goog/v1/projects/PROJECT_ID/locations/us-central1/endpoints/ENDPOINT_ID:predict
vertex_project: "my-project-id"
vertex_location: "us-central1"

2. 啟動 proxy

litellm --config /path/to/config.yaml

3. 測試它

curl http://0.0.0.0:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-1234" \
-d '{
"model": "medgemma-model",
"messages": [{"role": "user", "content": "What are the symptoms of hypertension?"}],
"max_tokens": 100
}'

SDK 使用方式:

from litellm import completion

response = completion(
model="vertex_ai/gemma/medgemma-2b-v1",
messages=[{"role": "user", "content": "What are the symptoms of hypertension?"}],
api_base="https://ENDPOINT.us-central1-PROJECT.prediction.vertexai.goog/v1/projects/PROJECT_ID/locations/us-central1/endpoints/ENDPOINT_ID:predict",
vertex_project="my-project-id",
vertex_location="us-central1",
)
🚅
LiteLLM Enterprise
為正式環境打造的 SSO/SAML、稽核記錄、支出追蹤、多團隊管理與防護欄。
深入瞭解 →