Skip to main content

Installation

npm
npm install @raindrop-ai/mastra @mastra/core

Quick Start

import { createRaindropMastra } from "@raindrop-ai/mastra";
import { Agent } from "@mastra/core/agent";
import { openai } from "@ai-sdk/openai";

const raindrop = createRaindropMastra({
  writeKey: "rk_...",
  userId: "user-123",
});

const agent = new Agent({
  name: "Assistant",
  model: openai("gpt-4o-mini"),
  instructions: "Be helpful",
});

const wrapped = raindrop.wrap(agent);

const response = await wrapped.generate("What is the capital of France?");
console.log(response.text);

await raindrop.shutdown();

What Gets Traced

  • Agent generate — input prompt, output text, model, token usage (promptTokens/completionTokens)
  • Errors — captured with error status, re-thrown to caller

Configuration

const raindrop = createRaindropMastra({
  writeKey: "rk_...",       // Optional: omit to disable telemetry
  endpoint: "...",          // Optional: custom Raindrop API endpoint
  userId: "user-123",      // Optional: associate events with a user
  convoId: "convo-456",    // Optional: conversation/thread ID
  debug: false,             // Optional: enable verbose logging
});

Flushing and Shutdown

await raindrop.flush();     // flush pending data
await raindrop.shutdown();  // flush + release resources