Foundry prompt agent: Traces token totals don't match billing. Is an agent run billed as a single request?

caoimhin 0 Reputation points
2026-11-25T16:31:19.3366667+00:00

Hi all,

I'm doing some research comparing agent platforms, and I'd appreciate help understanding token figures for a Foundry prompt agent. Model is gpt-4o deployed in Azure, the agent uses MCP tools.

For a single run:

  • The playground, Azure Monitor and the AzureOpenAIRequestUsage log all show 6,576 tokens (5,169 in / 1,407 out), as one request.
  • Foundry Traces shows 19,876 tokens (19,377 in / 499 out).

Is the playground/billing figure the right one to use for cost, and is the Traces figure expected to differ like this for agent runs?

Screenshot attached. Thanks for any guidance!
picture

Foundry Agent Service
Foundry Agent Service

A fully managed platform in Microsoft Foundry for hosting, scaling, and securing AI agents built with any supported framework or model

0 comments No comments

2 answers

Sort by: Most helpful
  1. AI answer

    2026-11-25T16:34:50.4433333+00:00

    Use the 6,576 deployment tokens—5,169 input and 1,407 output—to estimate this run’s GPT-4o inference charge, while using Azure Cost Management meter records as the final billing authority; the 19,876 trace total is observability data and should not be treated as an additional GPT-4o charge.

    An agent run is not inherently billed as one request. It is a unit of work that can contain multiple model turns and tool operations, each billed through the applicable meter. Tool calls can cause additional model turns, while MCP servers and dependent resources can generate separate charges through their own resources.^1^

    What your figures indicate

    Figure Interpretation
    Playground: 5,169 in / 1,407 out Usage returned for the model response
    AzureOpenAIRequestUsage: 5,169 / 1,407 Recorded deployment usage for that model request
    Deployment metric: approximately 6.58K Consistent with 5,169 + 1,407 = 6,576
    Trace: 19,377 in / 499 out Trace-level observability figure requiring span-level inspection
    Trace estimated cost An estimate, not the final billed amount

    The agreement between the Playground, deployment metric, and one AzureOpenAIRequestUsage record strongly indicates one recorded GPT-4o deployment call in that interval. It proves a one-call run only if the trace’s model span and deployment log also share the corresponding request/response ID—not merely a similar timestamp.

    Azure OpenAI exposes processed prompt and generated-completion metrics for model usage.^2^ For billing reconciliation, Microsoft specifically directs customers to the meter data in Azure Cost Management and states that invoice and meter records are the source of truth.^1^

    Why the trace can differ

    A Foundry trace represents the full execution journey. It can contain nested spans for the agent invocation, planning, model calls, MCP/tool execution, retries, and other operations.^3^

    Token usage is attached to model-related spans through OpenTelemetry attributes such as gen_ai.usage.input_tokens and gen_ai.usage.output_tokens. Tool and agent spans are separate operations.^4^ These attribute names document the OpenTelemetry trace structure; the managed prompt-agent UI can present them differently.

    The documentation does not define the aggregation algorithm for the specific token columns shown in your trace-list screenshot. Therefore, do not assume that 19,876 is either:

    • an extra billable request, or
    • definitely the sum of unique model tokens.

    It could reflect aggregation across nested spans, retries, or another instrumentation difference, but that must be verified from the trace tree rather than inferred from the summary.

    Reconcile the run

    1. In the Foundry project, open Agents → Traces, select the trace, and expand its complete waterfall. In the fleet experience, use Manage → Fleet → Agents → select the agent → Traces.^5^
    2. Count only model-inference spans such as chat or text_completion; do not count invoke_agent or execute_tool as separate GPT-4o requests.
    3. For every model span, record:
      • input and output tokens;
      • model and deployment;
      • request or response ID;
      • retry status and timestamp.
    4. Correlate those IDs with AzureOpenAIRequestUsage. If there is one matching model span and one matching deployment record, use 5,169 input + 1,407 output for that model call.
    5. In Azure Cost Management → Cost Analysis, select the relevant scope and time range, then group first by Meter and then by Operation name. Check both the GPT-4o deployment meters and any MCP/tool or dependent-resource meters. Billing data can arrive later and might not isolate one run exactly.

    If the trace still cannot be reconciled

    If the detailed trace contains only one model span but its summary still reports 19,876 tokens, open an Azure technical support request for Microsoft Foundry/Azure OpenAI tracing. Include:

    • subscription and resource IDs;
    • region, deployment name, model name, and model version;
    • trace ID and request/response ID;
    • exact UTC timestamp;
    • screenshots of the trace detail and deployment metrics;
    • the corresponding AzureOpenAIRequestUsage records.

    That condition requires service-side inspection of the trace aggregation.

    If the invoice or Cost Management meters charge more model tokens than the deployment records support, open an Azure Cost Management + Billing support request instead and attach the meter-level cost/usage export. Keep MCP and other resource charges separate: an agent run can incur those even when GPT-4o itself made only one recorded request.^1^


    References

    1. Billing concepts for Microsoft Foundry - Microsoft Foundry | Microsoft Learn
    2. Azure OpenAI monitoring data reference
    3. Agent tracing overview - Microsoft Foundry | Microsoft Learn
    4. Trace LangChain and LangGraph apps with Microsoft Foundry and Azure Monitor
    5. Manage agents at scale in Microsoft Foundry Control Plane
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

    1 person found this answer helpful.
  2. Morteza Azizi 0 Reputation points
    2026-11-26T12:47:29.1333333+00:00

    The question is which token figure to use for the cost of this run, and whether an agent run is billed as one request.

    Use the 6,576 tokens as the confirmed usage for this model request: 5,169 input and 1,407 output. The Playground, Azure Monitor, and the AzureOpenAIRequestUsage log all show that figure for one request. The Billing concepts for Microsoft Foundry article says model calls are billed based on the tokens processed by the deployment.

    An agent run is not billed as one request in general. You pay for the model calls it makes and for the tools and resources it uses. A tool call can add another model turn and more tokens. During public preview, the agent cost shown in the Foundry portal covers model calls only. Other costs appear in Azure Cost Management. Meter records are the source of truth for billed costs.

    The 19,876 shown in Foundry Traces is a different view. The Agent tracing overview describes traces as capturing an agent run, including nested spans for operations, tools, and token consumption. It does not establish that the trace-list total represents a separate billable request, nor does it establish that it matches the billed token total.

    I have not opened this trace, so I cannot determine which spans make up the 19,876 or reconcile it against the model requests for this run.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.