Install and configure
Install neuraldefend 1.0.2 in the same environment as the application. The guide requires Python 3.9 or newer. Obtain a key through Neural Defend onboarding and expose it through NEURALDEFEND_API_KEY or the explicit api_key constructor option.
The production client uses the production origin. NeuroVerifyClient.staging creates a staging client. Use a credential scoped to the selected environment and do not enable a custom base URL unless the integration has a reviewed reason.
Call and read results
detect_image returns ImageResult. detect_video returns VideoResult and accepts documented frame-sampling options. Paths are streamed from a validated file handle. Byte input and unnamed streams require a filename so multipart metadata remains deterministic.
Use result.to_dict for stable normalized output. The raw property retains a sanitized immutable score envelope for explicit diagnostics, but it is not the stable application contract.
- scored is true only for a recognized successful score.
- rejected identifies a business rejection without converting it into an exception.
- ImageResult.high_risk identifies the documented high band.
- VideoResult.has_audio preserves whether an audio score is present.
Errors, retries, and lifecycle
Public exceptions derive from NeuroVerifyError and distinguish validation, authentication, scope, rate-limit, server, timeout, network, protocol, and other HTTP failures. Catch specific classes and keep request identifiers when provided.
The client applies bounded retries to documented 429, 500, and 503 responses. It does not retry timeouts or network failures. Use a context manager or call close so the underlying HTTP resources are released.
Evidence boundary
Limitations
- The verified release is 1.0.2 as of the source check date; confirm PyPI and the package changelog before pinning a new deployment.
Source record
