Skip to main content
DOCUMENTATION

API Reference

Everything you need to integrate AgentShield into your agent pipeline.

Installation

Install the SDK via npm, or use the raw HTTP API from any language.

npm
npm install @nuketk1809/agentshield
Quick start
import { AgentShield } from "@nuketk1809/agentshield";

const shield = new AgentShield("as_live_your_api_key");

// Scan content before your agent acts on it
const result = await shield.scan("web content to check");

if (result.score < 80) {
  console.log("Blocked:", result.verdict, result.threats);
} else {
  agent.proceed();
}
Scan a URL
const result = await shield.scanUrl("https://example.com/page");
// AgentShield fetches the page and scans it for you
Quick boolean check
if (await shield.isSafe(content)) {
  agent.proceed();
}

// Custom threshold (default is 80)
if (await shield.isSafe(content, 50)) {
  // More permissive
}
Configuration
const shield = new AgentShield({
  apiKey: "as_live_...",
  baseUrl: "https://your-custom-domain.com",  // optional
  timeout: 5000,                                // optional, default 10s
});
Error handling
import { AgentShield, AgentShieldError } from "@nuketk1809/agentshield";

try {
  const result = await shield.scan(content);
} catch (err) {
  if (err instanceof AgentShieldError) {
    console.log(err.status);  // 401, 429, etc.
    console.log(err.message); // "Invalid API key"
  }
}

SDK Methods

MethodDescription
shield.scan(content)Scan text content for threats
shield.scanUrl(url)Fetch URL and scan its content
shield.isSafe(content, threshold?)Returns true if score >= threshold (default 80)
shield.isUrlSafe(url, threshold?)Returns true if URL score >= threshold

No SDK? You can also call the API directly with any HTTP client — see the tab for raw cURL examples.