Ich möchte Tags für die Kostenzuweisung hinzufügen, wenn ich On-Demand-Modelle von Amazon Bedrock aufrufe.
Lösung
Weise einem Anwendungsinferenzprofil Tags zu und verknüpfe das Profil dann mit dem On-Demand-Modell.
Hinweis: Du kannst On-Demand-Modellen keine Tags zuweisen.
Ein Anwendungsinferenzprofil erstellen
Verwende das CreateInferenceProfile. Das folgende Beispiel erstellt ein Anwendungsinferenzprofil, das mit amazon.nova-pro-v1:0 mithilfe des Tags "key": "CostAllocateTag","value": "project123" verknüpft wird.
Beispiel:
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"}]'
Beispielausgabe:
{
"inferenceProfileArn": "arn:aws:bedrock:us-east-1:AccountId:application-inference-profile/y1pcpudi2mb7",
"status": "ACTIVE"
}
Ein Kostenzuweisungs-Tag aktivieren
Verwende die AWS-Fakturierung und -Kostenmanagement-Konsole, um ein Kostenzuweisungs-Tag zu aktivieren.
Hinweis: Die Tags werden innerhalb von 24 Stunden auf der Seite mit den Kostenzuweisungs-Tags angezeigt.
Das Modell aufrufen
Verwende das Anwendungsinferenzprofil, um das Modell aufzurufen. Gib für die Modell-ID den ARN des Anwendungsinferenzprofils anstelle der On-Demand-Modell-ID an.
Beispiel:
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"}]}]'
Beispielausgabe:
{
"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
}
}