Mastra
Build AI agents with TypeScript and React
TypeScripteasy
Mastra is a TypeScript framework for building AI agents. Decyra captures all agent interactions and LLM calls, providing comprehensive observability into your Mastra agents.
Prerequisites
- Decyra account with API key
- Node.js 18+ installed
- Mastra package installed
Installation
npm install @mastra/core @mastra/ai @decyra/sdk
Integration
Wrap the OpenAI client with Decyra:
import { createMastra } from '@mastra/core';
import { createOpenAI } from '@mastra/ai';
import { wrapOpenAI } from '@decyra/sdk';
const openaiClient = createOpenAI({
apiKey: process.env.DECYRA_API_KEY,
baseURL: 'https://proxy.decyra.com/v1',
defaultHeaders: {
'X-Decyra-API-Key': process.env.DECYRA_API_KEY!,
},
});
const decyraClient = wrapOpenAI(openaiClient);
const mastra = createMastra({
name: 'my-app',
ai: {
providers: {
openai: decyraClient,
},
},
});
Define and use an agent:
const agent = mastra.agent({
name: 'assistant',
instructions: 'You are a helpful assistant',
model: 'gpt-4',
});
const response = await agent.generate('Explain quantum computing');
console.log(response.text);
What Gets Captured
| Field | Description |
|---|---|
| Model | The AI model used |
| Temperature | Temperature parameter |
| Agent Name | Name of the Mastra agent |
| Instructions | Agent system instructions |
| Prompt Hash | Hash of the input prompt |
| Response Time | Time for agent execution |
| Token Usage | Input/output tokens |
| Cost | Estimated API cost |
Verify
Check your Decyra dashboard to see agent interactions in the traces view. Each agent call will include full context and model details.