Amazon Bedrock オンデマンドモデルを呼び出すときに、コスト配分タグを追加したいです。
解決策
アプリケーション推論プロファイルにタグを割り当て、そのプロファイルをオンデマンドモデルにリンクします。
注: オンデマンドモデルにはタグを割り当てることができません。
アプリケーション推論プロファイルを作成します。
CreateInferenceProfile を使用します。次の例では、amazon.nova-pro-v1:0 にリンクされたアプリケーション推論プロファイルを作成します。タグは "key": "CostAllocateTag","value": "project123" です。
例
aws bedrock create-inference-profile --region 'us-east-1' \
--inference-profile-name 'profile-project123' \
--description 'profile-project123' \
--model-source '{"copyFrom": "arn:aws:bedrock:us-east-1::foundation-model/amazon.nova-pro-v1:0"}' \
--tags '[{"key": "CostAllocateTag","value": "project123"}]'
出力例
{
"inferenceProfileArn": "arn:aws:bedrock:us-east-1:AccountId:application-inference-profile/y1pcpudi2mb7",
"status": "ACTIVE"
}
コスト配分タグを有効にする
コスト配分タグを有効にするには、AWS Billing and Cost Management コンソールを使用します。
注: タグは、24 時間以内にコスト配分タグページに表示されます。
モデルを呼び出す
モデルを呼び出すには、アプリケーション推論プロファイルを使用します。モデル ID には、オンデマンドモデル ID ではなく、アプリケーション推論プロファイルの ARN を指定します。
例
aws bedrock-runtime converse --region 'us-east-1' \
--model-id 'arn:aws:bedrock:us-east-1:AccountId:application-inference-profile/y1pcpudi2mb7' \
--messages '[{"role": "user", "content": [{"text": "Hello"}]}]'
出力例
{
"output": {
"message": {
"role": "assistant",
"content": [
{
"text": "Hello! It's nice to have you here. I'm here to help with whatever you might need. Whether you have a question, need assistance with a topic, or just want to chat, feel free to ask. What can I assist you with today?"
}
]
}
},
"stopReason": "end_turn",
"usage": {
"inputTokens": 1,
"outputTokens": 54,
"totalTokens": 55
},
"metrics": {
"latencyMs": 889
}
}