Skip to main content
For a complete example, check out our Mastra integration example on GitHub.
Mastra is a framework for building AI agents with built-in support for multiple LLM providers. This guide shows you how to integrate Gentrace with Mastra to trace and monitor your AI agents.

Prerequisites

Installation

Configuration

Initialize both Gentrace and Mastra in your application:

Usage

Here’s a complete example showing how to create and use a Mastra agent with Gentrace tracing:
agents/email-assistant.ts

Environment Variables

Create a .env file with your API keys:
.env

Advanced Features

Using Multiple Agents

Mastra supports creating multiple agents with different configurations:

Agent Tools and Functions

Mastra agents can use tools and functions, which are automatically traced by Gentrace: