THR979 · Theater
Follow the Tokens: Finding the Real Cost of Your Foundry AI Models
Speakers: Toni Pohl
Microsoft’s player cannot open a video at a given time: once it plays, skip to the time shown.
What the session covers
Toni Pohl explains how to find out what individual Microsoft Foundry model deployments cost, given that Azure billing only shows cost per resource group or Foundry project. He covers token basics: input vs output pricing, context windows, guards and filters that also use tokens, and prompt caching. He then shows how to pull list prices from the Azure retail prices API with PowerShell and how third-party models such as Claude are billed through Azure Marketplace, and he briefly explains Copilot credits and GitHub AI credits. Next he reads token usage from a Foundry agent API response and walks through a per-request cost formula, followed by optimisation tips. The last part is an unattended C# app that queries Azure Monitor metrics for per-model token usage and cost, with the results analysed in Power BI.
Best for: Developers, Azure administrators and FinOps teams who need per-request or per-model cost data for Foundry model deployments for reporting and budgeting.
New material: no clear start of new material was found in this session.
Where to skip: Skip the token basics and jump to 05:43 for the retail prices API demo. 09:43 briefly covers Copilot credits and GitHub AI credits. The core is 11:38 to 18:03 (token usage from the agent API and the per-request cost formula) and the Azure Monitor + C# + Power BI demo at 20:13. The optimisation tips at 18:03 are mostly well-known practices.
Chapters (9)
- 00:02 Recap Depth 100 · Novelty 0/3
Introduction and agenda: why per-model cost of Foundry models matters
The host introduces Toni Pohl, an IT consultant, who frames the session around the question users and cost centres ask: how much does using a model or agent cost. He outlines four parts: how cost is measured, how to get model prices, how to see the cost of a single request, and how administrators get per-model cost. He notes that Azure billing shows cost only per resource group or Foundry project, not per individual model.
- 01:53 Deep dive Depth 200 · Novelty 1/3
How token costs arise: tokenization, input vs output, context windows, caching
The speaker explains the LLM pipeline (tokenization, embeddings, transformation) and that only the input is controllable while output is billed at a higher price because it includes the model's computation. He shows a tokenizer tool where a 33-character prompt yields 15 tokens and gives the rule of thumb that 100 tokens are roughly 75 English words (words × 1.3). He covers per-token billing including cached and output tokens, context windows of 100,000 up to about 1.1 million tokens, guards and filters in Foundry that also consume tokens, and flags prompt caching as a key cost saver.
- 05:43 Demo Depth 300 · Novelty 1/3
Demo: querying the Azure retail prices API for Foundry models with PowerShell
The speaker explains two price sources: the retail (consumer) price list and an API for cloud solution providers. A PowerShell script 'get prices' builds a URI for all Foundry models in West US 2 in USD, follows the next-page link for paging and writes the results to CSV and JSON. In the JSON he shows each model listed several times with separate meters for input, cached input and output; for an MAI model input costs 2 cents per 1 million tokens, cached input a tenth of that, and output is much more expensive. A search for Claude returns nothing, which leads to the next topic.
- 09:43 Deep dive Depth 200 · Novelty 1/3
Third-party model billing, MACC eligibility, Copilot credits and GitHub AI credits
The retail API covers services sold through Microsoft Foundry, but vendors such as Anthropic bill separately, with Claude consumption units converted into costs in Azure Marketplace that customers must look up themselves. Azure Marketplace offers are eligible for Microsoft Azure Consumption Commitment. He then describes AI credits: Copilot credits in the Microsoft 365 ecosystem and GitHub AI credits, both converted from token usage and currently priced at 1 cent per credit retail. For GitHub Copilot he cites Claude Opus 5.5 with a 1.1 million token context at 400 credits input and 2,000 credits output per 1 million tokens, and suggests cheaper models such as Claude Sonnet at about half the price.
- 11:38 Demo Depth 300 · Novelty 1/3
Demo: reading token usage from a Foundry agent response via the API
A demo chat agent in a Foundry project is asked about the weather in San Francisco in the playground; the YAML view shows agent version and instructions but no cost. The same request is sent from a PowerShell script to the project endpoint, creating a conversation and saving the output to response.json. The response contains a usage section with about 1,500 input tokens, zero cached tokens on the first call, output tokens, total tokens and a tools section when the agent used a tool such as the Foundry toolbox.
- 15:21 Deep dive Depth 300 · Novelty 1/3
Cost formula per request and the effect of cached tokens
The speaker warns that most major LLMs return usage data but it is not universally standardised, so cost logic must not assume identical responses. He recommends developers store usage per request in a database or show it to users for transparency. The formula subtracts cached tokens from input tokens, then adds cached-token, output-token and tool costs, usually priced per million tokens; a GPT-5 example in South Central US at $1.25 shows a request costing almost 1 cent with caching versus about 3 cents without. He advises putting stable content first and asking follow-up questions on previous results to benefit from caching.
- 18:03 Deep dive Depth 300 · Novelty 1/3
Cost optimisation tips: Foundry toolbox, caching, RAG size, output length, model choice
The speaker recommends the Foundry toolbox for agents with multiple tools, because it reduces requests and token usage by giving the orchestrator only the relevant tool definition, which is also cached internally. Further tips: exploit prompt caching and cache breakpoints (e.g. with GPT-5.6), shorten agent instructions, limit RAG retrieval size with thresholds or semantic ranking in AI Search, and cap output length or force a JSON structure. He also advises keeping tool results small and noting that the latest model is not always needed; older models like GPT-4 or GPT-5 may suffice for simple tasks such as PDF summarisation.
- 20:13 Demo Depth 300 · Novelty 1/3
Demo: per-model cost from Azure Monitor with an unattended C# app and Power BI
For administrators, standard Azure billing shows cost per Foundry project only, so the speaker queries Azure Monitor metrics for a project to get per-model token usage. A C# app (intended to run nightly, e.g. in an Azure Function) authenticates as an app registration 'Get Foundry Usage' with a certificate or secret, needs no API permissions, but must have the Monitoring Reader role on the Foundry project. The app queries 30 days of data, applies hard-coded prices and outputs per-model requests, input and output tokens and cost (e.g. GPT-5 at $1.07). The data is loaded into a database and analysed in Power BI, e.g. November consumption of GPT-5.1 with an average of about 30 cents per request.
- 24:35 Closing Depth 100 · Novelty 0/3
Summary, sample repository and closing
The speaker summarises: control and optimise inputs and prompts, have developers capture and store usage data per request, and let administrators use Azure Monitor for per-model cost. Samples and slides are available in the Ignite GitHub repository via a QR code. The host closes the last session in the theatre.
Announcements (0)
No specific announcement was made in this session.
Demos (4)
-
Estimate how many tokens a prompt consumes before sending it to a model.
Steps (3)
- Open the tokenizer tool in the browser.
- Type a sample prompt into the text field.
- Read the resulting token and character counts (15 tokens, 33 characters in the demo).
-
Retrieve the list prices of all Foundry models for a given region and currency so that per-token costs can be calculated.
Steps (6)
- Run the PowerShell script 'get prices' and enter the parameters: region West US 2, currency USD, output format CSV or JSON.
- The script builds the retail prices API URI filtered to Foundry models in the region and currency.
- The script checks whether a next page link exists and, if so, also reads the next page until the link is empty.
- The results are collected into a results object and written to CSV and JSON files.
- Open the prices JSON file and search for a model (e.g. an MAI model).
- Compare the meters for input, cached input and output price per 1 million tokens.
Prerequisites: PowerShell; the samples are available in the Ignite GitHub repository.
-
Developers retrieve the token usage of a single agent request so that its cost can be calculated and shown to users.
Steps (6)
- In the Foundry project playground, open the chat agent and enter the prompt about the weather in San Francisco.
- Inspect the YAML view of the response and note that it shows agent version and instructions but no cost.
- Run a PowerShell script with the project endpoint, agent name and prompt.
- Create a conversation and send the prompt to the agent.
- Save the response to response.json.
- Inspect the usage section: input tokens, cached tokens, output tokens, total tokens and the tools section.
Prerequisites: A Foundry project with a deployed agent; PowerShell; samples in the Ignite GitHub repository.
-
Administrators and FinOps teams get unattended per-model token usage and estimated cost for a Foundry project for reporting and budgeting.
Steps (8)
- Create an app registration (here 'Get Foundry Usage') with a certificate or client secret; no API permissions are required.
- In the Foundry project's access control (role management), assign the application the Monitoring Reader role.
- Configure the C# app's environment variables with the tenant ID and application ID, and set the target Foundry resource.
- Set the time range (30 days in the demo) and the model prices (hard-coded in the demo).
- Run the app (F5): it acquires a token and queries Azure Monitor for the project's metrics.
- Review the output per model: requests, input tokens, output tokens and calculated cost.
- Store the results in a database and analyse them in Power BI (e.g. consumption of GPT-5.1 in November).
- Optionally schedule the app to run nightly, e.g. in an Azure Function.
Prerequisites: App registration with certificate or secret; Monitoring Reader role on the Foundry project; .NET/C#; step-by-step README and samples in the Ignite GitHub repository.