Mastra

Integrate Mastra with Future AGI for TypeScript agent observability. Configure trace export using the @traceai/mastra package for LLM monitoring.

1. Installation

First install the Mastra and traceAI packages.

npm install @mastra/core @traceai/mastra @traceai/fi-core

2. Set Environment Variables

Configure your Future AGI credentials.

process.env.FI_API_KEY = "your-futureagi-api-key";
process.env.FI_SECRET_KEY = "your-futureagi-secret-key";

3. Configure Mastra Telemetry Export

Use the custom exporter from @traceai/mastra to send traces to Future AGI. You can optionally filter out non-LLM spans using isFISpan.

import { Mastra } from "@mastra/core";
import { FITraceExporter, isFISpan } from "@traceai/mastra";

export const mastra = new Mastra({
  // ... other config
  telemetry: {
    serviceName: "traceai-mastra-agent", // customize the service name
    enabled: true,
    export: {
      type: "custom",
      exporter: new FITraceExporter({
        url: "https://app.futureagi.com/tracer/v1/traces",
        headers: {
          "x-api-key": process.env.FI_API_KEY as string,
          "x-secret-key": process.env.FI_SECRET_KEY as string,
        },
        // Optional: filter out non-LLM/node spans from being sent to Future AGI
        spanFilter: isFISpan,
      }),
    },
  },
});

4. Run your Agent

Once configured, run your Mastra agent as usual. The exporter will automatically send trace data to your Future AGI project.

Was this page helpful?

Questions & Discussion