Loading...
    • 開發者指南
    • API 參考
    • MCP
    • 資源
    • 發行說明
    Search...
    ⌘K

    第一步

    Claude 介紹快速入門

    模型與定價

    模型概覽選擇模型Claude 4.5 的新功能遷移到 Claude 4.5模型棄用定價

    使用 Claude 建構

    功能概覽使用 Messages API上下文視窗提示詞最佳實踐

    功能

    提示詞快取上下文編輯延伸思考串流訊息批次處理引用多語言支援Token 計數嵌入向量視覺PDF 支援Files API搜尋結果Google Sheets 附加元件

    工具

    概述如何實現工具使用代幣高效工具使用細粒度工具串流Bash 工具代碼執行工具電腦使用工具文字編輯工具網頁擷取工具網路搜尋工具記憶工具

    代理技能

    概述在 API 中開始使用 Agent Skills技能編寫最佳實踐使用 Agent Skills 與 API

    Agent SDK

    概述Agent SDK 參考 - TypeScriptPython SDK

    指南

    串流輸入處理權限會話管理託管 Agent SDK修改系統提示SDK 中的 MCP自訂工具SDK 中的子代理SDK 中的斜線命令SDK 中的代理技能追蹤成本和使用量待辦事項清單SDK 中的外掛程式

    API 中的 MCP

    MCP 連接器遠端 MCP 伺服器

    Claude 在第三方平台上

    Amazon BedrockVertex AI

    提示工程

    概述提示詞生成器使用提示模板提示詞改進器保持清晰和直接使用範例(多樣提示)讓 Claude 思考(思維鏈)使用 XML 標籤給 Claude 分配角色(系統提示詞)預填 Claude 的回應串接複雜提示長文本技巧延伸思考技巧

    測試與評估

    定義成功標準開發測試案例使用評估工具降低延遲

    加強防護措施

    減少幻覺提高輸出一致性防範越獄handle-streaming-refusals減少提示詞洩漏保持 Claude 的角色特性

    管理和監控

    Admin API 概述使用量和成本 APIClaude Code 分析 API
    Console
    Claude 在第三方平台上

    Vertex AI 上的 Claude

    Anthropic 的 Claude 模型現已通過 Vertex AI 正式推出。

    用於存取 Claude 的 Vertex API 幾乎與 Messages API 相同,並支援所有相同的選項,但有兩個主要差異:

    • 在 Vertex 中,model 不在請求正文中傳遞。相反,它在 Google Cloud 端點 URL 中指定。
    • 在 Vertex 中,anthropic_version 在請求正文中傳遞(而不是作為標頭),並且必須設定為值 vertex-2023-10-16。

    Vertex 也受到 Anthropic 官方 client SDKs 的支援。本指南將引導您完成使用 Python 或 TypeScript 向 Vertex AI 上的 Claude 發出請求的過程。

    請注意,本指南假設您已經擁有能夠使用 Vertex AI 的 GCP 專案。有關所需的設定以及完整的逐步說明,請參閱 使用 Anthropic 的 Claude 3 模型。

    安裝用於存取 Vertex AI 的 SDK

    首先,為您選擇的語言安裝 Anthropic 的 client SDK。

    Python
    pip install -U google-cloud-aiplatform "anthropic[vertex]"
    TypeScript
    npm install @anthropic-ai/vertex-sdk

    存取 Vertex AI

    模型可用性

    請注意,Anthropic 模型的可用性因地區而異。在 Vertex AI Model Garden 中搜尋「Claude」或前往 使用 Claude 3 以取得最新資訊。

    API 模型 ID

    模型Vertex AI API 模型 ID
    Claude Sonnet 4.5claude-sonnet-4-5@20250929
    Claude Sonnet 4claude-sonnet-4@20250514
    Claude Sonnet 3.7 claude-3-7-sonnet@20250219
    Claude Opus 4.1claude-opus-4-1@20250805
    Claude Opus 4claude-opus-4@20250514
    Claude Opus 3 claude-3-opus@20240229
    Claude Haiku 4.5claude-haiku-4-5@20251001
    Claude Haiku 3.5claude-3-5-haiku@20241022
    Claude Haiku 3claude-3-haiku@20240307

    發出請求

    在執行請求之前,您可能需要執行 gcloud auth application-default login 以使用 GCP 進行身份驗證。

    以下範例顯示如何從 Vertex AI 上的 Claude 產生文字:

    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-sonnet-4-5@20250929",
        max_tokens=100,
        messages=[
            {
                "role": "user",
                "content": "Hey Claude!",
            }
        ],
    )
    print(message)

    如需更多詳細資訊,請參閱我們的 client SDKs 和官方 Vertex AI 文件。

    活動記錄

    Vertex 提供 請求-回應記錄服務,允許客戶記錄與您的使用相關的提示和完成。

    Anthropic 建議您至少在 30 天滾動基礎上記錄您的活動,以便瞭解您的活動並調查任何潛在的濫用。

    啟用此服務不會給 Google 或 Anthropic 任何存取您內容的權限。

    功能支援

    您可以在 此處 找到 Vertex 上目前支援的所有功能。

    全球端點與區域端點

    從 Claude Sonnet 4.5 和所有未來模型 開始,Google Vertex AI 提供兩種端點類型:

    • 全球端點:動態路由以實現最大可用性
    • 區域端點:保證透過特定地理區域的資料路由

    區域端點的定價比全球端點高 10%。

    這僅適用於 Claude Sonnet 4.5 和未來的模型。較舊的模型(Claude Sonnet 4、Opus 4 及更早版本)保持其現有的定價結構。

    何時使用各選項

    全球端點(推薦):

    • 提供最大可用性和正常運行時間
    • 動態將請求路由到具有可用容量的區域
    • 無定價溢價
    • 最適合資料駐留靈活的應用程式
    • 僅支援按使用量付費流量(佈建的輸送量需要區域端點)

    區域端點:

    • 透過特定地理區域路由流量
    • 資料駐留和合規性要求所需
    • 支援按使用量付費和佈建的輸送量
    • 10% 的定價溢價反映了專用區域容量的基礎設施成本

    實施

    使用全球端點(推薦):

    初始化用戶端時將 region 參數設定為 "global":

    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-sonnet-4-5@20250929",
        max_tokens=100,
        messages=[
            {
                "role": "user",
                "content": "Hey Claude!",
            }
        ],
    )
    print(message)

    使用區域端點:

    指定特定區域,例如 "us-east1" 或 "europe-west1":

    from anthropic import AnthropicVertex
    
    project_id = "MY_PROJECT_ID"
    region = "us-east1"  # 指定特定區域
    
    client = AnthropicVertex(project_id=project_id, region=region)
    
    message = client.messages.create(
        model="claude-sonnet-4-5@20250929",
        max_tokens=100,
        messages=[
            {
                "role": "user",
                "content": "Hey Claude!",
            }
        ],
    )
    print(message)

    其他資源

    • Google Vertex AI 定價: cloud.google.com/vertex-ai/generative-ai/pricing
    • Claude 模型文件: Vertex AI 上的 Claude
    • Google 部落格文章: Claude 模型的全球端點
    • Anthropic 定價詳細資訊: 定價文件
    • 安裝用於存取 Vertex AI 的 SDK
    • 存取 Vertex AI
    © 2025 ANTHROPIC PBC

    Products

    • Claude
    • Claude Code
    • Max plan
    • Team plan
    • Enterprise plan
    • Download app
    • Pricing
    • Log in

    Features

    • Claude and Slack
    • Claude in Excel

    Models

    • Opus
    • Sonnet
    • Haiku

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Claude Developer Platform

    • Overview
    • Developer docs
    • Pricing
    • Amazon Bedrock
    • Google Cloud’s Vertex AI
    • Console login

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Help and security

    • Availability
    • Status
    • Support center

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy

    Products

    • Claude
    • Claude Code
    • Max plan
    • Team plan
    • Enterprise plan
    • Download app
    • Pricing
    • Log in

    Features

    • Claude and Slack
    • Claude in Excel

    Models

    • Opus
    • Sonnet
    • Haiku

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Claude Developer Platform

    • Overview
    • Developer docs
    • Pricing
    • Amazon Bedrock
    • Google Cloud’s Vertex AI
    • Console login

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Help and security

    • Availability
    • Status
    • Support center

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy
    © 2025 ANTHROPIC PBC