Official Python SDK for the NeuroVerify Detection API
Project description
NeuralDefend Python SDK
Typed Python 3.9+ client for the NeuroVerify image and video authenticity API.
Install
pip install neuraldefend
Set NEURALDEFEND_API_KEY, then use the synchronous client:
import json
from neuraldefend import NeuroVerifyClient
with NeuroVerifyClient() as client:
result = client.detect_image("selfie.jpg")
print(json.dumps(result.to_dict(), indent=2))
if result.scored:
print(result.risk_level, result.risk_score)
elif result.rejected:
print("Could not score:", result.message)
Business rejections are normal results, including HTTP 400 validation rejections. Use
status and risk_level for decisions. Do not infer authenticity from HTTP 200 or define
business rules from numeric score thresholds. billable is authoritative for the
transaction; a face-policy rejection can still be billable.
result.to_dict() returns only stable normalized fields and derived convenience flags as
JSON-serializable data. The sanitized immutable wire payload remains available separately
as result.raw for explicit diagnostics and is never serialized automatically. Raw
diagnostics are unstable and may contain filenames or future personal/customer fields;
do not log or persist them without appropriate access and retention controls.
Video analysis returns independent modalities:
with NeuroVerifyClient() as client:
result = client.detect_video("clip.mp4", max_frames=24)
print(result.video_risk_level, result.audio_risk_level)
print(result.overall_risk_score) # client-side convenience, not an API field
Paths, bytes, and binary file-like objects are accepted. filename= is required for
bytes and nameless streams so the SDK can send deterministic media metadata. Caller-owned
streams are never closed. Seekable
streams are rewound to the beginning for safe retries; non-seekable streams require
max_retries=0.
Supported image extensions are .jpg, .jpeg, .png, .bmp, .tif, .tiff,
.webp, .heic, and .heif (10 MiB maximum). Supported video extensions are .mp4,
.avi, .mov, .mkv, .wmv, .flv, .webm, .ogg, and .ogv
(1,500,000,000-byte maximum). Known extensions use deterministic MIME types; unknown
extensions are warned about and sent as application/octet-stream.
Configuration
Explicit arguments take precedence over environment variables:
api_keythenNEURALDEFEND_API_KEYbase_urlthenNEURALDEFEND_BASE_URLthen productionallow_custom_base_url=Falsetimeout=120max_retries=3
NeuroVerifyClient.staging() always selects staging, regardless of
NEURALDEFEND_BASE_URL. Production and staging use TLS. A non-TLS URL is accepted only
when an injected transport is supplied for isolated tests. Non-Neural Defend origins are
rejected by default. If a trusted private deployment requires one, set
allow_custom_base_url=True explicitly; that origin receives the API key and uploaded
media. Redirects are never followed.
Only HTTP 429, 500, and 503 are retried. Network errors, timeouts, and other HTTP statuses
are not retried because request billability may be ambiguous. max_retries=3 means up to
four total HTTP attempts. Every accepted attempt receives a new transaction ID and may
have separate billing implications.
Upload media only with the data owner's authorization and an appropriate legal basis. Media can contain biometric personal data; apply your organization's retention, deletion, residency, logging, and access-control requirements.
Errors
All SDK exceptions derive from NeuroVerifyError:
ValidationErrorfor local validationAuthenticationErrorfor HTTP 401ScopeErrorfor HTTP 403RateLimitErrorfor final HTTP 429ServerErrorfor server error envelopes and final HTTP 500/503TimeoutErrorandNetworkErrorfor transport failuresProtocolErrorfor malformed API responsesHttpErrorfor unclassified HTTP responses
Errors carry status_code, detail, and request_id when available. Rate-limit errors
also carry the documented rate-limit header values.
Architecture decision note
OpenAPI Generator 7.14.0 buffers multipart files in memory in its Python transport. That
is unsafe for the API's large video limit. The package therefore ships the generated
_core privately for contract tracking but deliberately does not use it at runtime.
The stable facade uses a hand-written httpx multipart transport so paths and streams
remain streaming. Responses are decoded from raw JSON rather than generated models so
additive fields and future enum values do not break installed clients.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neuraldefend-1.0.0.tar.gz.
File metadata
- Download URL: neuraldefend-1.0.0.tar.gz
- Upload date:
- Size: 40.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19f32fab44459a200cb634bfc776884aaca0970cbe6d2a1da340e3849311d83b
|
|
| MD5 |
6ac8d4cd0f242c5884128f215c95004c
|
|
| BLAKE2b-256 |
d4c57bbf35547aa3db5861ad02d58f2cdba844ddacffbc896d37b67243c99bf4
|
Provenance
The following attestation bundles were made for neuraldefend-1.0.0.tar.gz:
Publisher:
release-python.yml on Neural-Defend/NeuralDefend-SDKs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
neuraldefend-1.0.0.tar.gz -
Subject digest:
19f32fab44459a200cb634bfc776884aaca0970cbe6d2a1da340e3849311d83b - Sigstore transparency entry: 2256516931
- Sigstore integration time:
-
Permalink:
Neural-Defend/NeuralDefend-SDKs@851dfcbecba45cfca3ce79efa5a4d851de45b76d -
Branch / Tag:
refs/tags/python-v1.0.0 - Owner: https://github.com/Neural-Defend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@851dfcbecba45cfca3ce79efa5a4d851de45b76d -
Trigger Event:
push
-
Statement type:
File details
Details for the file neuraldefend-1.0.0-py3-none-any.whl.
File metadata
- Download URL: neuraldefend-1.0.0-py3-none-any.whl
- Upload date:
- Size: 52.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c403843a0b8d0d536c27948c29596ce92d372a8de3da79fc05398cf11c9c345
|
|
| MD5 |
8e40402f0d4c468542c42dba274b6dbf
|
|
| BLAKE2b-256 |
2efe4cd9362b4ee1750457b41489f4a8a98f901c556504a769ac45dfb71e457e
|
Provenance
The following attestation bundles were made for neuraldefend-1.0.0-py3-none-any.whl:
Publisher:
release-python.yml on Neural-Defend/NeuralDefend-SDKs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
neuraldefend-1.0.0-py3-none-any.whl -
Subject digest:
8c403843a0b8d0d536c27948c29596ce92d372a8de3da79fc05398cf11c9c345 - Sigstore transparency entry: 2256516938
- Sigstore integration time:
-
Permalink:
Neural-Defend/NeuralDefend-SDKs@851dfcbecba45cfca3ce79efa5a4d851de45b76d -
Branch / Tag:
refs/tags/python-v1.0.0 - Owner: https://github.com/Neural-Defend
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@851dfcbecba45cfca3ce79efa5a4d851de45b76d -
Trigger Event:
push
-
Statement type: