Detecte/docs

Install the SDK

npm install @detecte/sdk
# or
pnpm add @detecte/sdk
# or
bun add @detecte/sdk

Initialize

import { Detecte } from "@detecte/sdk";
 
const detecte = new Detecte({
  apiKey: process.env.DETECTE_API_KEY!,
  // optional:
  baseURL: "https://api.detecte.xyz",
  timeout: 5000,
  failsafe: "fail_open",   // "fail_open" | "fail_closed" | "fail_silent"
  retries: 2,
});

Failsafe behavior

If Detecte is unreachable, the SDK falls back according to your failsafe setting:

ModeBehavior
fail_opendecision.allowed = true is returned with metadata.fallback = true. Use for non-critical agents.
fail_closeddecision.allowed = false is returned. Use for high-risk agents.
fail_silentThe error is thrown — your code decides what to do.

The default is fail_open because it preserves uptime; production fintech and crypto deployments should override to fail_closed.

Edge runtime

The SDK works on the Vercel Edge Runtime, Cloudflare Workers, Deno Deploy, and Bun. It uses only Web Fetch and crypto.subtle.

TypeScript

Strict TypeScript is the default. Every SDK method is typed end-to-end and Zod-validates responses at the boundary.