Mirra SDK Overview of the Mirra SDK tools and libraries
The Mirra SDK provides a typed, idiomatic interface for interacting with the Mirra Platform. It is available for TypeScript/Node.js.
npm install @mirra-messenger/sdk
View on npm
Initialize the SDK with your API key (from the web app under Settings → API Keys , or the mobile app):
import { MirraSDK } from '@mirra-messenger/sdk' ;
const mirra = new MirraSDK ({
apiKey: process.env. MIRRA_API_KEY
});
Always load your API key from environment variables rather than hardcoding it.
The SDK provides programmatic access to:
Store and retrieve knowledge with semantic search capabilities.
// Create a memory entity
await mirra.memory. create ({
type: 'note' ,
content: 'Important meeting notes...' ,
metadata: { topic: 'project-x' }
});
// Semantic search
const results = await mirra.memory. search ({
query: 'meeting notes about project' ,
limit: 10
});
Access language models for chat, streaming, and decision-making.
// Chat completion
const response = await mirra.ai. chat ({
messages: [{ role: 'user' , content: 'Summarize this document...' }],
model: 'claude-3-5-sonnet'
});
// Streaming response
for await ( const chunk of mirra.ai. chatStream ({ messages })) {
process.stdout. write (chunk.delta);
}
// Decision making with reasoning
const decision = await mirra.ai. decide ({
prompt: 'Which approach should we take?' ,
options: [
{ id: 'a' , label: 'Option A' },
{ id: 'b' , label: 'Option B' }
]
});
Deploy and execute serverless functions.
// Create a script
const script = await mirra.scripts. create ({
name: 'My Automation' ,
description: 'Processes incoming data' ,
code: 'async function main(params) { return { success: true }; } module.exports = { main };' ,
runtime: 'nodejs18'
});
// Execute a script
const result = await mirra.scripts. invoke ({
scriptId: script.id,
payload: { data: 'input' }
});
Every typed namespace below is a wrapper over one generic dispatch call. Use it
directly when you need an operation the typed surface doesn't expose yet.
// resourceId is an adapter id — 'flows', 'telegram', 'google-calendar', ...
const result = await mirra.resources. call ({
resourceId: 'google-calendar' ,
method: 'listEvents' ,
params: { maxResults: 10 }
});
Prefer the typed namespaces (mirra.googleCalendar.listEvents(...)) — they give
you argument and return types. resources.call is the untyped escape hatch.
Upload, process, and search documents in your knowledge graph.
// Upload a document
const doc = await mirra.documents. upload ({
file: base64Content,
filename: 'report.pdf' ,
mimeType: 'application/pdf'
});
// Search across documents
const results = await mirra.documents. search ({
query: 'quarterly revenue' ,
limit: 5
});
Create event-driven and scheduled automations.
// Create an event-triggered flow
const flow = await mirra.flows. createEventFlow ({
title: 'New Message Handler' ,
description: 'Responds to incoming messages' ,
trigger: {
type: 'event' ,
config: { eventSource: 'telegram' }
},
scriptId: 'my-script-id'
});
// Create a scheduled flow
const cronFlow = await mirra.flows. createTimeFlow ({
title: 'Daily Report' ,
description: 'Generates daily summary' ,
trigger: {
type: 'time' ,
config: { cronExpression: '0 9 * * *' }
},
scriptId: 'report-script-id'
});
The SDK includes pre-built adapters for popular services:
Category Integrations Messaging Telegram, Mirra Messaging Google Gmail, Calendar, Drive, Sheets, Docs Productivity Jira, Trello Social Twitter Crypto Jupiter Exchange, Wallet operations
Access adapters directly on the SDK instance:
// Send a Telegram message
await mirra.telegram. sendMessage ({
chatId: '123456' ,
text: 'Hello from Mirra!'
});
// Create a Google Calendar event
await mirra.googleCalendar. createEvent ({
title: 'Team Meeting' ,
startTime: '2025-01-30T10:00:00Z' ,
endTime: '2025-01-30T11:00:00Z'
});
For more details, see the Authentication Guide .