View a markdown version of this page

Agent cost - Amazon CloudWatch

Agent cost

Agent cost shows the estimated cost of your agents in the Omni web UI: what their model calls, their evaluations, and their Amazon Bedrock AgentCore resources cost over a time range, split by agent, model, session, or any attribute that their model-call spans carry. Every figure is an estimate at list price, not your AWS bill. For the trace, span, and session vocabulary, see Monitor AI agents.

Prerequisites

Agent cost works for any agent whose spans reach CloudWatch, wherever it runs: on Amazon EKS, Amazon ECS, Amazon EC2, AWS Lambda, Amazon Bedrock AgentCore Runtime, or another cloud. For cost to appear, your agent needs the following.

Traces that reach CloudWatch. The Agent cost page reads the same spans as the Agent traces page, so the telemetry setup in Send AI agent telemetry is the setup for cost. Cost is summed from the spans that reach CloudWatch, so a model call whose span is dropped before it is exported, for example by sampling, adds no cost.

A CLIENT span for each model call. A model call gets a cost when its span carries all of the following:

Field Required value
Span kind CLIENT
gen_ai.operation.name chat, text_completion, generate_content, or embeddings
gen_ai.request.model or gen_ai.response.model The model ID of a model hosted on Amazon Bedrock
gen_ai.usage.input_tokens or gen_ai.usage.output_tokens The token counts of the call

Your instrumentation decides which calls carry a cost and how often each one is counted:

  • Instrumentation. For each Amazon Bedrock call, the AWS Distro for OpenTelemetry (ADOT) records a model-call span with the fields in the preceding table. Spans from other OpenTelemetry instrumentation are priced the same way if they have the same fields and the span kind CLIENT.

  • Counting. A framework span that records the same call as an INTERNAL span is not priced, so a call that ADOT records is counted once. Each CLIENT span that meets the requirements in the preceding table is priced on its own, so when two instrumentation libraries each record the same call as such a span, the call is counted twice.

  • Avoid a double count. If you pair ADOT with a second library that also records your Amazon Bedrock calls, disable ADOT's Bedrock instrumentation so that one library records each call: for Python, set OTEL_PYTHON_DISABLED_INSTRUMENTATIONS as described in Send AI agent telemetry.

  • Model recognition. The model is recognized from its model ID, not from gen_ai.system or gen_ai.provider.name.

  • AgentCore resources. The AgentCore resources listed in How the estimate is made record their own cost on the spans they emit, so they need no instrumentation from you.

How the estimate is made

Each model call records its own estimated cost on its span: the call's input tokens, output tokens, cache reads, and cache writes, priced at the model's list price. The cost is written on the span when the span arrives in CloudWatch, before the Omni web UI reads it. Cost is not added to a span after it is stored, so usage from before cost recording began for your account and AWS Region has no cost estimate and adds nothing to any total. The inference cost for a time range adds the recorded amounts of every model call in it.

Because the estimate is read from spans, it is only as complete as the spans your agents send:

  • A call whose span does not meet the requirements in Prerequisites carries no recorded cost and adds nothing to any total. If a model is listed as having no cost estimate, or a trace shows — and No estimate, check that the call is recorded as a CLIENT span with those attributes and that the model ID is the one Amazon Bedrock uses. The cost breakdown of such a model shows its token counts.

  • A model with no list price has no estimate, whatever its span carries. Where a figure would appear, the page shows — and No estimate, never $0.

Evaluations are priced the same way. Each evaluation records its own estimated cost for scoring a trace or a session, and the page shows that cost separately from inference. To change how much traffic your online evaluations score, see Online evaluations. On-demand evaluations have no cost estimate and are not included.

When AgentCore records a cost on the spans of the resources your agents use, the page adds that cost as a third source, AgentCore resources, and includes it in the total. The resources that record a cost are Gateway, Memory, Browser, Code Interpreter, and Runtime. A span that names a model is priced as a model call, even when AgentCore Runtime hosts it, so no span is priced twice. For how AgentCore prices its resources, see AgentCore agent cost in the Amazon Bedrock AgentCore Developer Guide.

When to use it

Use Agent cost to see where your agents' cost goes and how it is changing: which agents, models, or sessions cost the most in a time range, how the cost compares with the previous window of the same length, and what share of the total each one takes. Group by an attribute that your model-call spans carry, such as a release version, to compare the cost of two versions. Create an alert from the page to be notified when the estimated cost of an agent reaches a threshold. For the cost of each run while you test a change before release, see Experiments.

Open Agent cost

In the launcher, under Agent observability, choose Agent cost, then select the time range. The page has five panels that share the time range and any filter you set:

Cost breakdown dashboard showing estimated total of $11.23. Sankey diagram displays flow from three cost types Inference $2.11, Evaluations $8.08, AgentCore $1.05 to various Waggle agents. Tables below show top models, sessions, and systems by cost
  • Estimated cost — cards for Total, Inference (your agents' model calls), Evaluations (the evaluations that scored your agents' traces and sessions), AgentCore resources (when the time range has priced AgentCore resources), and Per session, the average estimated cost of a session in the range. Each card shows its change against the previous window of the same length, and reads New when the previous window cost nothing. Choose a card to show only that cost type on the page. The Per session card does not select a cost type.

  • Cost breakdown — a chart with a Cost type control (All, Inference, Evaluations, and AgentCore resources when the time range has priced AgentCore resources), a Group by control, a Flow or Line view, and Create alert.

  • Top 10 models by cost, Top 10 sessions by cost, and Top 10 by an attribute of your choice (System by default) — tables that rank by estimated cost.

Group the cost

Group by on the Cost breakdown chart splits the cost one of these ways:

  • Agent — the agent that made the calls.

  • Model — the model that was called. An evaluation that names its judge model adds to that model's group. One that names none appears in a single Evaluations group.

  • Session — the session the calls belong to. In place of the Flow and Line views, the chart draws one point per session that has a cost estimate, at the time of its last span, with the average cost per session as a dashed line. Cost belongs to a session when its spans record a session ID. For how to set it, see Agent sessions.

  • Attribute — a span attribute. The list offers Operation (gen_ai.operation.name) and System (gen_ai.system) first, then every span and resource attribute key that your traces carry, shown as its path, such as attributes.release.version.

  • AgentCore resource — the type of AgentCore resource, when the time range has priced AgentCore resources.

An Attribute grouping reads the attribute on the model-call span. If your agent writes an attribute only on its root span or on a tool span, the page groups every call under No value and says so. To group cost by an attribute, write it on each model call.

To narrow every panel to one agent, model, session, attribute value, or AgentCore resource type, choose a group in the Cost breakdown chart: a band or node in the Flow view, or a point in the Line view. Then choose Filter to that item. The filter appears in the page header, where you can remove it. One filter applies at a time.

Read the result

  • Flow view shows the cost sources on the left and the groups on the right. Each group is labeled with its amount and its share of the total. With Cost type set to Inference or Evaluations, the flow runs through the token types instead: input tokens, output tokens, cache reads, cache writes, and other charges.

  • Line view plots each of the most expensive groups as a rate over time, such as cost per hour, with the rest combined as Other.

  • Top 10 tables rank by estimated cost. Choose a row's cost to open its cost breakdown. In the sessions table, choose a session ID to open the session.

  • Small and missing amounts. An amount below one cent shows as <$0.01. An item with no estimate shows — and No estimate.

  • Incomplete results. A panel whose query might have missed some cost shows a warning icon with the reason. If a query reaches its row limit, the panel says so. Choose a shorter time range or one agent.

Create a cost alert

Choose Create alert in the Cost breakdown title bar. The alert configuration form opens with a rule prepared from the chart:

  • The rule adds up the cost sources the chart currently shows and evaluates them per agent, with the threshold in US dollars. The alert fires when an agent's estimated cost in one evaluation interval reaches the threshold.

  • A grouping by model, session, attribute, or AgentCore resource narrows the chart, not the rule.

  • A filter to one agent scopes the rule to that agent. While the page is filtered to a model, a session, an attribute value, or one AgentCore resource type, Create alert is unavailable and shows the reason. Clear that filter to create the alert.

Adjust the rule before you save it. For thresholds, evaluation timing, alert states, and notifications, see Alerts.

Where else cost appears

The same estimate appears beside token usage elsewhere in the web UI. The aggregate views show it as an Estimated cost card and as an Estimated cost tab of the Agent metrics over time chart (see Monitor agents in the web UI). Agent traces and Agent sessions show it as an Estimated cost column, and Experiments shows it for each run. A trace's cost covers its model calls and the AgentCore resource spans it contains. A session's cost adds the evaluations that scored the session and the AgentCore resources that served it, so a session can cost more than the sum of its traces.

You can also ask Omni in the Omni web UI chat what your agents' model calls cost (see Ask the Omni agent). For example:

  • "What does one session of support-agent cost on average, and which session cost the most?"

  • "Which model calls cost the most for support-agent this week?"

  • "How is support-agent's cost split across input, output, and cached tokens?"