Need to use Agentuity services from a Next.js route, Express server, or standalone script? Each service is available as a lightweight npm package with the same API you already know from ctx.*.
Available Packages
| Package | Install | Description |
|---|---|---|
@agentuity/keyvalue | bun add @agentuity/keyvalue | Store and retrieve data by key with TTL support |
@agentuity/vector | bun add @agentuity/vector | Semantic search with automatic embedding generation |
@agentuity/sandbox | bun add @agentuity/sandbox | Create and manage isolated execution environments |
@agentuity/queue | bun add @agentuity/queue | Publish messages to worker and pub/sub queues |
@agentuity/db | bun add @agentuity/db | Execute SQL queries and inspect table schemas |
@agentuity/email | bun add @agentuity/email | Send and receive emails with managed addresses |
@agentuity/webhook | bun add @agentuity/webhook | Manage webhook endpoints and track deliveries |
@agentuity/schedule | bun add @agentuity/schedule | Create cron-based scheduled jobs |
@agentuity/task | bun add @agentuity/task | Track work items with comments, tags, and attachments |
@agentuity/coder | bun add @agentuity/coder | Manage Coder sessions, participants, and replay data |
Quick Example
import { KeyValueClient } from '@agentuity/keyvalue';
const kv = new KeyValueClient();
await kv.set('cache', 'user:123', { name: 'Alice', role: 'admin' });
const result = await kv.get('cache', 'user:123');When to Use What
Agentuity services are accessible four ways, depending on where your code runs:
- Agent handler (
ctx.*): Inside acreateAgenthandler. Services are pre-configured on the context object. - Route handler (
c.var.*): Inside anew Hono<Env>()route (import type { Env } from '@agentuity/runtime'). Same services, accessed via Hono context variables. - Standalone package: From any Node.js or Bun app (Next.js, Express, scripts). Install one package, set an env var.
- REST API: Direct HTTP access from any language or environment.
| Service | Agent (ctx.*) | Route (c.var.*) | Standalone Package | REST API |
|---|---|---|---|---|
| Key-Value | ctx.kv | c.var.kv | @agentuity/keyvalue | API |
| Vector | ctx.vector | c.var.vector | @agentuity/vector | API |
| Sandbox | ctx.sandbox | c.var.sandbox | @agentuity/sandbox | API |
| Queues | ctx.queue | c.var.queue | @agentuity/queue | API |
| Database | N/A | N/A | @agentuity/db | API |
ctx.email | c.var.email | @agentuity/email | API | |
| Webhooks | N/A | N/A | @agentuity/webhook | API |
| Schedules | ctx.schedule | c.var.schedule | @agentuity/schedule | API |
| Tasks | ctx.task | c.var.task | @agentuity/task | API |
| Coder | N/A | N/A | @agentuity/coder | API |
Services like Streams, Logger, Tracer, Thread, and Session are also available via ctx.* and c.var.* but don't have standalone packages. See Accessing Services for the complete reference.
Key-Value Storage
Fast lookups, caching, configuration, and rate limiting.
bun add @agentuity/keyvalueimport { KeyValueClient } from '@agentuity/keyvalue';
const kv = new KeyValueClient();
// Store with optional TTL (in seconds)
await kv.set('cache', 'session:abc', { userId: '123' }, { ttl: 3600 });
// Retrieve
const result = await kv.get('cache', 'session:abc');
if (result.exists) {
console.log(result.data);
}
// Search keys by keyword
const matches = await kv.search('cache', 'session');
// Delete
await kv.delete('cache', 'session:abc');Constructor options:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | AGENTUITY_SDK_KEY env var | API key for authentication |
url | string | Auto-detected from region | Base URL for the KV API |
orgId | string | - | Organization ID for multi-tenant operations (optional) |
logger | Logger | Minimal logger | Custom logger instance |
For the complete key-value API including namespace management and stats, see Key-Value Storage.
Vector Search
Semantic search with automatic embedding generation.
bun add @agentuity/vectorimport { VectorClient } from '@agentuity/vector';
const vector = new VectorClient();
// Upsert documents (embeddings are generated automatically)
await vector.upsert('docs', {
key: 'doc-1',
document: 'Agentuity provides cloud-native agent hosting',
metadata: { source: 'readme' },
});
// Search by natural language query
const results = await vector.search('docs', {
query: 'how to deploy agents',
limit: 5,
});Constructor options:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | AGENTUITY_SDK_KEY env var | API key for authentication |
url | string | Auto-detected from region | Base URL for the Vector API |
orgId | string | - | Organization ID for multi-tenant operations (optional) |
logger | Logger | Minimal logger | Custom logger instance |
For the complete vector API including TTL, batch operations, and metadata filtering, see Vector Storage.
Sandbox
Isolated execution environments for running untrusted code, build pipelines, or compute jobs.
bun add @agentuity/sandboximport { SandboxClient } from '@agentuity/sandbox';
const client = new SandboxClient();
// One-shot execution (creates, runs, destroys automatically)
const result = await client.run(
{ command: { exec: ['echo', 'hello world'] } },
{ stdout: process.stdout, stderr: process.stderr }
);
console.log('Exit code:', result.exitCode);
// Interactive sandbox (long-lived)
const sandbox = await client.create({ runtime: 'bun:1' });
await sandbox.execute({ command: ['bun', 'install'] });
await sandbox.writeFiles([{ path: 'index.ts', content: Buffer.from('console.log("hi")') }]);
await sandbox.destroy();Constructor options:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | AGENTUITY_SDK_KEY env var | API key for authentication |
url | string | Auto-detected from region | Base URL for the Sandbox API |
orgId | string | - | Organization ID for multi-tenant operations (optional) |
logger | Logger | Minimal logger | Custom logger instance |
For the complete sandbox API including snapshots, jobs, checkpoints, and file operations, see Sandboxes.
Message Queues
Publish messages to worker and pub/sub queues for asynchronous processing.
bun add @agentuity/queueimport { QueueClient } from '@agentuity/queue';
const queue = new QueueClient();
// Create a queue
await queue.createQueue('notifications');
// Publish a message
await queue.publish('notifications', {
type: 'welcome',
userId: '123',
});
// Delete a queue
await queue.deleteQueue('notifications');Constructor options:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | AGENTUITY_SDK_KEY env var | API key for authentication |
url | string | Auto-detected from region | Base URL for the Queue API |
orgId | string | - | Organization ID for multi-tenant operations (optional) |
logger | Logger | Minimal logger | Custom logger instance |
For the complete queue API including consumption patterns and message acknowledgment, see Message Queues.
Database
Execute SQL queries and inspect table schemas on your Agentuity-managed database.
bun add @agentuity/dbimport { DBClient } from '@agentuity/db';
const db = new DBClient({
database: 'my-database',
orgId: 'org_abc123',
});
// Execute a query
const result = await db.query('SELECT * FROM users LIMIT 10');
console.log(result.columns, result.rows);
// List tables
const tables = await db.tables();
// Get query logs
const logs = await db.logs({ limit: 50 });DBClient requires database and orgId in the constructor. These are not optional because every query targets a specific database within an organization.
Constructor options:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | AGENTUITY_SDK_KEY env var | API key for authentication |
url | string | Auto-detected from region | Base URL for the DB API |
database | string | Required | Database name |
orgId | string | Required | Organization ID |
region | string | AGENTUITY_REGION or usc | Cloud region |
logger | Logger | Minimal logger | Custom logger instance |
Send and receive emails using managed addresses with webhook-based inbound routing.
bun add @agentuity/emailimport { EmailClient } from '@agentuity/email';
const email = new EmailClient();
// Create a managed email address
const address = await email.createAddress('support');
// Send an email
await email.send({
from: address.email,
to: ['user@example.com'],
subject: 'Welcome!',
text: 'Thanks for signing up.',
});
// List inbound emails
const inbound = await email.listInbound(address.id);Constructor options:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | AGENTUITY_SDK_KEY env var | API key for authentication |
url | string | Auto-detected from region | Base URL for the Email API |
orgId | string | - | Organization ID for multi-tenant operations (optional) |
logger | Logger | Minimal logger | Custom logger instance |
Webhooks
Create webhook endpoints, route deliveries to destinations, and track receipts.
bun add @agentuity/webhookimport { WebhookClient } from '@agentuity/webhook';
const webhooks = new WebhookClient();
// Create a webhook endpoint
const result = await webhooks.create({ name: 'stripe-events' });
// Add a destination
await webhooks.createDestination(result.webhook.id, {
type: 'url',
config: { url: 'https://myapp.com/api/stripe' },
});
// List receipts
const receipts = await webhooks.listReceipts(result.webhook.id);Constructor options:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | AGENTUITY_SDK_KEY env var | API key for authentication |
url | string | Auto-detected from region | Base URL for the Webhook API |
orgId | string | - | Organization ID for multi-tenant operations (optional) |
logger | Logger | Minimal logger | Custom logger instance |
Schedules
Create cron-based scheduled jobs that deliver payloads to configured destinations.
bun add @agentuity/scheduleimport { ScheduleClient } from '@agentuity/schedule';
const schedules = new ScheduleClient();
// Create a schedule (runs every hour)
const result = await schedules.create({
name: 'hourly-sync',
expression: '0 * * * *',
});
// List all schedules
const list = await schedules.list();
// Get a specific schedule
const details = await schedules.get(result.schedule.id);Constructor options:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | AGENTUITY_SDK_KEY env var | API key for authentication |
url | string | Auto-detected from region | Base URL for the Schedule API |
orgId | string | - | Organization ID for multi-tenant operations (optional) |
logger | Logger | Minimal logger | Custom logger instance |
Tasks
Track work items with comments, tags, attachments, and a full activity changelog.
bun add @agentuity/taskimport { TaskClient } from '@agentuity/task';
const tasks = new TaskClient();
// Create a task
const task = await tasks.create({
title: 'Fix login bug',
type: 'bug',
priority: 'high',
});
// Add a comment
await tasks.createComment(task.id, 'Reproduced on Chrome 120', 'user_abc');
// Tag it
const tag = await tasks.createTag('urgent', '#ff0000');
await tasks.addTagToTask(task.id, tag.id);
// List all tasks
const list = await tasks.list({ status: 'open' });Constructor options:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | AGENTUITY_SDK_KEY env var | API key for authentication |
url | string | Auto-detected from region | Base URL for the Task API |
orgId | string | - | Organization ID for multi-tenant operations (optional) |
logger | Logger | Minimal logger | Custom logger instance |
Coder
Manage Coder sessions, participants, workspaces, replay data, and loop state from any Node.js or Bun app.
Coder has no single static base URL. When url and AGENTUITY_CODER_URL are unset, CoderClient calls the Agentuity API for your org's Hub address, then routes session and workspace requests against it. Use the client to skip implementing that flow yourself, or pass an explicit url to skip discovery.
bun add @agentuity/coderimport { CoderClient } from '@agentuity/coder';
const client = new CoderClient();
// List sessions
const { sessions } = await client.listSessions({ limit: 10 });
for (const session of sessions) {
console.log(`${session.sessionId}: ${session.label}`);
}
// Create a new session
const session = await client.createSession({
task: 'Implement feature X',
workflowMode: 'standard',
});
console.log(`Created session: ${session.sessionId}`);
// Get replay data for a session
const replay = await client.getReplay(session.sessionId);
// List participants
const { participants } = await client.listParticipants(session.sessionId);
// Archive a session when done
await client.archiveSession(session.sessionId);Constructor options:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | AGENTUITY_SDK_KEY env var | API key for authentication |
url | string | Auto-discovered via Agentuity API | Base URL for the Coder Hub. Set explicitly to skip discovery |
region | string | AGENTUITY_REGION or usc | Region used during discovery. Ignored when url or AGENTUITY_CODER_URL is set |
orgId | string | - | Organization ID for multi-tenant operations (optional) |
logger | Logger | Minimal logger | Custom logger instance |
For every CoderClient method with signatures, parameters, and return types, see CoderClient Reference. For concepts, session lifecycle, and workflow guidance, see Coder.
Configuration
All standalone packages share the same configuration pattern. Set environment variables once, and every client picks them up automatically.
All standalone packages require an API key. Set the AGENTUITY_SDK_KEY environment variable or pass apiKey directly to each client constructor. For the difference between SDK keys and CLI login credentials, see Agentuity Keys.
Environment Variables
| Variable | Description | Default |
|---|---|---|
AGENTUITY_SDK_KEY | API key for authentication | Required |
AGENTUITY_REGION | Region for API endpoints | usc |
Each service also supports a URL override variable for custom deployments:
| Variable | Service |
|---|---|
AGENTUITY_KEYVALUE_URL | Key-Value Storage |
AGENTUITY_VECTOR_URL | Vector Search |
AGENTUITY_SANDBOX_URL | Sandbox |
AGENTUITY_QUEUE_URL | Message Queues |
AGENTUITY_DB_URL | Database |
AGENTUITY_EMAIL_URL | |
AGENTUITY_WEBHOOK_URL | Webhooks |
AGENTUITY_SCHEDULE_URL | Schedules |
AGENTUITY_TASK_URL | Tasks |
AGENTUITY_CODER_URL | Coder |
Shared Constructor Pattern
Every client follows the same constructor pattern:
import { KeyValueClient } from '@agentuity/keyvalue';
// Minimal: uses env vars for everything
const kv = new KeyValueClient();
// Explicit: override specific options
const kvCustom = new KeyValueClient({
apiKey: 'agentuity_sk_...',
orgId: 'org_abc123',
});Most constructor options are validated at initialization using Zod schemas. DBClient also requires database and orgId because every request targets one database in one organization.