---
title: 在云平台上使用用户配置文件
url: https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/platforms
description: 在提供 Claude 的各个云平台上，应在何处创建用户配置文件、需要先关联什么，以及如何发送用户配置文件 ID。
---

如果您通过云平台使用 Claude，用户配置文件的设置方式取决于该平台。平台决定了由哪个组织持有您的用户配置文件、您需要先将什么关联到该组织，以及每个请求在何处携带用户配置文件的 ID。要了解用户配置文件的作用以及您是否需要它们，请参阅[用户配置文件的工作原理](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/how-user-profiles-work)。要了解为谁创建用户配置文件以及如何创建用户配置文件，请参阅[创建用户配置文件并归属请求](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/attribute-requests)。

## 哪个组织持有您的用户配置文件

在 Amazon Bedrock、Claude Models on Google Cloud (Google managed) 和 Microsoft Foundry 上，您需要在另一个平台上的 Anthropic 组织中创建用户配置文件。该平台通常是 Claude API。该组织的凭据仅用于管理用户配置文件，您发送给 Claude 的请求仍使用您云平台的凭据。每个平台的章节都会说明哪些组织可用。

在 Claude Models on Google Cloud (Google managed) 和 Amazon Bedrock 上，两种[访问类型](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/attribute-requests#decide-who-gets-a-profile)均可使用。

## 如果您使用 Amazon Bedrock

* **在何处创建用户配置文件：** 在 Claude API 上的组织中。Claude Platform on AWS 上的组织也可以，但其用户配置文件[不会报告限制或封禁](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/platforms#claude-platform-on-aws)。
* **需要先关联什么：** 每个向 Amazon Bedrock 发送携带用户配置文件 ID 的请求的 AWS 账户。请将每个账户关联到您用于创建用户配置文件的组织。有关步骤，请参阅[关联 AWS 账户或 Google Cloud 项目](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles-verification-portal#link-an-aws-account-or-google-cloud-project)。仅用于您自己的使用量的账户无需关联。
* **ID 放在哪里：** 放在请求体顶层的 `user_profile_id` 字段中，而不是 `anthropic-user-profile-id` 标头中。请仅在[可以携带用户配置文件 ID 的请求](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/platforms#amazon-bedrock-models)中发送它。请参阅[各平台如何检查 ID](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/platforms#how-each-platform-checks-the-id)。

### 可以携带用户配置文件 ID 的请求

用户配置文件适用于 [Amazon Bedrock 中的 Claude（`bedrock-mantle`）](https://platform.claude.com/docs/zh-CN/build-with-claude/claude-in-amazon-bedrock)，以及 [Amazon Bedrock 上的 Claude（`bedrock-runtime`）](https://platform.claude.com/docs/zh-CN/build-with-claude/claude-on-amazon-bedrock-legacy)上的 `InvokeModel`，包括使用 `InvokeModelWithResponseStream` 进行的"streaming"（流式传输）。请仅在针对以下模型的请求中发送用户配置文件 ID，但并非每个模型都同时在两个端点上可用：

* Claude 4.7 及更高版本的模型
* Claude Sonnet 4.6
* Claude Haiku 4.5

对于任何其他模型的请求，请不要包含该 ID，因为携带该 ID 的请求可能会以 `400` 失败。Amazon Bedrock 批量推理作业中也请不要包含该 ID。

不带 ID 的请求不会归属到任何终端客户。

用户配置文件不适用于 `Converse` API。请改用 `InvokeModel` 或 `bedrock-mantle` 端点。

### 在请求体中发送 ID

以下展示了 ID 在 `bedrock-mantle` 请求体中的位置。对于 `bedrock-runtime` 请求体，请参阅下方列表中的最后两项。

```json
{
  "model": "anthropic.claude-opus-5-5",
  "max_tokens": 1024,
  "user_profile_id": "uprof_011CZkZCu8hGbp5mYRQgUmz9",
  "messages": [{ "role": "user", "content": "Hello, Claude" }]
}
```

ID 如何进入请求体取决于您调用 Amazon Bedrock 的方式：

* **标准 SDK 客户端：** 请勿通过您用于 Claude API 的客户端向 Amazon Bedrock 发送用户配置文件 ID。无论您为该客户端提供什么基础 URL，它都会将 ID 放在标头中。

* **用于 `bedrock-mantle` 的 SDK 客户端：** 请使用 [`bedrock-mantle` 客户端](https://platform.claude.com/docs/zh-CN/build-with-claude/claude-in-amazon-bedrock#install-an-sdk)的最新版本，您可以通过 `AnthropicBedrockMantle` (csharp: `AnthropicBedrockMantleClient`; go: `bedrock.NewMantleClient()`; java: `BedrockMantleBackend`; php: `MantleClient`; ruby: `Anthropic::BedrockMantleClient`) 创建它。在 SDK 的[用户配置文件参数](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/attribute-requests#attribute-each-request)中传入 ID，客户端会将其放入请求体。

* **用于 `bedrock-runtime` 的 SDK 客户端：** 如果您通过 `AnthropicBedrock` (csharp: `AnthropicBedrockClient`; go: `bedrock.WithLoadDefaultConfig()`; java: `BedrockBackend`; php: `Bedrock\Client`; ruby: `Anthropic::BedrockClient`) 调用 `InvokeModel`，[最新版本的 SDK](https://platform.claude.com/docs/zh-CN/cli-sdks-libraries/overview#latest-versions) 会为您将[用户配置文件参数](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/attribute-requests#attribute-each-request)放入请求体中。较早的版本不会这样做，因此除非您自行添加 ID，否则请求不会被归属。在 TypeScript 和 C# 中，起决定作用的是 Bedrock 包的版本，即 `@anthropic-ai/bedrock-sdk` 或 `Anthropic.Bedrock`。

  在最新 SDK 所发送的 API 版本上，针对某些模型的 `InvokeModel` 请求可能会以 `400` 失败。这些模型是 [Amazon Bedrock 上的 Claude（`bedrock-runtime`）](https://platform.claude.com/docs/zh-CN/build-with-claude/claude-on-amazon-bedrock-legacy)模型表中编号为 4.6 或更低的模型。对于这些模型，请继续使用 SDK 的上一个主要版本。要安装该版本，请使用[安装用于访问 Bedrock 的 SDK](https://platform.claude.com/docs/zh-CN/build-with-claude/claude-on-amazon-bedrock-legacy#install-an-sdk-for-accessing-bedrock) 中的命令。

  使用较早版本时，请通过 `extra_body` (ruby: `request_options: {extra_body: {...}}`; typescript: `body`; php: `extraBodyParams`; java: `.putAdditionalBodyProperty()`; go: `option.WithJSONSet()`; csharp: `MessageCreateParams.FromRawUnchecked()`) 将 `user_profile_id` 添加到[接受该 ID 的模型](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/platforms#amazon-bedrock-models)的请求体中。请保持请求体的其余部分不变，因为 SDK 会根据请求体中的 `model` 以及（如果您使用流式传输）`stream: true` 构建 URL。在 TypeScript 和 C# SDK 中，该选项会替换整个请求体，因此请将请求的每个字段连同 `user_profile_id` 一起包含在内。

* **直接调用 `InvokeModel`：** 请将模型 ID 放在请求的 URL 中（在 AWS SDK 中为 `modelId`），而不是请求体中。请求体还需要包含 `anthropic_version` 字段，例如 `"anthropic_version": "bedrock-2023-05-31"`。

如果您从[发送请求](https://platform.claude.com/docs/zh-CN/build-with-claude/claude-on-amazon-bedrock-legacy#making-requests)中的示例开始，请将其模型更改为[接受用户配置文件 ID](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/platforms#amazon-bedrock-models) 的模型。

## 如果您使用 Claude Platform on AWS

* **在何处创建用户配置文件：** 在您于 [Claude Platform on AWS](https://platform.claude.com/docs/zh-CN/build-with-claude/claude-platform-on-aws) 上的组织中，使用该平台的基础 URL 和身份验证方式。调用主体需要具有[用户配置文件 IAM 操作](https://platform.claude.com/docs/zh-CN/api/claude-platform-on-aws-iam-actions#user-profiles)权限。
* **需要先关联什么：** 如果您在此组织中创建用户配置文件，则无需关联任何内容。如果用户配置文件由其他组织创建，请参阅[如果请求返回 `400`](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/attribute-requests#if-a-request-returns-a-400)。
* **ID 放在哪里：** 放在 `anthropic-user-profile-id` 标头中，该标头由 SDK 的[用户配置文件参数](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/attribute-requests#attribute-each-request)设置。
* **限制和封禁：** 不会报告。有关执行措施字段改为显示什么内容，请参阅[在 Claude Platform on AWS 上管理用户配置文件](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/manage-profiles#if-you-use-claude-platform-on-aws)。

## 如果您使用 Claude Models on Google Cloud (Anthropic managed)

* **在何处创建用户配置文件：** 在您于 [Claude Models on Google Cloud (Anthropic managed)](https://platform.claude.com/docs/zh-CN/build-with-claude/claude-models-on-google-cloud/anthropic-managed) 上的组织中，您可以在其中创建、检索、列出和更新用户配置文件。请使用 Google Cloud 凭据而不是 API 密钥进行身份验证，并使用[适用于 Claude Models on Google Cloud (Anthropic managed) 的 SDK 客户端](https://platform.claude.com/docs/zh-CN/build-with-claude/claude-models-on-google-cloud/anthropic-managed#install-an-sdk)的最新版本或[组织级基础 URL](https://platform.claude.com/docs/zh-CN/build-with-claude/claude-models-on-google-cloud/anthropic-managed#making-requests)。
* **需要先关联什么：** 如果您在此组织中创建用户配置文件，则无需关联任何内容。如果用户配置文件由其他组织创建，请参阅[如果请求返回 `400`](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/attribute-requests#if-a-request-returns-a-400)。
* **ID 放在哪里：** 放在 `anthropic-user-profile-id` 标头中，该标头由 SDK 的[用户配置文件参数](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/attribute-requests#attribute-each-request)设置。

## 如果您使用 Claude Models on Google Cloud (Google managed)

* **在何处创建用户配置文件：** 在 Claude API 上的组织中。Claude Platform on AWS 上的组织也可以，但其用户配置文件[不会报告限制或封禁](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/platforms#claude-platform-on-aws)。
* **需要先关联什么：** 每个向 [Claude Models on Google Cloud (Google managed)](https://platform.claude.com/docs/zh-CN/build-with-claude/claude-models-on-google-cloud/google-managed) 发送携带用户配置文件 ID 的请求的 Google Cloud 项目。请将每个项目关联到您用于创建用户配置文件的组织。有关步骤，请参阅[关联 AWS 账户或 Google Cloud 项目](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles-verification-portal#link-an-aws-account-or-google-cloud-project)。仅用于您自己的使用量的项目无需关联。
* **ID 放在哪里：** 放在 `anthropic-user-profile-id` 标头中，而不是请求体中。请参阅[各平台如何检查 ID](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/platforms#how-each-platform-checks-the-id)。

使用 SDK 时，请使用[适用于 Claude Models on Google Cloud (Google managed) 的 SDK 客户端](https://platform.claude.com/docs/zh-CN/build-with-claude/claude-models-on-google-cloud/google-managed#install-an-sdk-for-accessing-vertex-ai)的最新版本，您可以通过 `AnthropicVertex` (csharp: `AnthropicVertexClient`; go: `vertex.WithGoogleAuth()`; java: `VertexBackend`; php: `Anthropic\Vertex\Client`; ruby: `Anthropic::VertexClient`) 创建它。在其[用户配置文件参数](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/attribute-requests#attribute-each-request)中传入 ID，客户端会发送该标头。

## 如果您使用 Microsoft Foundry

以下详细信息适用于[托管在 Anthropic 上](https://platform.claude.com/docs/zh-CN/build-with-claude/claude-in-microsoft-foundry#hosting-options)的 [Microsoft Foundry 中的 Claude](https://platform.claude.com/docs/zh-CN/build-with-claude/claude-in-microsoft-foundry) 部署。

* **在何处创建用户配置文件：** 在 Claude API 上的组织中。`/v1/user_profiles` 端点在 Microsoft Foundry 上不可用。
* **需要先关联什么：** 持有您 Foundry 资源的组织。Anthropic 会将其关联到您用于创建用户配置文件的组织。如需申请关联，请联系您的客户团队。
* **ID 放在哪里：** 关联建立后，放在 `anthropic-user-profile-id` 标头中。在此之前，每个携带用户配置文件 ID 的请求都会返回 `400`。

## 规则和特殊情况

### 各平台如何检查 ID

某些平台会对每个请求检查该 ID。有关是哪些平台以及它们返回什么，请参阅[如果请求返回 `400`](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/attribute-requests#if-a-request-returns-a-400)。

Claude Models on Google Cloud (Google managed) 会以 `400` 拒绝格式错误的 ID。Amazon Bedrock 在[可以携带用户配置文件 ID 的请求](https://platform.claude.com/docs/zh-CN/manage-claude/user-profiles/platforms#amazon-bedrock-models)上也是如此。两者都会接受任何格式正确的 ID。在这两个平台上，成功的响应并不能确认该 ID 与您的某个用户配置文件匹配。
