8
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Amazon Bedrockのコストをユーザー別管理するためにApplication Inference Profilesを試した

Last updated at Posted at 2025-09-18

同じAWSアカウント内で、複数のユーザーが同一のモデルを使う場合、Bedrockの推論コストをユーザー別に分けて管理したいことがあります。複数のユーザーでなくても用途別などでコストを別々に管理したいことがあります。

しかし標準設定では全てのBedrockコストが一括りになってしまい、用途別のコスト管理が困難という問題があります。

そこで今回は、Amazon BedrockのApplication inference profilesを使って、ユーザーやプロジェクト、用途別にBedrockの推論コストを把握する方法を試してみました。

Application inference profilesとは何か

Application inference profilesは、Bedrockのモデル呼び出しにコストタグを付けるための仕組みです。

通常は apac.anthropic.claude-sonnet-4-20250514-v1:0 のようなモデル名でAPIを呼び出しますが、Application inference profilesでは代わりに arn:aws:bedrock:ap-northeast-1:123456789012:application-inference-profile/xxxxxxxxxxxx のようなARNを使って呼び出します。

Application inference profilesを作る際には、元となるモデルを指定します。 apac.anthropic.claude-sonnet-4-20250514-v1:0 を指定してprofileを作った場合、そのprofileのARNで呼び出してもモデル自体は同じ apac.anthropic.claude-sonnet-4-20250514-v1:0 になります。つまり利用する側からすれば呼び出し先を変えるだけです。

このApplication inference profilesにコストタグを設定しておくと、Cost Explorerでタグ別のコスト分析ができるようになります。

複数のApplication inference profilesを作成して、それぞれに異なるコストタグを付けておけば、ユーザー別・プロジェクト別にBedrockのコストを把握できます。

Application inference profilesの作成方法

現状、マネジメントコンソールからは作成できません。AWS CLIを使います。

aws bedrock create-inference-profile --inference-profile-name "AIP-Alice" --model-source copyFrom="arn:aws:bedrock:ap-northeast-1::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0"

inference-profile-nameは適当な名前を付けます。create-inference-profileを実行すると、以下のようなJSONが返ってきます。この中にARNが含まれています。 xxxxxxxxxxxx の部分がinference profile identifierです。

{
    "inferenceProfileArn": "arn:aws:bedrock:ap-northeast-1:123456789012:application-inference-profile/xxxxxxxxxxxx",
    "status": "ACTIVE"
}

これにタグを付与します。keyにはコストタグで利用できるタグを指定します。

aws bedrock tag-resource --resource-arn arn:aws:bedrock:ap-northeast-1:123456789012:application-inference-profile/xxxxxxxxxxxx --tags key=BedrockUser,value=alice2

作成したApplication inference profilesの確認方法

作成したApplication inference profilesは、マネジメントコンソールから確認できません。

You can't view application inference profiles in the Amazon Bedrock console.

AWS CLIで確認します。

list-inference-profilesコマンド

aws bedrock list-inference-profiles --type-equals APPLICATION
{
    "inferenceProfileSummaries": [
        {
            "inferenceProfileName": "AIP-Alice",
            "createdAt": "2025-09-10T10:17:39.852317+00:00",
            "updatedAt": "2025-09-10T10:17:39.852317+00:00",
            "inferenceProfileArn": "arn:aws:bedrock:ap-northeast-1:123456789012:application-inference-profile/xxxxxxxxxxxx",
            "models": [
                {
                    "modelArn": "arn:aws:bedrock:ap-northeast-1::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0"
                }
            ],
            "inferenceProfileId": "xxxxxxxxxxxx",
            "status": "ACTIVE",
            "type": "APPLICATION"
        }
    ]
}

get-inference-profileコマンド

aws bedrock get-inference-profile --inference-profile-identifier xxxxxxxxxxxx
{
    "inferenceProfileName": "AIP-Alice",
    "createdAt": "2025-09-10T10:17:39.852317+00:00",
    "updatedAt": "2025-09-10T10:17:39.852317+00:00",
    "inferenceProfileArn": "arn:aws:bedrock:ap-northeast-1:123456789012:application-inference-profile/xxxxxxxxxxxx",
    "models": [
        {
            "modelArn": "arn:aws:bedrock:ap-northeast-1::foundation-model/anthropic.claude-sonnet-4-20250514-v1:0"
        }
    ],
    "inferenceProfileId": "xxxxxxxxxxxx",
    "status": "ACTIVE",
    "type": "APPLICATION"
}

上記コマンドでは付与したタグが出てきません。タグを確認するには以下のコマンドを実行します。

aws bedrock list-tags-for-resource --resource-arn arn:aws:bedrock:ap-northeast-1:123456789012:application-inference-profile/xxxxxxxxxxxx
{
    "tags": [
        {
            "key": "BedrockUser",
            "value": "alice2"
        }
    ]
}

Claude CodeでのApplication inference profilesの利用例

Claude CodeをAmazon Bedrockで使う場合、以下のような環境変数を設定していると思います。

export AWS_ACCESS_KEY_ID=AKXXXXXXXXXXXXXXXXXX
export AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
or
export AWS_BEARER_TOKEN_BEDROCK=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

export AWS_REGION=ap-northeast-1
export ANTHROPIC_MODEL=apac.anthropic.claude-sonnet-4-20250514-v1:0
export CLAUDE_CODE_USE_BEDROCK=1

このうち ANTHROPIC_MODEL にApplication inference profilesのARNを指定します。

ANTHROPIC_MODEL=arn:aws:bedrock:ap-northeast-1:123456789012:application-inference-profile/xxxxxxxxxxxx

Cost Explorerでの確認

AWSのマネジメントコンソールのCost Explorerで、コストタグ別のコストを確認できます。

右のメニューでタグ別の表示を設定すればグラフ化されます。

以下のスクショは、コストタグ別のClaude Sonnet 4の費用をグラフで見たものです。

img

※コストタグの名前がこの記事のサンプルコードと異なってしまっているため、このスクショでは塗りつぶしてあります。

※Application inference profilesにアクセスしてコストが発生してからCost Explorerに反映されるまでには時間がかかります。翌日ぐらいに確認したほうがいいかもしれません。

この仕組みを使う際の注意点

複数のユーザーでBedrockを利用する場合、ユーザーごとに特定のApplication inference profilesのみにアクセスできるようにIAMを設定する必要があります。ユーザーが勝手に別のApplication inference profilesを使ってしまうと、コスト管理ができなくなってしまいます。

まとめ

Application inference profilesを使えば、Bedrockのコストをユーザーやプロジェクト、用途単位で分けて把握できます。

8
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?