- Newest
- Most votes
- Most comments
Yes, Amazon Bedrock does support tagging, but there are a few important points to consider regarding your current approach:
-
Tagging in Bedrock is supported, but it's not applied directly in the model invocation call. Instead, you tag the Bedrock resources themselves.
-
The
TagResource
operation is used to add tags to Bedrock resources. This is a separate API call from the model invocation. -
Tags are applied to resources like agents, custom models, knowledge bases, etc., not to individual API calls.
-
For billing purposes, you would typically tag the Bedrock resources when you create or manage them, not during each invocation.
To tag a Bedrock resource using the Node.js SDK, you would use something like this:
import { BedrockClient, TagResourceCommand } from "@aws-sdk/client-bedrock"; const client = new BedrockClient({ region: "YOUR_REGION" }); const params = { resourceArn: "arn:aws:bedrock:REGION:ACCOUNT_ID:RESOURCE_TYPE/RESOURCE_ID", tags: { CustID: "dev010" } }; try { const command = new TagResourceCommand(params); const response = await client.send(command); console.log("Resource tagged successfully"); } catch (error) { console.error("Error tagging resource:", error); }
Replace the resourceArn
with the actual ARN of the Bedrock resource you want to tag.
For your model invocation, you don't need to include the Tags
parameter. Your invokeModel
function should work without the Tags
line, focusing only on the model invocation parameters.
To see the tags applied to your Bedrock resources and verify they're being used for billing, you can use the AWS Cost Explorer or generate a cost allocation report in the AWS Billing Console.
Edit to add:
Specifically for tagging non-agentic invocation of base models, you may want to create and tag an application inference profile. If these tag-based cost allocation capabilities aren't appropriate for your use-case, you could also explore this custom cost tracking solution based on CloudWatch.
Sources
Tagging Amazon Bedrock resources - Amazon Bedrock
TagResource - Amazon Bedrock
Relevant content
- asked 2 years ago
- asked 3 years ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 8 months ago
Thanks we will starting looking at this approach; question where do you locate the ARN for the LLM model we are using?
I have that now via AWS CLi