Python API examples
Use Python 3.10 or newer (standard library only) in your backend. Save the four files below together. No private repository access, Python model installation, or extra client package is required.Before sending a request
Use only images and embeddings you are authorized to process. ConfigureDEEPFACE_API_KEY through your secret manager or a server-side environment,
never in browser/mobile code, chat, a command argument, or a URL.
If no credential is configured, these examples stop before network access.
Follow authentication for the existing owner-confirmed setup;
prepare code while the owner verifies their email. Use a standard REST key here,
not a dedicated MCP key.
Each command checks public capabilities and uses the current default model.
Set DEEPFACE_MODEL only for an allowed model with reviewed commercial rights.
DEEPFACE_API_BASE_URL defaults to https://api.deepface.dev; HTTPS is required
except HTTP loopback for local tests. Redirects are rejected.
Run the examples
source_vector and either
target_vector or target_vectors, with optional distance_metric and
threshold. Use embeddings from the same model and preprocessing pipeline;
matching dimensions alone are insufficient. Choose and evaluate a threshold
for your own permitted inputs rather than treating any nearest vector as identity.
The model is selected from capabilities (or DEEPFACE_MODEL), not inferred
from the vector file.
The embedding export contains the complete representation result. Protect it
as sensitive data, keep it out of version control, and delete it when no longer
needed. It is created with owner-only permissions and refuses overwrites.
The ordinary console summary contains no embeddings or submitted images.
Outcomes and costs
Commands return a nonzero exit status for failed, no-face, pending, malformed or unknown outcomes. A non-match is a completed verification, not a transport error. Without a comparison threshold, the summary reportsmatch_evaluation: not_requested
and omits the match count.
No-face detections can be billable even when returned as HTTP 422; inspect
errors and pricing. A saved
example or successful fixture is not an accuracy claim for your users.
These examples send at most one compute request per command. They do not retry
a 429, 503, timeout or lost response automatically. A transport/parse failure
reports compute_outcome_unknown, its request ID and retryable: false.
Computation may have completed; investigate before another attempt. Reusing a
request ID is not a result-retrieval or idempotency guarantee.
If a local export fails after a completed result, do not rerun inference
to repeat the export.
Default examples omit X-Request-Priority: positive priority can increase
completed-call pricing. Change priority or enable paid use only with the
owner’s authority. Review limits and retry semantics
and production outcomes, cost and retries
before adding production concurrency, retry or billing behavior.