AWS Claude API
本文按 AWS Bedrock 官方文档整理,完整展示 AWS Bedrock 上 Claude 的 Converse API 与 InvokeModel + Anthropic 风格请求体 两种官方调用方式。
鉴权方式
- 使用 AWS 凭证进行 SigV4 签名。
- 运行时服务:
bedrock-runtime
请求地址
1. Bedrock Converse API
- 方法:
POST - 路径:
/model/{modelId}/converse - 完整 REST 形态:
https://bedrock-runtime.{region}.amazonaws.com/model/{modelId}/converse
2. Bedrock ConverseStream API
- 方法:
POST - 路径:
/model/{modelId}/converse-stream
3. Bedrock InvokeModel + Anthropic 风格请求体
- 方法:
POST - 路径:
/model/{modelId}/invoke - 完整 REST 形态:
https://bedrock-runtime.{region}.amazonaws.com/model/{modelId}/invoke
请求参数
Converse API 请求参数
Anthropic 风格请求体参数
请求示例
Converse API
curl
aws bedrock-runtime converse \
--region us-east-1 \
--model-id anthropic.claude-3-7-sonnet-20250219-v1:0 \
--messages '[
{
"role": "user",
"content": [
{
"text": "Summarize GGPU Platform in one paragraph."
}
]
}
]' \
--inference-config '{
"maxTokens": 256,
"temperature": 0.7
}'Anthropic 风格请求体 + InvokeModel
curl
aws bedrock-runtime invoke-model \
--region us-east-1 \
--model-id anthropic.claude-3-7-sonnet-20250219-v1:0 \
--content-type application/json \
--accept application/json \
--body '{
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 256,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Summarize GGPU Platform in one paragraph."
}
]
}
],
"temperature": 0.7
}' \
output.json请求返回结果
Converse API 返回结果
Anthropic 风格返回结果
请求返回示例
Converse API 返回示例
{
"output": {
"message": {
"role": "assistant",
"content": [
{
"text": "GGPU Platform helps teams orchestrate AI workflows through a unified runtime and integration layer."
}
]
}
},
"stopReason": "end_turn",
"usage": {
"inputTokens": 14,
"outputTokens": 18,
"totalTokens": 32
},
"metrics": {
"latencyMs": 842
}
}Anthropic 风格返回示例
{
"id": "msg_bdrk_01KqZ6mR9L9y7b4Lw6mB9v3",
"type": "message",
"role": "assistant",
"model": "anthropic.claude-3-7-sonnet-20250219-v1:0",
"content": [
{
"type": "text",
"text": "GGPU Platform helps teams orchestrate AI workflows through a unified runtime and integration layer."
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 14,
"output_tokens": 18
}
}说明
- Bedrock 上 Claude 主要有两套官方接入方式:
Converse和InvokeModel + Anthropic 协议请求体。 - 如果你要写“原生 Claude 风格”文档,通常应展示
InvokeModel的 body 结构;如果你要写“Bedrock 通用对话接口”文档,应展示Converse。 - 更细的多模态 content block、tool use、streaming event 结构请以 AWS 官方文档为准。