ZeroLeaks SDK
Run hosted red-team scans against the exact agent, models, tools, memory, and middleware used by your application.
@zeroleaks/sdk connects the hosted ZeroLeaks attack engine to your application code. A runtime scan sends every probe through your agent while the SDK maintains conversation state and records observed tool calls and results. Model and tool credentials never have to be sent to ZeroLeaks, and the target does not need a public URL.
import { ZeroLeaks, createRuntimeTarget } from "@zeroleaks/sdk";
const zeroleaks = new ZeroLeaks();
const target = createRuntimeTarget({
definition: {
name: "Production support agent",
provider: "custom",
tools: productionToolDefinitions,
},
invoke: ({ messages, sessionId, signal }) =>
runProductionAgent({ messages, sessionId, signal }),
reset: (sessionId) => resetAgentSession(sessionId),
});
const { report } = await zeroleaks.runtimeScans.run(target);
console.log(report.overallScore, report.toolTrace);Choose a scan type
| Scan type | Best for | What ZeroLeaks exercises |
|---|---|---|
| Runtime scans | Application code, CI, staging | Your real model configuration, instructions, memory, middleware, tools, and execution loop |
| AI SDK adapter | AI SDK Agent or ToolLoopAgent | Full AI SDK tool schemas, executions, results, and multi-turn state |
| OpenAI adapter | Responses API or Chat Completions | Native OpenAI request settings and local function-tool execution |
| Endpoint scans | Already-deployed HTTP agents | Production HTTP contract, authentication, response parsing, and declared tools |
zeroleaks CLI | A system prompt before an application exists | Local prompt scanning with your own model-provider credentials (the hosted version is retired) |
| Skill scans | Agent skills and manifests | Static and behavioral analysis of repositories, URLs, or ZIP archives |
How a scan works
Runtime and endpoint scans run the same stages:
- Reconnaissance and profiling. Three short questions to the agent plus your tool definitions produce a profile of its role, tools, reachable data, and trust boundaries.
- Three attack tracks in parallel: secrets in context, prompt injection, and agent probes derived from the profile. The agent probes cover boundaries such as authorization, data access, network egress, tool use, human approval, memory, and cross-agent trust, plus multi-turn campaigns and the production probe catalog.
- Judging. A panel of judge models scores the results. An observable effect, such as a real tool call or an echoed canary, counts for more than a response that only sounds compliant.
- Report. Scores, findings, evidence, and recommendations. See reports.
A scan does not rerun exploits against a fixed version of your agent. After you apply a fix, the next scan repeats the attacks to check whether the fix holds.
Next steps
Quickstart
Install the SDK and run your first scan.
Runtime scans
Scan a custom, AI SDK, or OpenAI agent in your own process.
Endpoint scans
Scan an agent that is already deployed.
Tools and side effects
Contain tool calls during a scan.
Reports
Read scores, findings, and evidence.
CI and automation
Scan after every deploy.
API reference
Client methods, types, and errors.