Find out why your AI app is slow or expensive

See what each AI call costs, how long it takes and which page or feature made it, so you can find the slow or expensive part of your AI app before your users or your bill do.

What Heystack shows you

Everything below is in AI & Safety in the console, for the app and time range you pick at the top.

  • Health. Whether your AI answers are OK: answers, failures, time to first word and to the full answer, answers cut short or declined, with markers when a model, prompt version or release changed. See AI health.
  • Overview. AI spend, with what you're on track to spend this month, across every provider and AI gateway you use; calls; failure rate; the typical slow case; tokens; and agent runs and tool calls when your app uses them.
  • Models. One row per model: calls, failure rate, typical time and typical slow case, tokens and cost. This is the quickest way to see whether one model is the slow or costly one.
  • Spend by route. Your AI cost added up by the page or route of your app that made the call, with calls, failures and tokens. It loads only when you ask for it.
  • Conversations. Each request with the AI calls it made: when, who, which models, tokens, cost and failures. The words of prompts and answers are kept only if you turn that on (it's off by default).
  • Cheapest wins. Suggestions, never changes: for example that a cheaper model from the same family could handle some calls (check the quality first), or that many calls to one model fail.

Home also shows AI spend next to your other key numbers, and a person's page in Users & sessions shows that person's AI calls, tokens and models.

Find what's slow

  1. Compare models. In Models, look at the typical slow case of each model. A model that is slow for everyone points at the model or provider; a slow case far above the typical time points at some calls being much heavier than others.
  2. Open a slow request. Open a conversation, or a request from Explore › Traces, to see the request as steps in order, each with how long it took. Slow spots points out repeated work, one step that takes most of the time, or steps waiting on each other.
  3. Ask what slow requests have in common. In Explore › Traces, choose What's different? and Slow, with a time in milliseconds. Heystack shows which values, such as a route or a release, are more common among the slow requests than the rest.

Find what's expensive

  • Spend by route shows which page or feature costs the most. Calls with no recorded route are grouped as No route recorded.
  • Models shows which model the money goes to, and Cheapest wins suggests where a cheaper model might do.
  • Conversations shows the single requests behind the totals, for example one feature that calls a model many times per request.
  • Budgets. Under Settings › Organisation › AI budgets, set a daily or monthly budget for your organisation, an app, a provider, a model or a gateway consumer, and get alerted at 50%, 80% and 100% and when the month is on pace to overshoot. A budget is an alert, not a meter; for a limit that must never be passed, set a hard cap in your gateway. See AI gateways.

How cost is worked out

  • Cost is the amount your provider reported when it reports one, an Estimate from public prices otherwise, and No price when Heystack doesn't know a model's price. A model with no price is never counted as $0.
  • Heystack's prices cover common models from OpenAI, Anthropic and Google. They don't know your negotiated rates or batch discounts, so treat them as a guide and use your provider's billing for exact figures.
  • Each call is counted once, even when two libraries both report it (for example Heystack's Workers setup and the AI SDK). An agent run or step that wraps model calls shows as a step, not as more calls.
  • Heystack measures the cost, speed and failures of AI calls. It does not score how good the answers are.

See the console guide for the exact rules.

Getting your AI calls into Heystack

Where the numbers come from depends on where your app calls the model:

  • Cloudflare Workers: recorded automatically for calls to OpenAI, Anthropic, Mistral, Google, Cloudflare AI Gateway and Workers AI. See Cloudflare Workers.
  • Next.js or Node.js with the Vercel AI SDK: on AI SDK 7, install the AI SDK's telemetry package and register it once at startup (experimental_telemetry on its own sends nothing in version 7); on AI SDK 5 or 6, turn on the telemetry option on each call. Give each call a feature name (functionId) so Spend by route and Health can tell features apart. See AI frameworks.
  • AI SDK on Cloudflare Workers: keep one copy of the telemetry library that the AI SDK's package and Heystack's both use. If they load different versions, the AI SDK's calls are silently dropped; the recipe shows how to check. See AI frameworks.
  • Python: the OpenAI and Anthropic libraries, LangChain and LangGraph, LlamaIndex, the OpenAI Agents SDK, Pydantic AI and LiteLLM each have a recipe. Turn on one instrumentation per library: two at once can count a call twice. See AI frameworks.
  • Other frameworks and gateways: Mastra, LiteLLM and the Cloudflare and Vercel AI gateways are read too. See AI frameworks and AI gateways.
  • MCP tools: if both your MCP client and your MCP server report a tool call, it shows twice in tool counts. Turn on reporting on one side.
  • Calls made from the browser aren't recorded as AI calls. Record them where your server makes them.
  • Next.js on Cloudflare: AI capture isn't confirmed yet.

If you're not sure which applies, the AI frameworks page has the full table, including what isn't shown yet for each source.

Ask your coding agent

With your coding agent connected to Heystack, you can ask in plain words, for example:

Using Heystack, which AI models did my app call in the last 7 days, what did each cost,
and which one is slowest in its slow cases? Suggest where a cheaper model could work.

The agent reads the same calls, tokens, failure rates, timings and estimated costs you see in the console.

  • AI frameworks: setup for each way of calling a model.
  • Security: AI safety checks that run inside your app. Heystack never sits between your app and the model provider.
  • Quickstart: connect your first app.