The TypeScript SDK is published as
@lasscyber/agnes-security
on npm. It supports Node.js 20+, browsers, Deno, Bun, and Cloudflare
Workers, and is fully isomorphic (uses the standard fetch
everywhere).
5-minute quickstart
decision.allowed, decision.blockedBy, decision.reasons, and
decision.requestId are the only fields you need for most
integrations. decision.raw exposes the full server response when you
need to drill down. See
Interpreting results.
Authenticate
See Authentication for the bearer
header, sandbox keys, and Agnes-Version pinning.
Guard an LLM call
checkInput uses the inbound policy; checkOutput automatically flips
"default-inbound" → "default-outbound". Pass any other policy slug
explicitly to override.
Build policies in code
Canonical SDK names are camelCase (promptInjectionJailbreak); the
builder translates to today’s server keys (e.g.
adversarial_detection_analyzer) at build() time. See
Combined analyzer for the underlying
policy schema.
Errors
All API errors carry .status, .code, .requestId, and .raw.
Specific classes add fields (retryAfter, fieldErrors,
gracePeriodEnd).
code is the canonical Agnes error code (e.g. rate_limit_exceeded,
analyzer_unavailable, validation_error); the full reference lives
under Errors. Quote requestId when filing a
support ticket so the team can correlate the exact failure on the
server side.
Service status
Real-time API health and incident history live at
status.lasscyber.com. Subscribe via
email or Slack to receive notifications when an incident opens or
resolves; this is the right place to check before opening a ticket if
the SDK is throwing repeated ServerError or NetworkError.
Escape hatch
If the ergonomic surface does not yet cover an endpoint you need, reach
the underlying typed transport:
This is the same client the rest of the SDK builds on, so anything in
the API reference is reachable.
Sandbox mode (ak_test_* keys)
For tests and CI, mint a sandbox key. It is free, bypasses paid
upstream providers, and returns deterministic canned results keyed off
the prompt content.
See Sandbox mode for the full canned-response
matrix and how to mint ephemeral test tenants from CI.
OpenAI drop-in
The import path @lasscyber/agnes-security/integrations/openai is a
separate subpath export so callers who never use it pay zero bundle
cost.
Edge runtime support
No Node-specific APIs are imported in the default entry. Runs out of
the box in Cloudflare Workers, Vercel Edge, Deno, and the browser. The
optional OpenAI integration is side-effect free (the import only
defines a class).
Do not put an ak_* API key into a browser bundle. Treat keys as
secrets. The TypeScript SDK’s edge-runtime support is for server-side
and worker-side environments, not direct browser use.
Development
Regenerate the typed schema after API changes:
License
Apache-2.0.