Free Intensive Nov 21–22Free 2-day hands-on Vibecoding Intensive on Nov 21–22 at 16:00 MSK (Sat–Sun) · Live Cohort 3 starts Nov 23Join Free →Cohort 3 (Nov 23)
ReleaseInsight · On RadarAWS Machine Learning Blog→ original

Amazon Bedrock now breaks down Claude Code and Codex costs per employee

When dozens of developers work in Claude Code and Codex, the AI bill arrives as a single line item, and nobody can see who spent what. Amazon Bedrock now records which user made each call in billing, provided that sign-in goes through IAM Identity Center. Team and cost-center tags let you split spending by person and department without changing the tools themselves. That is why you should set up SSO before handing out assistants at scale.

AI-processed from AWS Machine Learning Blog; edited by Hamidun News
Amazon Bedrock now breaks down Claude Code and Codex costs per employee
Source: AWS Machine Learning Blog. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceAWS Machine Learning Blog ↗
Editor-in-Chief
Key metric #1Limits enforced through CloudWatch and Lambda take effect within 1–5 minutes
Key metric #2AWS Budgets updates up to 3 times a day, so an overrun can last a full day
Key metric #3If AWS_BEARER_TOKEN_BEDROCK is set, the spending is charged to the key's owner

While three people use AI assistants, nobody cares about the bill. When Claude Code, Codex, or Claude Desktop is rolled out to hundreds of employees, the CFO opens the billing console and sees one large number. That number doesn't tell you who spends the most, whether that spending pays off, or how much to budget for next year. AWS has published a detailed guide on solving this problem on Amazon Bedrock.

How Bedrock knows who made the request

The idea is simple: Bedrock records which IAM principal made each model call. That record goes into the AWS Cost and Usage Reports (CUR 2.0) in the line_item_iam_principal column. You don't need to change code or the tools' own settings; tracking works at the level of the bedrock-runtime and bedrock-mantle endpoints. Claude Code, Claude Desktop, OpenAI Codex, ChatGPT Work, and OpenCode all go through them.

The key requirement is that every person has their own session. If everyone works under a single shared role with the same session name, or goes through a gateway with its own role, all the spending merges into one "user." That's why AWS recommends connecting a corporate identity provider (Okta, Microsoft Entra ID, or Ping Identity) to IAM Identity Center. The session name then becomes the employee's login. Through SCIM, you can also pull in attributes such as team or cost center. These become tags visible in CUR 2.0 and Cost Explorer.

On a developer's workstation, everything comes down to a single profile in ~/.aws/config and the command aws sso login. The token refreshes automatically until the session ends (8 hours by default). People have no long-lived AWS keys, and CloudTrail records who called what.

What to configure in the tools and in billing

For Claude Desktop, the SSO sign-in parameters are exported to a file for the MDM system. In Claude Code, it's enough to enable CLAUDE_CODE_USE_BEDROCK and specify the profile, and also set awsAuthRefresh for automatic re-login. Codex reads its settings from ~/.codex/config.toml. For both, it's worth pinning model versions before the company-wide rollout so that a new release doesn't change what users are calling.

There's a catch. If the AWS_BEARER_TOKEN_BEDROCK variable is set in the environment, Claude Code and Codex use that key instead of SSO. All spending is then attributed to the key's owner, and per-user tracking disappears. To get per-user attribution, you need to remove it.

In the Billing console, create a CUR 2.0 export in Parquet format with hourly or daily granularity and enable the option that includes data about the calling account. Older exports without this option won't work; you need a new one. The Team and CostCenter tags must be activated manually, and only after users have made at least one call. They appear within 24 hours in CUR and within up to 48 hours in Cost Explorer, and they are not applied retroactively. After that, you can analyze spending with SQL queries in Athena by user or by cost center. For dashboards, Cost Explorer, QuickSight, CUDOS, or Grafana will work.

There's also a limitation: CUR aggregates spending by principal and usage type over the export interval. It doesn't show the cost of an individual request. For breakdowns by prompt, you need model invocation logs or request metadata tags. Input, output, cache read, and cache write tokens are billed separately, so one hour of activity usually produces four rows.

How to limit spending

Seeing the costs isn't enough; you also need to be able to stop them. AWS describes four options, each with its own delay:

  • AWS Budgets with an automatic action, such as denying access, is the simplest. But budgets update up to three times a day, and billing data lags by up to 24 hours. An active user can exceed the limit within a day.
  • CloudWatch and Lambda, using token metrics, react within 1–5 minutes. Per-user breakdowns require separate inference profiles or roles for each user.
  • Quotas in DynamoDB are checked when credentials are issued. Blocking takes effect at the next refresh, not on every call.
  • An LLM gateway blocks every request, but it's the most complex option, and it adds latency.

In practice, these options are combined: CUR for reporting, a gateway or DynamoDB for real-time control, and Budgets as a safety net.

What to do

You can start step by step. Connect the identity provider and grant groups access to Bedrock, and attribution in CloudTrail starts working right away. Then activate the tags and add the Athena queries. Introduce limits only after you can see actual spending by person, not blindly. If some tools go through Claude for Enterprise or Claude Platform on AWS, their usage is tracked in the Anthropic console. Limits there are set by Anthropic itself, and those costs won't break down by user in CUR.

Story

Key Questions Answered

How Bedrock knows who made the request?

The idea is simple: Bedrock records which IAM principal made each model call. That record goes into the AWS Cost and Usage Reports (CUR 2.0) in the line_item_iam_principal column. You don't need to change code or the tools' own settings; tracking works at the level of the bedrock-runtime and bedrock-mantle endpoints. Claude Code, Claude Desktop, OpenAI Codex, ChatGPT Work, and OpenCode all go through them. The key requirement is that every person has their own session.

What to configure in the tools and in billing?

For Claude Desktop, the SSO sign-in parameters are exported to a file for the MDM system. In Claude Code, it's enough to enable CLAUDE_CODE_USE_BEDROCK and specify the profile, and also set awsAuthRefresh for automatic re-login. Codex reads its settings from ~/.codex/config.toml. For both, it's worth pinning model versions before the company-wide rollout so that a new release doesn't change what users are calling. There's a catch.

How to limit spending?

Seeing the costs isn't enough; you also need to be able to stop them. AWS describes four options, each with its own delay: AWS Budgets with an automatic action, such as denying access, is the simplest. But budgets update up to three times a day, and billing data lags by up to 24 hours. An active user can exceed the limit within a day. CloudWatch and Lambda, using token metrics, react within 1–5 minutes. Per-user breakdowns require separate inference profiles or roles for each user.

ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Hands-On AI Engineering · Hamidun Academy

Build & Ship Production AI Agents Without Boilerplate Code

Start your free 72-hour trial at Hamidun Academy (academy.hamidun.com) — interactive lessons on Claude Code & Cursor, live Tech Radar, and production agent templates.

Start 72h Free Trial →Vibe-Coding Intensive
What do you think?
Loading comments…