API 支持:用法因产品而异。
- Messages API:在每个请求中设置
inference_geo,或为工作区设置默认值。 - Managed Agents:在智能体的模型配置中固定
inference_geo;在创建会话时覆盖它。
“Data residency”(数据驻留)控制让您可以管理数据的处理和存储位置。有两个相互独立的设置对此进行管理:
- 推理地理位置(Inference geo): 按请求控制模型推理的运行位置。通过
inference_geoAPI 参数设置,或设置为工作区默认值。 - 工作区地理位置(Workspace geo): 控制静态数据的存储位置以及端点处理(例如图像转码和代码执行)的发生位置。在 Claude Console 中按工作区级别进行配置。
注意
Claude Managed Agents 支持在智能体级别进行地理位置固定:在智能体的模型配置上设置
inference_geo,可固定为运行该智能体的会话提供模型请求服务的地理位置,并可在创建会话时进行按会话覆盖。未固定地理位置的智能体在每个请求上遵循工作区的默认推理地理位置。Managed Agents 还遵循在 Console 中配置的工作区地理位置;使用自托管沙箱时,工具执行和沙箱文件系统保留在您控制的基础设施上;所附加的记忆存储的内容仍由 Anthropic 存储,并在会话期间复制到您的沙箱中。
推理地理位置
inference_geo 参数控制特定 API 请求的模型推理运行位置。可将其添加到任何 POST /v1/messages 调用中。
| 值 | 描述 |
|---|---|
"global" |
默认值。推理可能在任何可用的地理位置运行,以获得最佳性能和可用性。 |
"us" |
推理仅在位于美国的基础设施上运行。 |
API 用法
cURL
curl https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 1024,
"inference_geo": "us",
"messages": [{
"role": "user",
"content": "Summarize the key points of this document."
}]
}'
CLI
ant messages create \
--model claude-opus-5-5 \
--max-tokens 1024 \
--inference-geo us \
--message '{role: user, content: "Summarize the key points of this document."}'
Python
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
inference_geo="us",
messages=[
{"role": "user", "content": "Summarize the key points of this document."}
],
)
for block in response.content:
if block.type == "text":
print(block.text)
# 检查推理的实际运行位置
print(f"Inference geo: {response.usage.inference_geo}")
TypeScript
const client = new Anthropic();
const response = await client.messages.create({
model: "claude-opus-5-5",
max_tokens: 1024,
inference_geo: "us",
messages: [
{
role: "user",
content: "Summarize the key points of this document."
}
]
});
const textBlock = response.content.find((block) => block.type === "text");
console.log(textBlock?.text);
// 检查推理实际运行的位置
console.log(`Inference geo: ${response.usage.inference_geo}`);
C#
var client = new AnthropicClient();
var response = await client.Messages.Create(
new MessageCreateParams
{
Model = Model.ClaudeOpus5_5,
MaxTokens = 1024,
InferenceGeo = "us",
Messages =
[
new UserMessageParam { Content = "Summarize the key points of this document." },
],
}
);
foreach (var block in response.Content)
{
if (block.TryPickText(out var textBlock))
{
Console.WriteLine(textBlock.Text);
}
}
// 检查推理实际运行的位置
Console.WriteLine($"Inference geo: {response.Usage.InferenceGeo}");
Go
client := anthropic.NewClient()
message, err := client.Messages.New(context.Background(), anthropic.MessageNewParams{
Model: anthropic.ModelClaudeOpus5_5,
MaxTokens: 1024,
InferenceGeo: anthropic.String("us"),
Messages: []anthropic.MessageParam{
anthropic.NewUserMessage(anthropic.NewTextBlock("Summarize the key points of this document.")),
},
})
if err != nil {
log.Fatal(err)
}
for _, block := range message.Content {
if textBlock, ok := block.AsAny().(anthropic.TextBlock); ok {
fmt.Println(textBlock.Text)
}
}
// 检查推理实际运行的位置
fmt.Printf("Inference geo: %s\n", message.Usage.InferenceGeo)
Java
AnthropicClient client = AnthropicOkHttpClient.fromEnv();
Message response = client.messages().create(
MessageCreateParams.builder()
.model(Model.CLAUDE_OPUS_5_5)
.maxTokens(1024L)
.inferenceGeo("us")
.addUserMessage("Summarize the key points of this document.")
.build());
response.content().stream()
.flatMap(block -> block.text().stream())
.forEach(textBlock -> IO.println(textBlock.text()));
// 检查推理实际运行的位置
IO.println("Inference geo: " + response.usage().inferenceGeo().get());
PHP
$client = new Client();
$response = $client->messages->create(
model: 'claude-opus-5-5',
maxTokens: 1024,
inferenceGeo: 'us',
messages: [
['role' => 'user', 'content' => 'Summarize the key points of this document.'],
],
);
foreach ($response->content as $block) {
if ($block->type === 'text') {
echo $block->text, PHP_EOL;
}
}
// 检查推理实际运行的位置
echo "Inference geo: {$response->usage->inferenceGeo}\n";
Ruby
client = Anthropic::Client.new
response = client.messages.create(
model: Anthropic::Model::CLAUDE_OPUS_5_5,
max_tokens: 1024,
inference_geo: "us",
messages: [
{role: "user", content: "Summarize the key points of this document."}
]
)
response.content.each do |block|
puts block.text if block.type == :text
end
# 检查推理实际运行的位置
puts "Inference geo: #{response.usage.inference_geo}"
响应
响应的 usage 对象包含一个 inference_geo 字段,用于指示推理的运行位置:
Output
{
"usage": {
"input_tokens": 25,
"output_tokens": 150,
"inference_geo": "us"
}
}
模型可用性
inference_geo 参数在 Claude 4.6 及更高版本的模型上受支持。在 Claude Opus 4.5、Claude Sonnet 4.5(已弃用)、Claude Haiku 4.5 或更早的模型上使用 inference_geo 的请求会返回 400 错误。
注意
inference_geo参数可在 Claude API(第一方)、Claude Platform on AWS 和 Claude Models on Google Cloud (Anthropic managed) 上使用。在 Amazon Bedrock 和 Claude Models on Google Cloud (Google managed) 上,推理区域由端点 URL 或推理配置文件决定,因此inference_geo不适用。在 Claude in Microsoft Foundry 上,inference_geo同样不适用:托管在 Azure 上的部署可以改用 US Data Zone Standard 部署类型,该类型将推理保持在美国境内。inference_geo参数也无法通过 OpenAI SDK 兼容性端点使用。
工作区级别限制
工作区设置还支持限制可用的推理地理位置:
allowed_inference_geos: 限制工作区可以使用的地理位置。如果请求指定的inference_geo不在此列表中,API 将返回错误。default_inference_geo: 设置请求中省略inference_geo时的回退地理位置。单个请求可以通过显式设置inference_geo来覆盖此设置。
这些设置可以通过 Console 或 Admin API 在 data_residency 字段下进行配置。
注意
Claude Models on Google Cloud (Anthropic managed): 每个工作区都允许所有推理地理位置,并使用
"global"作为其默认推理地理位置。Claude Console 将这两项设置显示为只读。如需仅在美国进行推理,请在每个请求上设置inference_geo: "us"。
工作区地理位置
工作区地理位置在创建工作区时设置,之后无法更改。目前,"us" 是唯一可用的工作区地理位置。
要设置工作区地理位置,请在 Console 中创建一个新工作区:
- 前往 Claude Console 中的工作区(
platform.claude.com/settings/workspaces)。 - 点击 Create workspace,在 Console 中打开创建工作区页面(
platform.claude.com/settings/workspaces/new)。 - 输入名称,确认 Workspace geo 字段中的值,然后点击 Create workspace。
注意
Claude Platform on AWS: 工作区地理位置不可配置。此平台上的 Claude Managed Agents 会话以
"us"作为实际生效的工作区地理位置运行,这也是目前唯一可用的工作区地理位置。有关该平台特定的数据驻留注意事项,请参阅 Claude Platform on AWS。
注意
Claude Models on Google Cloud (Anthropic managed): 工作区地理位置不可配置。每个工作区都使用
"us"作为其工作区地理位置,并且 Workspace geo 字段不会出现在 Claude Console 中。
定价
数据驻留定价因模型代际而异:
- Claude 4.6 及更高版本的模型: 仅限美国的推理(
inference_geo: "us")在所有令牌定价类别(输入令牌、输出令牌、缓存写入和缓存读取)中按标准费率的 1.1 倍计价。在 Claude Haiku 5.5 上,该倍数也适用于超过 100,000 个令牌的提示所适用的更高价格(请参阅长上下文定价)。 - 全局路由(
inference_geo: "global"): 适用标准定价。 - 较旧的模型: 不支持
inference_geo(请参阅模型可用性)。适用标准定价。包含该参数的请求会返回 400 错误。
此定价适用于 Claude API(第一方)、Claude Platform on AWS 和 Claude Models on Google Cloud (Anthropic managed)。在 Claude in Microsoft Foundry 上,相同的 1.1 倍倍数适用于托管在 Azure 上且使用 US Data Zone Standard 部署类型的部署。由合作伙伴运营的平台,即 Bedrock 和 Claude Models on Google Cloud (Google managed),有其各自的区域定价。有关详细信息,请参阅数据驻留定价。
相同的倍数也适用于 Claude Managed Agents:当智能体的模型配置将 inference_geo 固定为 "us" 时,运行该智能体的会话中的模型请求按标准费率的 1.1 倍计价。
注意
如果您有 Priority Tier 承诺,仅限美国推理的 1.1 倍倍数也会影响令牌在您的 Priority Tier 容量中的计算方式。使用
inference_geo: "us"消耗的每个令牌会从您承诺的 TPM 中扣除 1.1 个令牌,这与其他定价倍数(例如提示缓存)影响消耗速率的方式一致。
Batch API 支持
inference_geo 参数在 Batch API 上受支持。批处理中的每个请求都可以指定自己的 inference_geo 值。
从旧版退出选项迁移
如果您的组织之前选择退出全局路由以将推理保留在美国,您的工作区已自动配置为 allowed_inference_geos: ["us"] 和 default_inference_geo: "us"。无需更改代码。您现有的数据驻留要求将继续通过新的地理位置控制来执行。
发生了哪些变化
旧版退出选项是一项组织级别的设置,它将所有请求限制在位于美国的基础设施上。新的数据驻留控制用两种机制取代了它:
- 按请求控制:
inference_geo参数让您可以在每个 API 调用上指定"us"或"global",为您提供请求级别的灵活性。 - 工作区控制: Console 中的
default_inference_geo和allowed_inference_geos设置让您可以在工作区中的所有密钥上强制执行地理位置策略。
您的工作区发生了什么
您的工作区已自动迁移:
| 旧版设置 | 新的等效设置 |
|---|---|
| 退出全局路由(仅限美国) | allowed_inference_geos: ["us"]、default_inference_geo: "us" |
所有使用您工作区密钥的 API 请求将继续在位于美国的基础设施上运行。无需执行任何操作即可保持您当前的行为。
如果您想使用全局路由
如果您的数据驻留要求已发生变化,并且您希望利用全局路由获得更好的性能和可用性,请更新工作区的推理地理位置设置,在允许的地理位置中包含 "global",并将 default_inference_geo 设置为 "global"。有关详细信息,请参阅工作区级别限制。
定价影响
旧版模型不受此迁移影响。有关较新模型的当前定价,请参阅定价。
当前限制
- 共享速率限制: 速率限制在所有地理位置之间共享。
- 推理地理位置: 仅
"us"和"global"可用。 - 工作区地理位置: 目前仅
"us"可用。工作区地理位置在工作区创建后无法更改。
后续步骤
-
数据驻留定价:查看数据驻留定价详情。
-
工作区:了解工作区配置。
-
用量和成本分析 API:按推理地理位置跟踪用量和成本。
可用性
数据驻留在部分模型上可用,并具备零数据保留和HIPAA 就绪资格。
API 支持
Messages API
- 可用性:可用
- 用法:在每个请求中设置
inference_geo,或为工作区设置默认值。
- 工作区地域不可配置。
Managed Agents
- 可用性:可用
- 用法:在智能体的模型配置中固定
inference_geo,并在创建会话时按会话覆盖它。未固定的智能体遵循工作区默认值。
- 工作区地域不可配置;其中的 Managed Agents 会话以工作区地域 “us” 运行。
数据处理
| 项目 | 零数据保留 | HIPAA |
|---|---|---|
| 状态 | 具备资格(不包括 涵盖的模型) | 具备资格 |
适用的端点:
/v1/messages使用inference_geo