Skip to main content
Neural Defend

NeuralDefend TypeScript SDK

The official @neuraldefend/sdk package is version 1.0.3 for Node.js 22 or newer and current evergreen browsers. It provides detectImage and detectVideo, typed normalized results, local validation, cancellation, timeouts, and bounded retries. Node.js can read NEURALDEFEND_API_KEY. Browser clients require an explicit key, and the public guide says never to embed a long-lived production key in browser code. Route browser uploads through your backend unless Neural Defend has approved a browser-exposable credential for the tenant.

Maintained byNeural Defend
Updated August 7, 2026
Siva Shankar, Co-founder and CTO of Neural Defend.
Siva ShankarCo-founder & CTO
An article-specific diagram for NeuralDefend TypeScript SDK organizes key sections including select the runtime and credential path, use runtime-specific inputs, cancellation, errors, and retries.

Select the runtime and credential path

For server-side use, run Node.js 22 or newer and keep NEURALDEFEND_API_KEY in a secret manager or process environment. You can also pass apiKey explicitly. The staging factory selects the documented staging origin.

The browser build never reads environment variables. Do not ship an onboarding key in JavaScript, HTML, source maps, a mobile bundle, or static configuration. The published guide recommends an application-owned backend upload unless the tenant has an explicitly approved browser credential flow.

Use runtime-specific inputs

Node.js accepts a filesystem path, Uint8Array, Buffer, Blob, File, or readable stream under documented filename rules. Browsers accept File or Blob. A plain Blob, bytes, or unnamed stream needs an explicit filename.

Always branch on result.status. JSON.stringify emits stable normalized properties, while result.raw is a deeply frozen, redacted diagnostic payload and is not the stable application contract. Future unrecognized status or risk values resolve to an unknown result rather than silently becoming approval.

An article-specific topic map for NeuralDefend TypeScript SDK organizes key sections including use runtime-specific inputs, cancellation, errors, and retries, select the runtime and credential path.

Cancellation, errors, and retries

Pass an AbortSignal to cancel preparation, retry waits, upload, or response processing. Caller cancellation is distinct from a timeout. The error hierarchy also distinguishes validation, authentication, scope, rate limit, server, network, protocol, and other HTTP failures.

The SDK applies bounded retries to selected rate-limit and server responses. Timeouts, network failures, protocol errors, cancellation, and most other HTTP failures are not retried automatically. Avoid wrapping the SDK in an uncoordinated retry loop.

Evidence boundary

Limitations

  • No public documentation provides a universal browser credential-issuance implementation; keep uploads server-side unless Neural Defend approves a tenant-specific browser design.

Source record

Sources and references

  1. Neural DefendNeuralDefend TypeScript SDK guideVerified August 7, 2026.
  2. npm@neuraldefend/sdk 1.0.3Published July 27, 2026. Verified August 7, 2026.

Protect the credential

Review security and data handling

Define server-side key custody, authorized uploads, logging boundaries, and sanitized support data.

Open security guidance