Skip to Content
ZeroLeaksDocs
ZeroLeaks SDK

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 typeBest forWhat ZeroLeaks exercises
Runtime scansApplication code, CI, stagingYour real model configuration, instructions, memory, middleware, tools, and execution loop
AI SDK adapterAI SDK Agent or ToolLoopAgentFull AI SDK tool schemas, executions, results, and multi-turn state
OpenAI adapterResponses API or Chat CompletionsNative OpenAI request settings and local function-tool execution
Endpoint scansAlready-deployed HTTP agentsProduction HTTP contract, authentication, response parsing, and declared tools
zeroleaks CLIA system prompt before an application existsLocal prompt scanning with your own model-provider credentials (the hosted version is retired)
Skill scansAgent skills and manifestsStatic and behavioral analysis of repositories, URLs, or ZIP archives

How a scan works

Runtime and endpoint scans run the same stages:

  1. 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.
  2. 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.
  3. 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.
  4. 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

On this page