

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 为代理创建别名
<a name="deploy-agent-proc"></a>

以下过程说明了如何为代理创建别名和版本。创建别名后，您可以使用 [Amazon Bedrock 代理运行时端点](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#bra-rt)发出 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html) 请求，以在应用程序中使用代理。

**创建别名**
+ 为代理创建别名和版本。选择与您的首选方法对应的选项卡，然后按照以下步骤操作：

------
#### [ Console ]

**创建别名（也可以创建新版本）**

  1. 采用有权使用 Amazon Bedrock 控制台的 IAM 身份登录 AWS 管理控制台。然后，通过以下网址打开 Amazon Bedrock 控制台：[https://console.aws.amazon.com/bedrock](https://console.aws.amazon.com/bedrock)。

  1. 从左侧导航窗格中选择**代理**。然后，在**代理**部分选择一个代理。

  1. 在**别名**部分，选择**创建**。

  1. 输入唯一的**别名名称**，（可选）并提供**描述**。

  1. 在**关联版本**下，选择以下选项之一：
     + 要创建新版本，请选择**创建新版本并将其关联到此别名**。
     + 要使用现有版本，请选择**使用现有版本关联此别名**。从下拉菜单中，选择要关联别名的版本。

  1. 在**选择吞吐量**下，选择以下选项之一：
     + 要让代理按照您为账户设置的费率运行模型推理，请选择**按需（ODT）**。有关更多信息，请参阅[Amazon Bedrock 的配额](quotas.md)。
     + 要让您的代理使用您之前为模型购买的预置吞吐量以更高的速率运行模型推理，请选择**预置吞吐量（PT）**，然后选择一个预置模型。有关更多信息，请参阅[利用 Amazon Bedrock 中的预调配吞吐量增加模型调用容量](prov-throughput.md)。

  1. 选择**创建别名**。

------
#### [ API ]

  要为代理创建别名，请使用 [Amazon Bedrock 代理构建时端点](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#bra-bt)发送 [CreateAgentAlias](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent_CreateAgentAlias.html) 请求。

  以下字段是必填字段：  
****    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/deploy-agent-proc.html)

  以下字段是可选字段：  
****    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/bedrock/latest/userguide/deploy-agent-proc.html)

  ```
      def create_agent_alias(self, name, agent_id):
          """
          Creates an alias of an agent that can be used to deploy the agent.
  
          :param name: The name of the alias.
          :param agent_id: The unique identifier of the agent.
          :return: Details about the alias that was created.
          """
          try:
              response = self.client.create_agent_alias(
                  agentAliasName=name, agentId=agent_id
              )
              agent_alias = response["agentAlias"]
          except ClientError as e:
              logger.error(f"Couldn't create agent alias. {e}")
              raise
          else:
              return agent_alias
  ```

  有关更多信息，请参阅[开始使用 Amazon Bedrock 代理](bedrock-agent_example_bedrock-agent_Hello_section.md)。

------