Mastra launches Metrics API for its platform
Mastra released a Metrics API that lets developers query token usage, model cost, latency and error rates from production Mastra projects via the Mastra Client SDK, Mastra CLI or observability endpoints. The API supports totals, breakdowns, time series and percentile data, and can combine queries with time ranges and status filters to build custom reports, dashboards, downstream data feeds and alerts. Mastra says metrics aggregate across every run, whereas traces show what happened in a single run.
The API lets teams query and aggregate production metrics programmatically, supporting custom dashboards, alerts and agents that construct queries on the fly.
You can now query token usage, model cost, latency, and error rates with Mastra platform's Metrics API. Use the Mastra Client SDK, Mastra CLI, or observability endpoints to get totals, breakdowns, time series, and percentile data from production Mastra projects.
Traces show what happened in a single run, while metrics aggregate across every run. This lets you see which model, conversation, or tool calls cost the most, run the slowest, or fail most often. You can combine query types with time ranges and status filters to surface important insights to share with your team.
Your browser does not support the video tag.
We launched metrics earlier this year, letting you view model costs, latency, and error counts in Mastra platform and Studio. Today, using the Metrics API, you can construct your own queries to generate custom reports, build dashboards, send data to downstream services, or post alerts to connected chat platforms when model costs or error rates rise.
You can combine the Metrics API with code mode to build agents capable of constructing their own queries on the fly to answer questions, summarize insights, or generate PDFs for team members and stakeholders.