Claude Models on Google Cloud (Google managed)
Google 將 Claude Models on Google Cloud (Google managed) 作為 Google Cloud's Agent Platform 的一部分來營運。您可以使用 Anthropic 的用戶端 SDK 呼叫 Claude。
Claude Models on Google Cloud 比較了這兩種 Google Cloud 方案,並說明如何判斷您使用的是哪一種。
進行 API 呼叫之前
若要使用 Claude Models on Google Cloud (Google managed),您需要:
- 一個可以使用 Agent Platform 的 Google Cloud 專案。如需設定步驟,請參閱 Google Cloud 的 Anthropic Claude models on Agent Platform 頁面。
- 已安裝 gcloud CLI,用於本機開發。
- 對於進行呼叫的身分,需要一個包含
aiplatform.endpoints.predict權限的 IAM 角色,例如 Agent Platform User(roles/aiplatform.user)。如需詳細資訊,請參閱 Google Cloud 的 Agent Platform partner models 頁面。 - 該身分的 Google Cloud 憑證。對於 SDK 範例,您可能需要執行
gcloud auth application-default login以向 Google Cloud 進行驗證。Claude Models on Google Cloud (Google managed) 的 cURL 範例會透過gcloud auth print-access-token取得權杖。該命令使用 gcloud CLI 本身的登入,而非 Application Default Credentials。對於這些範例,請先執行gcloud auth login或gcloud init。
安裝 SDK
Anthropic 的用戶端 SDK 透過 AnthropicVertex 支援 Claude Models on Google Cloud (Google managed)。請安裝提供它的套件:
pip install -U "anthropic[vertex]"ant CLI 不支援 Claude Models on Google Cloud (Google managed)。
發送請求
對 Claude Models on Google Cloud (Google managed) 的請求會傳送至以 :rawPredict 結尾的 Agent Platform 端點 URL。「Streaming」(串流)請求則改用 :streamRawPredict。
請求與 Messages API 請求幾乎相同,主要有兩點不同:
- 模型: 端點 URL 會指定模型。在 cURL 請求中,請勿在主體中包含
model。 - 版本: 在 cURL 請求中,請在主體中傳遞
anthropic_version,而非作為標頭。將其設為vertex-2023-10-16,或設定為 API 版本2026-10-21。
以下範例使用全域端點。如需其他端點類型,請參閱全域、多區域和區域端點。
from anthropic import AnthropicVertex
project_id = "MY_PROJECT_ID"
region = "global"
client = AnthropicVertex(project_id=project_id, region=region)
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=100,
messages=[
{
"role": "user",
"content": "Hey Claude!",
}
],
)
print(message)API 模型 ID
| Model | Agent Platform API model ID |
|---|---|
| Claude Fable 5.1 | |
| Claude Mythos 5.1 (limited availability(opens in new tab)) | |
| Claude Fable 5 | |
| Claude Mythos 5 (limited availability(opens in new tab)) | |
| Claude Opus 5.5 | |
| Claude Opus 5 | |
| Claude Opus 4.8 | |
| Claude Opus 4.7 | |
| Claude Opus 4.6 | |
| Claude Opus 4.5 | |
| Claude Opus 4.1 (deprecated) | |
| Claude Opus 4 (deprecated) | |
| Claude Sonnet 5.5 | |
| Claude Sonnet 5 | |
| Claude Sonnet 4.6 | |
| Claude Sonnet 4.5 (deprecated) | |
| Claude Sonnet 4 (deprecated) | |
| Claude Haiku 5.5 | |
| Claude Haiku 4.5 | |
| Claude Haiku 3.5 (deprecated) |
Claude Models on Google Cloud (Google managed) 在不同區域提供不同的 Claude 模型。若要查看某個區域提供哪些模型,請在 Model Garden 中搜尋「Claude」,或參閱 Google Cloud 的 Anthropic Claude models on Agent Platform 頁面。
Google 會為 Claude Models on Google Cloud (Google managed) 所提供的模型設定生命週期日期。這些日期可能與 Claude API 的時程不同。如需模型目前的停用日期,請參閱 Google Cloud 的 Anthropic Claude models on Agent Platform 頁面。如需了解「已棄用」和「已停用」的含義,請參閱模型棄用。
全域、多區域和區域端點
Claude Models on Google Cloud (Google managed) 提供三種端點類型。您可以透過建立用戶端時傳遞的區域值來選擇其中一種。在 cURL 請求中,端點類型會決定主機以及 URL 中的 locations 區段。
| 端點類型 | 區域值 | 主機 |
|---|---|---|
| 全域(建議) | "global" | aiplatform.googleapis.com |
| 多區域 | "us" 或 "eu" | aiplatform.us.rep.googleapis.comaiplatform.eu.rep.googleapis.com |
| 區域 | 某個區域,例如 "us-east5" | {region}-aiplatform.googleapis.com |
各端點類型的差異在於請求的傳送目的地:
- 全域: 請求會傳送至任何有可用容量的區域。當您希望獲得最高可用性且資料落地要求較有彈性時,請使用此類型。
- 多區域: 請求會傳送至美國(
"us")或歐盟("eu")內的任何區域。當您需要在較廣泛的地理範圍內實現資料落地,並需要比單一區域更高的可用性時,請使用此類型。 - 區域: 請求只會傳送至您指定的區域,例如
"us-east5"或"europe-west1"。當您需要單一區域的資料落地或必須符合嚴格的合規要求時,請使用此類型。
多區域和區域端點的費用比全域端點高 10%。三種端點類型都接受隨用隨付流量,而佈建輸送量則需要區域端點。
區域端點僅提供 Claude Sonnet 4.6 及更早的模型。對於較新的模型,請使用全域或多區域端點。
以下範例使用 us 多區域端點。醒目標示的行用於設定區域。如需在全域端點上的完整請求,請參閱發送請求。
from anthropic import AnthropicVertex
project_id = "MY_PROJECT_ID"
region = "us" # Multi-region identifier: "us" or "eu"
client = AnthropicVertex(project_id=project_id, region=region)功能支援
Claude Models on Google Cloud (Google managed) 支援的功能包括:
功能概覽列出了所有功能,以及 Claude Models on Google Cloud (Google managed) 是否支援這些功能。
不支援的功能
Claude Models on Google Cloud (Google managed) 不支援以下功能:
- 輸入來源: 圖片和文件的 URL 來源,以及 Files API
- 伺服器端工具: 程式碼執行、網頁擷取和 advisor
- 代理基礎架構: Agent Skills、MCP connector 和程式化工具呼叫
- API 端點: Message Batches API、Models API、Admin API、Compliance API,以及 Usage and Cost API
- Claude Managed Agents
- 伺服器端備援:
fallbacks參數
請改用用戶端備援模式來取代伺服器端備援。
上下文視窗
Claude Models on Google Cloud (Google managed) 為以下模型提供 1M token 的「context window」(上下文視窗):
- Claude Fable 5.1
- Claude Fable 5
- Claude Opus 5.5
- Claude Opus 5
- Claude Opus 4.8
- Claude Opus 4.7
- Claude Opus 4.6
- Claude Sonnet 5.5
- Claude Sonnet 5
- Claude Sonnet 4.6
- Claude Haiku 5.5
其他 Claude 模型的上下文視窗為 200k token,包括 Claude Sonnet 4.5(已棄用)和 Claude Sonnet 4(已棄用)。
Agent Platform 將請求酬載限制為 30 MB。當您傳送大型文件或大量圖片時,可能會在達到 token 限制之前先達到此限制。
計費、速率限制和日誌記錄
速率限制
Google Cloud 負責管理 Claude Models on Google Cloud (Google managed) 的「rate limit」(速率限制)和配額。如需詳細資訊,包括如何申請提高配額,請參閱 Google Cloud 的 Quotas for Anthropic Claude models 頁面。
計費
Google Cloud 會針對 Claude Models on Google Cloud (Google managed) 向您開立帳單。如需價格資訊,請參閱 Google Cloud 的 Generative AI pricing 頁面。價格也取決於端點類型。請參閱全域、多區域和區域端點。
資料保留
Google Cloud 負責管理 Claude Models on Google Cloud (Google managed) 的資料處理。如需詳細資訊,請參閱 Agent Platform and zero data retention。
監控和日誌記錄
若要記錄 Claude Models on Google Cloud (Google managed) 的提示和完成內容,請使用 Agent Platform 的請求-回應日誌記錄服務。
Anthropic 建議您至少保留最近 30 天的日誌。這些日誌可協助您了解您的活動並調查可能的濫用行為。
從 Claude Models on Google Cloud (Anthropic managed) 遷移
如需了解遷移時會有哪些變更,請參閱兩種 Google Cloud 方案的差異。若要遷移至 Claude Models on Google Cloud (Google managed),請依照以下步驟操作:
設定存取權
確認您的專案以及進行呼叫的身分符合進行 API 呼叫之前中的要求。
安裝 SDK 套件
安裝提供 Claude Models on Google Cloud (Google managed) 用戶端的套件。請參閱安裝 SDK。
替換匯入和用戶端
變更匯入和建立用戶端的程式碼。使用
AnthropicVertex取代AnthropicGoogleCloud。cURL 請求需要新的 URL、新的標頭和新的主體。以下程式碼會建立您目前使用的 Claude Models on Google Cloud (Anthropic managed) 用戶端:Pythonfrom anthropic import AnthropicGoogleCloud client = AnthropicGoogleCloud()以下程式碼會建立 Claude Models on Google Cloud (Google managed) 的用戶端,並使用全域端點。如需其他端點類型,請參閱全域、多區域和區域端點。
Pythonfrom anthropic import AnthropicVertex project_id = "MY_PROJECT_ID" region = "global" client = AnthropicVertex(project_id=project_id, region=region)此程式碼在建立用戶端時會傳遞您的專案 ID 和區域。請將
MY_PROJECT_ID替換為您的專案 ID。您使用該用戶端進行的 Messages API 呼叫維持不變,例外情況是下一步中的模型 ID 和功能。執行測試請求
執行發送請求中的請求,以確認您的設定可正常運作。然後執行您自己的程式碼。在移轉正式環境流量之前,請先閱讀 Claude Models on Google Cloud (Google managed) 的速率限制。
後續步驟
探索 Claude 的功能。
查看各區域提供哪些 Claude 模型及其停用日期。
閱讀 Google Cloud 的 Agent Platform 文件。
閱讀 Google Cloud 關於 Claude 模型全域端點的部落格文章。
Was this page helpful?