§ DOCUMENTATION
Getting Started
Add AI agent governance to your application in under 5 minutes.
Prerequisites
https://api.execlave.comChoose your SDK
TypeScript/JavaScript and Python are both first-class. Pick one — the rest of this guide adapts.
Instant setup with an AI assistant
Copy this prompt into GitHub Copilot, Cursor, or any AI coding assistant. It will install and wire Execlave into your project automatically.
Integrate Execlave into my project using the JavaScript/TypeScript SDK. Here's what you need to do: 1. Install the SDK: npm install @execlave/sdk 2. Add this environment variable to my .env file: EXECLAVE_API_KEY=<my-api-key> 3. Create a file called "execlave.ts" (or .js) in my project's lib/ or utils/ folder with this initialization code: import { Execlave, AgentPausedError, PolicyBlockedError } from '@execlave/sdk'; export const ag = new Execlave({ apiKey: process.env.EXECLAVE_API_KEY!, baseUrl: process.env.EXECLAVE_BASE_URL || 'https://api.execlave.com', environment: process.env.NODE_ENV || 'development', debug: process.env.NODE_ENV !== 'production',}); // Register agent on startup (idempotent — safe to call multiple times)export async function initAgent() { return ag.registerAgent({ agentId: 'my-agent', name: 'My AI Agent', type: 'chatbot', platform: 'custom', });} // Wrap any LLM call with automatic tracingexport function traceCall<T>(fn: (input: string) => Promise<T>, agentId = 'my-agent') { return ag.wrap(fn, { agentId });} // Export error types for catch blocksexport { AgentPausedError, PolicyBlockedError }; 4. In my main application entry point (e.g. index.ts, app.ts, or server.ts), call initAgent(): import { initAgent } from './lib/execlave';await initAgent(); 5. Wrap my LLM calls with BOTH pre-execution policy enforcement AND tracing. The enforcePolicy() call is synchronous and MUST run before the LLM call — it raises PolicyBlockedError if any block-mode policy fires (e.g. prompt injection). import { ag, AgentPausedError, PolicyBlockedError } from './lib/execlave'; async function handleUserMessage(userMessage: string) { const trace = ag.startTrace({ agentId: 'my-agent' }); trace.setInput(userMessage); try { // Pre-execution policy check — MUST run before the LLM call. // Throws PolicyBlockedError if a block-mode policy is violated. await ag.enforcePolicy({ agentId: 'my-agent', input: userMessage }); const response = await myLLM.call(userMessage); trace.setOutput(response).setModel('gpt-4').finish(); return response; } catch (error) { if (error instanceof PolicyBlockedError) { trace.setOutput('[BLOCKED BY POLICY]').finish('error', error.message); // Decide what the user sees — generic refusal is safest: return 'Your input was blocked by our content policies.'; } if (error instanceof AgentPausedError) { trace.finish('error', error.message); return 'Service temporarily unavailable.'; } trace.finish('error', String(error)); throw error; }} 6. Add graceful shutdown to catch process exit: process.on('SIGTERM', async () => { await ag.shutdown(); process.exit(0);}); The SDK has zero runtime dependencies and automatically:- Buffers and batch-flushes traces in the background- Respects kill-switch (throws AgentPausedError if agent is paused)- Caches policy enforcement decisions (60s TTL)- Implements circuit breaker (3 failures → 60s backoff) IMPORTANT: tracing alone does NOT block LLM calls. Trace ingestion creates incidents post-hoc. To block requests before they reach the LLM, you MUST call ag.enforcePolicy() and handle PolicyBlockedError as shown above.Step-by-step guide
Install the SDK
Install the Execlave SDK package (zero runtime dependencies):
npm install @execlave/sdkGet your API key
Go to Dashboard → Settings → API Keys and generate a new key. Copy the key — it starts with exe_prod_ or exe_dev_.
Add it to your environment:
# .envEXECLAVE_API_KEY=exe_prod_your_key_hereInitialize the SDK
Create a shared client instance:
// lib/execlave.tsimport { Execlave } from '@execlave/sdk'; export const ag = new Execlave({ apiKey: process.env.EXECLAVE_API_KEY!, baseUrl: 'https://api.execlave.com', // your Execlave API environment: process.env.NODE_ENV || 'development',});Register your agent
Register your AI agent on startup. This is idempotent — safe to call every time your app starts.
import { ag } from './lib/execlave'; // Call once during app initializationawait ag.registerAgent({ agentId: 'my-chatbot', // unique identifier for your agent name: 'Customer Support Bot', // display name in dashboard type: 'chatbot', // chatbot | copilot | autonomous | workflow platform: 'custom', // custom | openai | anthropic | langchain});Enforce policies and trace your first LLM call
enforcePolicy() is the synchronous gate that blocks LLM calls when a block-mode policy (e.g. prompt injection) fires. It MUST run before the LLM call. Tracing alone does not block — it creates incidents post-hoc.
import { ag, AgentPausedError, PolicyBlockedError } from './lib/execlave'; async function handleMessage(userMessage: string) { const trace = ag.startTrace({ agentId: 'my-chatbot', sessionId: 'user-session-123', // optional: groups a conversation }); trace.setInput(userMessage); try { // Pre-execution policy enforcement — MUST run BEFORE the LLM call. // Throws PolicyBlockedError if a block-mode policy is violated. await ag.enforcePolicy({ agentId: 'my-chatbot', input: userMessage }); const response = await openai.chat.completions.create({ model: 'gpt-4', messages: [{ role: 'user', content: userMessage }], }); const answer = response.choices[0].message.content; trace .setOutput(answer) .setModel('gpt-4') .setTokens(response.usage?.prompt_tokens, response.usage?.completion_tokens) .setCost(0.03) .finish(); return answer; } catch (err) { if (err instanceof PolicyBlockedError) { trace.setOutput('[BLOCKED BY POLICY]').finish('error', err.message); return 'Your input was blocked by our content policies.'; } if (err instanceof AgentPausedError) { trace.finish('error', err.message); return 'Service temporarily unavailable.'; } trace.finish('error', String(err)); throw err; }}Verify in the dashboard
Open the Execlave dashboard and check:
You should see your agent registered and traces flowing in.
What's next?
Error handling
The SDK exports specific error types so you can handle governance events gracefully:
import { AgentPausedError, PolicyBlockedError } from '@execlave/sdk'; try { const result = await tracedCall('Process this order');} catch (err) { if (err instanceof AgentPausedError) { // Admin paused this agent via kill switch return 'Service temporarily unavailable.'; } if (err instanceof PolicyBlockedError) { // A blocking policy was violated return 'This request was blocked by security policy.'; } throw err; // re-throw unexpected errors}SDK configuration
| Option | Default | Description |
|---|---|---|
| apiKey | EXECLAVE_API_KEY env | Your API key (exe_prod_xxx or exe_dev_xxx) |
| baseUrl | https://api.execlave.com | Execlave API URL |
| environment | production | Deployment environment label |
| asyncMode | true | Buffer traces and flush in background |
| batchSize | 100 | Max traces per flush batch |
| flushIntervalMs | 10000 | Background flush interval (ms) |
| debug | false | Enable verbose debug logging |
| enableControlChannel | true | Poll for kill-switch status changes |
| pollIntervalMs | 15000 | Status polling interval (ms) |
| enableInjectionScan | true | Client-side scoring that tags traces with an injection score. Does NOT block LLM calls — use enforcePolicy() with a block-mode injection policy to block. |
| enforcementOnOutage | fail_open | Behavior when API is unreachable (fail_open or fail_closed) |
Key API endpoints
The SDK handles these automatically, but here they are for direct API usage:
| Endpoint | Auth | Description |
|---|---|---|
| POST /api/v1/agents | X-API-Key | Register an agent |
| POST /api/v1/traces/ingest | X-API-Key | Submit traces (up to 100 per batch) |
| POST /api/v1/policies | X-API-Key (admin) | Create a governance policy |
| POST /api/v1/policies/enforce | X-API-Key | Pre-execution policy check |
| PATCH /api/v1/agents/:id/pause | X-API-Key (admin) | Pause agent (kill switch) |
| PATCH /api/v1/agents/:id/resume | X-API-Key (admin) | Resume paused agent |
| GET /api/v1/agents/:id/status-poll | X-API-Key | Check agent status |
| POST /api/v1/agents/:id/grants | X-API-Key (admin) | Create agent-to-agent access grant |
| POST /api/v1/agents/authorize | X-API-Key | Check if agent call is authorized |
Environment variables
Your application only needs one environment variable:
EXECLAVE_API_KEY=exe_prod_your_key_hereIf you're running Execlave infrastructure locally, use these defaults:
# BackendDATABASE_URL=postgresql://postgres:postgres@localhost:5432/execlaveREDIS_URL=redis://localhost:6379PORT=4000 # FrontendNEXT_PUBLIC_API_URL=http://localhost:4000NEXT_PUBLIC_GRAPHQL_URL=http://localhost:4000/graphql # Start infrastructuredocker compose up -d # PostgreSQL + Redis + MinIOcd backend && npm run dev # API server on :4000cd frontend && npm run dev # Dashboard on :3000Self-hosted deployment
Run the full Execlave platform on your own infrastructure with a license key. Your data never leaves your network. Only a 24-hour license heartbeat (fingerprint + timestamp, no customer data) crosses the boundary.
Quickstart
curl -O https://get.execlave.com/docker-compose.ymlexport LICENSE_KEY=exe_lic_<your-key>docker compose up -dopen http://localhost:3000Get a license key
Request one at /get-license. Free tier licenses arrive within one business hour. For the complete self-hosted guide — environment variables, license semantics, backups, air-gapped mode, troubleshooting — see the self-hosted deployment guide.