TypeScript SDK
The official TypeScript SDK for MeetLoyd (@meetloyd/client) provides typed access to the platform API with streaming support. It covers agents, conversations, tasks, schedules, triggers, memory, teams, manifests, governance, billing, and more.
Installation
npm install @meetloyd/client
# or
bun add @meetloyd/client
Quick Start
import { MeetLoyd } from '@meetloyd/client';
const client = new MeetLoyd({
apiKey: 'sk_live_your_api_key',
baseUrl: 'https://app.meetloyd.com', // Optional (defaults to localhost:4000)
timeout: 30000, // Optional, in ms
});
// List agents
const { agents } = await client.agents.list();
console.log(agents);
// Create an agent
const agent = await client.agents.create({
name: 'My Assistant',
systemPrompt: 'You are a helpful assistant.',
model: 'claude-sonnet-4-6',
});
// Execute an agent (single message, non-streaming)
const run = await client.agents.execute(agent.id, 'Hello!');
console.log(run);
Client Configuration
The MeetLoyd constructor accepts a MeetLoydConfig object:
const client = new MeetLoyd({
apiKey: 'sk_live_...', // Required
baseUrl: 'https://...', // Optional (default: http://localhost:4000)
timeout: 30000, // Optional, ms (default: 30000)
});
API Modules
The client exposes the following API modules as public properties:
| Module | Description |
|---|---|
client.agents | List, get, create, update, delete, execute, pause, resume agents; list runs |
client.conversations | Create, get, delete conversations; stream and send messages |
client.usage | Usage summary, daily breakdown, per-agent usage |
client.tasks | CRUD for tasks, run, cancel |
client.workflows | CRUD for workflows, run, pause, activate; list/cancel runs |
client.teams | CRUD for teams, member management |
client.templates | Browse, deploy, manage templates |
client.schedules | CRUD for schedules, pause/resume/trigger |
client.triggers | CRUD for triggers, enable/disable/test |
client.manifests | Validate, resolve, deploy, upgrade, rollback manifests |
client.memory | Create, search, list, delete memories; quick-store helpers; team memory; A2A; storage config |
client.tools | List, get, test, delete tools; list builtins |
client.store | Browse, install, uninstall; reviews |
client.apiKeys | List, create, delete, rotate API keys |
client.governance | Kill switch, prompt versioning, suggestions, A/B tests, audit log |
client.budgets | Budget CRUD, check, summary, stats |
client.dlp | DLP config, classifications, permissions, violations |
client.cot | Chain-of-thought config, records, annotations |
client.compliance | Compliance frameworks, reports, schedules, evidence |
client.lifecycle | First-start, charters, handshakes, discovery cache |
client.securityCenter | Dashboard, controls, config |
client.accessReviews | Access review CRUD, decisions |
client.sso | SSO/SAML config |
client.audit | Audit logs, SIEM integrations, hash chain verification |
client.incidents | Incidents, timeline, security alerts, change requests |
client.identity | NANDA AgentFacts, SPIFFE, TBAC, token exchange, attestations |
client.contextGraph | Entities, edges, visibility policies, propagation, cross-team hints |
client.projects | Projects, milestones, artifacts, members, vault, dispatch rules |
client.files | Upload, download, parse, scan files |
client.models | List models, capabilities, cost calculation |
client.billing | Subscription, plans, invoices, payment methods |
client.analytics | Dashboard, time series, rankings, costs, errors, patterns |
client.notifications | List, read, preferences, push subscriptions |
client.webhooks | CRUD for webhooks, deliveries, retry |
client.oauthIntegrations | Browse catalog, connect/disconnect, OAuth config |
client.loydSurfaces | Loyd chat interface |
Agents API
// List agents (paginated)
const { agents, meta } = await client.agents.list({ page: 1, limit: 20 });
// Get a single agent
const agent = await client.agents.get('agent-id');
// Create an agent
const newAgent = await client.agents.create({
name: 'Support Agent',
systemPrompt: 'You are a customer support agent.',
model: 'claude-sonnet-4-6',
});
// Update an agent
const updated = await client.agents.update('agent-id', { name: 'New Name' });
// Delete an agent
await client.agents.delete('agent-id');
// Execute (non-streaming)
const run = await client.agents.execute('agent-id', 'Summarize this report.');
// List runs for an agent
const { runs } = await client.agents.runs('agent-id', { limit: 10 });
// Pause / Resume
await client.agents.pause('agent-id');
await client.agents.resume('agent-id');
Conversations API
// Create a conversation
const conversation = await client.conversations.create({ agentId: 'agent-id' });
// Get conversation with messages
const conv = await client.conversations.get('conversation-id');
// List conversations by agent
const { conversations } = await client.conversations.listByAgent('agent-id');
// Stream a response (SSE)
for await (const event of client.conversations.stream('conversation-id', 'Hello!')) {
if (event.type === 'token') {
process.stdout.write(event.token);
} else if (event.type === 'tool_call') {
console.log('Tool called:', event.toolCall);
} else if (event.type === 'done') {
console.log('Done. Tokens:', event.data.tokenUsage.total);
} else if (event.type === 'error') {
console.error('Error:', event.error);
}
}
// Send and collect the full response (convenience wrapper around stream)
const result = await client.conversations.send('conversation-id', 'Hello!');
console.log(result.content);
console.log(result.tokenUsage); // { input, output, total }
console.log(result.cost);
// Delete a conversation
await client.conversations.delete('conversation-id');
Error Handling
The SDK exports a single error class, MeetLoydError:
import { MeetLoyd, MeetLoydError } from '@meetloyd/client';
try {
await client.agents.get('nonexistent');
} catch (error) {
if (error instanceof MeetLoydError) {
console.log(error.message); // Human-readable message
console.log(error.status); // HTTP status code (e.g. 404)
console.log(error.code); // Optional error code string (e.g. 'NOT_FOUND')
}
}
MeetLoydError is thrown for HTTP errors, timeouts (status 408, code TIMEOUT), and network failures (status 0, code NETWORK_ERROR).
Low-Level Request Methods
For advanced use cases, the client exposes three request methods:
// JSON request
const data = await client.request<MyType>('GET', '/api/v1/custom-endpoint');
// XML body request (e.g. MSPDI import)
const data = await client.requestText<MyType>('POST', '/api/v1/projects/import', xmlString);
// SSE streaming
for await (const event of client.stream('POST', '/api/v1/some-stream', body)) {
// event: StreamEvent { type: 'token' | 'tool_call' | 'done' | 'error', ... }
}
Best Practices
- Use environment variables for API keys -- never hardcode them.
- Reuse the client instance -- create once and share across your application.
- Use streaming for interactive or long-running responses (
conversations.stream()). - Handle
MeetLoydError-- checkerror.statusto distinguish 401/403/404/429 errors.
Next: Learn about the Python SDK for Python applications.