Loading...
    • 开发者指南
    • API 参考
    • MCP
    • 资源
    • 发布说明
    Search...
    ⌘K

    第一步

    Claude 简介快速开始

    模型与定价

    模型概览选择模型Claude 4.5 的新功能迁移到 Claude 4.5模型弃用定价

    使用 Claude 构建

    功能概览使用 Messages API上下文窗口提示词最佳实践

    功能

    提示词缓存上下文编辑扩展思考流式消息批处理引用多语言支持Token 计数嵌入向量视觉PDF 支持Files API搜索结果Google Sheets 插件

    工具

    概述如何实现工具使用令牌高效的工具使用细粒度工具流式传输Bash 工具代码执行工具计算机使用工具文本编辑器工具Web fetch 工具网络搜索工具记忆工具

    代理技能

    概述在 API 中开始使用 Agent Skills技能创作最佳实践通过 API 使用 Agent Skills

    Agent SDK

    概览TypeScript SDKPython 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 官方 客户端 SDK 的支持。本指南将引导您完成在 Python 或 TypeScript 中向 Vertex AI 上的 Claude 发出请求的过程。

    请注意,本指南假设您已经拥有能够使用 Vertex AI 的 GCP 项目。有关所需的设置以及完整的演练,请参阅 使用 Anthropic 的 Claude 3 模型。

    安装用于访问 Vertex AI 的 SDK

    首先,为您选择的语言安装 Anthropic 的 客户端 SDK。

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

    访问 Vertex AI

    模型可用性

    请注意,Anthropic 模型的可用性因地区而异。在 Vertex AI 模型库 中搜索"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)

    有关更多详情,请参阅我们的 客户端 SDK 和官方 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"  # Specify a specific region
    
    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