Quickstart
Go from zero to governed AI actions in 5 minutes.
Prerequisites
- Node.js 18+ or any JavaScript runtime with
fetchsupport - A KeylessAI account (sign up free)
- Your API key, org ID, and agent ID from the dashboard
Steps
1
Install the SDK
npm install @keylessai/sdk
2
Initialize the client
import { KeylessAI } from '@keylessai/sdk'; const keyless = new KeylessAI({ apiKey: 'ka_live_xxx', // from dashboard orgId: 'your-org-id', // from dashboard agentId: 'your-agent-id', // from dashboard autoPolicy: true, // $1,000+ requires approval });
autoPolicy: true is the default. Any action with amount ≥ $1,000 automatically requires human approval.
3
Simulate first (dry run)
const sim = await keyless.simulate({ action: 'ads.budget_increase', amount: 500, target: { campaign: 'camp_abc' }, }); console.log(sim.policyDecision); // 'allow' console.log(sim.riskScore); // 0.3 console.log(sim.budgetImpact); // { cost: 500, remaining: 9500 }
simulate() runs the full policy engine without executing anything. Use it to preview what would happen.
4
Execute a governed action
const result = await keyless.execute({ action: 'ads.budget_increase', amount: 500, target: { campaign: 'camp_abc' }, idempotencyKey: 'budget-increase-2026-04-05', }); if (result.status === 'completed') { console.log('Done!', result.executionId); } else if (result.status === 'awaiting_approval') { console.log('Needs approval:', result.intentId); // Wait for human approval const approved = await keyless.waitForApproval(result.intentId); const final = await keyless.resume(result.intentId); console.log('Executed after approval:', final.executionId); } else if (result.status === 'denied') { console.log('Blocked by policy:', result.error); }
5
Check the audit ledger
const ledger = await keyless.ledger({ from: '2026-04-01', limit: 10, }); console.log(ledger.summary); // { total: 42, completed: 38, failed: 2, denied: 1, pending: 1, total_cost: 15200 }
What's next
- SDK Reference — Full method docs, types, error handling
- API Reference — Direct REST endpoint usage