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 在第三方平台上

    Amazon Bedrock 上的 Claude

    Anthropic 的 Claude 模型現已通過 Amazon Bedrock 正式推出。

    通過 Bedrock 呼叫 Claude 與使用 Anthropic 用戶端 SDK 呼叫 Claude 的方式略有不同。本指南將引導您完成通過 Python 或 TypeScript 向 Bedrock 上的 Claude 進行 API 呼叫的過程。

    請注意,本指南假設您已經註冊了 AWS 帳戶並配置了程式化存取。

    安裝並配置 AWS CLI

    1. 安裝版本為 2.13.23 或更新版本的 AWS CLI
    2. 使用 AWS configure 命令配置您的 AWS 認證(請參閱配置 AWS CLI),或透過在 AWS 儀表板中導航至「命令列或程式化存取」並按照彈出式模態視窗中的指示來尋找您的認證。
    3. 驗證您的認證是否正常運作:
    Shell
    aws sts get-caller-identity

    安裝用於存取 Bedrock 的 SDK

    Anthropic 的用戶端 SDK 支援 Bedrock。您也可以直接使用 AWS SDK(如 boto3)。

    pip install -U "anthropic[bedrock]"

    存取 Bedrock

    訂閱 Anthropic 模型

    前往 AWS 主控台 > Bedrock > 模型存取並請求存取 Anthropic 模型。請注意,Anthropic 模型的可用性因地區而異。有關最新資訊,請參閱 AWS 文件。

    API 模型 ID

    模型基礎 Bedrock 模型 IDglobaluseujpapac
    Claude Sonnet 4.5anthropic.claude-sonnet-4-5-20250929-v1:0是是是是否
    Claude Sonnet 4anthropic.claude-sonnet-4-20250514-v1:0是是是否是
    Claude Sonnet 3.7 anthropic.claude-3-7-sonnet-20250219-v1:0否是是否是
    Claude Opus 4.1anthropic.claude-opus-4-1-20250805-v1:0否是否否否
    Claude Opus 4anthropic.claude-opus-4-20250514-v1:0否是否否否
    Claude Opus 3 anthropic.claude-3-opus-20240229-v1:0否是否否否
    Claude Haiku 4.5anthropic.claude-haiku-4-5-20251001-v1:0是是是否否
    Claude Haiku 3.5anthropic.claude-3-5-haiku-20241022-v1:0否是否否否
    Claude Haiku 3anthropic.claude-3-haiku-20240307-v1:0否是是否是

    有關區域與全域模型 ID 的更多資訊,請參閱下方的全域與區域端點部分。

    列出可用模型

    以下範例顯示如何列印通過 Bedrock 提供的所有 Claude 模型:

    aws bedrock list-foundation-models --region=us-west-2 --by-provider anthropic --query "modelSummaries[*].modelId"

    進行請求

    以下範例顯示如何從 Bedrock 上的 Claude 生成文字:

    from anthropic import AnthropicBedrock
    
    client = AnthropicBedrock(
        # 透過提供以下金鑰進行驗證,或使用預設的 AWS 認證提供者,例如
        # 使用 ~/.aws/credentials 或 "AWS_SECRET_ACCESS_KEY" 和 "AWS_ACCESS_KEY_ID" 環境變數。
        aws_access_key="<access key>",
        aws_secret_key="<secret key>",
        # 臨時認證可與 aws_session_token 一起使用。
        # 在 https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html 閱讀更多資訊。
        aws_session_token="<session_token>",
        # aws_region 變更進行請求的 AWS 區域。預設情況下,我們讀取 AWS_REGION,
        # 如果不存在,我們預設為 us-east-1。請注意,我們不讀取 ~/.aws/config 中的區域。
        aws_region="us-west-2",
    )
    
    message = client.messages.create(
        model="global.anthropic.claude-sonnet-4-5-20250929-v1:0",
        max_tokens=256,
        messages=[{"role": "user", "content": "Hello, world"}]
    )
    print(message.content)

    有關更多詳細資訊,請參閱我們的用戶端 SDK,以及官方 Bedrock 文件此處。

    活動日誌

    Bedrock 提供了一項呼叫日誌服務,允許客戶記錄與您的使用相關的提示和完成。

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

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

    功能支援

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

    Bedrock 上的 PDF 支援

    PDF 支援可通過 Converse API 和 InvokeModel API 在 Amazon Bedrock 上使用。有關 PDF 處理功能和限制的詳細資訊,請參閱 PDF 支援文件。

    Converse API 使用者的重要考慮事項:

    • 視覺 PDF 分析(圖表、影像、版面配置)需要啟用引用
    • 沒有引用,只能進行基本文字提取
    • 為了完全控制而不強制引用,請使用 InvokeModel API

    有關兩種文件處理模式及其限制的更多詳細資訊,請參閱 PDF 支援指南。

    100 萬個 Token 上下文視窗

    Claude Sonnet 4 和 4.5 在 Amazon Bedrock 上支援 100 萬個 Token 上下文視窗。

    100 萬個 Token 上下文視窗目前處於測試版。若要使用擴展上下文視窗,請在您的 Bedrock API 請求中包含 context-1m-2025-08-07 測試版標頭。

    全域與區域端點

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

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

    區域端點包括相對於全域端點的 10% 定價溢價。

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

    何時使用各選項

    全域端點(推薦):

    • 提供最大可用性和正常運行時間
    • 動態將請求路由到具有可用容量的區域
    • 無定價溢價
    • 最適合資料駐留靈活的應用程式

    區域端點 (CRIS):

    • 透過特定地理區域路由流量
    • 資料駐留和合規性要求所需
    • 適用於美國、歐盟、日本和澳洲
    • 10% 定價溢價反映了專用區域容量的基礎設施成本

    實施

    使用全域端點(Sonnet 4.5 和 4 的預設值):

    Claude Sonnet 4.5 和 4 的模型 ID 已包含 global. 前綴:

    from anthropic import AnthropicBedrock
    
    client = AnthropicBedrock(aws_region="us-west-2")
    
    message = client.messages.create(
        model="global.anthropic.claude-sonnet-4-5-20250929-v1:0",
        max_tokens=256,
        messages=[{"role": "user", "content": "Hello, world"}]
    )

    使用區域端點 (CRIS):

    若要使用區域端點,請從模型 ID 中移除 global. 前綴:

    from anthropic import AnthropicBedrock
    
    client = AnthropicBedrock(aws_region="us-west-2")
    
    # 使用美國區域端點 (CRIS)
    message = client.messages.create(
        model="anthropic.claude-sonnet-4-5-20250929-v1:0",  # 沒有 global. 前綴
        max_tokens=256,
        messages=[{"role": "user", "content": "Hello, world"}]
    )

    其他資源

    • AWS Bedrock 定價: aws.amazon.com/bedrock/pricing
    • AWS 定價文件: Bedrock 定價指南
    • AWS 部落格文章: 在 Amazon Bedrock 中推出 Claude Sonnet 4.5
    • Anthropic 定價詳細資訊: 定價文件
    • 安裝並配置 AWS CLI
    • 安裝用於存取 Bedrock 的 SDK
    • 存取 Bedrock
    • 訂閱 Anthropic 模型
    • Bedrock 上的 PDF 支援
    • 100 萬個 Token 上下文視窗
    © 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