Developer Documentation
Everything you need to integrate the AI Sage runtime control plane into your JS/TS app or n8n workflow.
Quickstart
Install the official client package to start instrumenting your agent runs:
npm install @ai-sage/client
JS/TS SDK Guide
Initialize the client with your agent ID and environment API key:
import { AISage } from "@ai-sage/client";
const sage = new AISage({
agentId: "refund-agent-prod",
apiKey: process.env.AI_SAGE_API_KEY,
});
await sage.guard(async (ctx) => {
const reply = await agent.run(input);
ctx.assert.cost.below(0.40);
return reply;
});Policy Engine
Define runtime policies directly in your dashboard or config files:
- max_cost_per_run: Automatically throttle or halt agents exceeding budget caps.
- allowed_tools: Restrict tool execution to explicit white lists.
- min_confidence: Trigger automated human fallbacks when agent confidence drops below your threshold.
n8n Integration
Connect your live n8n AI workflow nodes to AI Sage to monitor node execution health, token spend, and trigger automated pause actions during runaway loops.
API Reference
POST /v1/agents/guardGuard an execution
GET /v1/agents/:id/healthFetch health & drift metrics
POST /v1/agents/:id/pauseEmergency pause trigger