Quickstart
Install the ZeroLeaks SDK, create an API key, and run a runtime scan against an existing agent.
Before you begin
You need a ZeroLeaks account with an active paid plan or trial, and Node.js 18+ or Bun 1+. The SDK ships as ESM and CommonJS and is MIT-licensed; hosted orchestration and attack intelligence remain server-side.
Create an API key
Create an API key in the dashboard settings and store it in a server-only environment variable:
ZEROLEAKS_API_KEY=zl_live_...Initialize the SDK only in trusted server, worker, test, or CI code. Never expose a zl_live_ key in browser JavaScript.
The client reads ZEROLEAKS_API_KEY by default. To pass options explicitly:
const zeroleaks = new ZeroLeaks({
apiKey: process.env.ZEROLEAKS_API_KEY,
baseUrl: "https://zeroleaks.ai",
timeoutMs: 30_000,
});Install the SDK
bun add @zeroleaks/sdk
# or
npm install @zeroleaks/sdkFor a provider adapter, add the provider's package:
bun add ai # AI SDK adapter
bun add openai # OpenAI adapterBoth are optional peer dependencies; a custom runtime target needs neither. Adapters use separate entry points, so applications that don't use them don't load their dependencies:
import { ZeroLeaks, createRuntimeTarget } from "@zeroleaks/sdk";
import { aiSdk } from "@zeroleaks/sdk/ai-sdk";
import { openAI } from "@zeroleaks/sdk/openai";Run your first scan
createRuntimeTarget() wraps any agent framework:
import { ZeroLeaks, createRuntimeTarget } from "@zeroleaks/sdk";
import { productionAgent } from "./agent";
const zeroleaks = new ZeroLeaks();
const target = createRuntimeTarget({
definition: {
name: "Support agent",
provider: "custom",
model: "production-model",
instructions: SUPPORT_INSTRUCTIONS,
tools: productionTools.map((tool) => ({
name: tool.name,
description: tool.description,
inputSchema: tool.inputSchema,
outputSchema: tool.outputSchema,
})),
},
invoke: async ({ messages, sessionId, signal }) => {
const result = await productionAgent({ messages, sessionId, signal });
return {
text: result.text,
messages: result.messages,
toolCalls: result.toolCalls,
usage: result.usage,
};
},
reset: async (sessionId) => {
await productionAgent.reset(sessionId);
},
});
const { scan, report } = await zeroleaks.runtimeScans.run(target, {
eventConcurrency: 8,
workerStallTimeoutMs: 6 * 60_000,
scan: { scanMode: "full" },
onPoll: (current) => console.log(current.currentPhase),
});
console.log(scan.status, report.overallScore);The SDK sends the serializable target and tool definitions to ZeroLeaks. Your process then claims probes and invokes the same agent function your application uses. ZeroLeaks judges the responses and returns one consolidated report.
Your model provider key, executable tool functions, and local application state remain in your environment. The SDK does send each tool call's arguments and result with the trace, so a document a tool retrieves during a scan reaches ZeroLeaks; credential-shaped values are redacted from reports. Your tools run in your process, so point them at scan-safe dependencies. See tools and side effects.
scanMode: "full" is the default. Use scanMode: "quick" for a smaller development smoke test. See scan modes.