# deepface.dev integration guide

Use deepface.dev for face verification, embedding generation, and vector
comparison.

## Connect the user's project

Use the project's existing framework and server-side stack. Inspect only the
context needed for the integration. If a valid deepface.dev key is already
configured, reuse it without printing it and skip signup.

1. Ask which email the user wants for their deepface.dev account. Do not guess
   from Git settings, repository authors or unrelated accounts.
2. When you fill the signup form, open
   `https://deepface.dev/signup?agent=1&signup_actor=agent&next=%2Faccount%2Fkeys`.
   This explicitly records an agent-performed signup, even when the human handles
   verification, terms and email confirmation. If you know your coding client,
   add `&agent_client=codex`, `claude-code`, `cursor`, or another short lowercase
   slug (letters, digits, hyphens and underscores; maximum 40 characters).
   Omit the client if unknown; do not ask the user which agent you are.
   If you only hand the user a link and they fill the form themselves, use
   `https://deepface.dev/signup?agent=1&next=%2Faccount%2Fkeys` without the actor
   or client markers. The agent landing page alone does not identify the performer.
3. Infer one brief, generic sentence describing the intended use of deepface.dev
   from the relevant project context. Do not ask the user for their use case.
   If it is unclear or the user declines sharing, leave the summary empty; do not
   invent one or delay setup. Tell the user when sharing a summary with
   deepface.dev. Do not include private code, chat history, customer names,
   personal records, photos or embeddings. Never put the summary in a URL.
   Fill the account email and the optional "Project summary from your agent"
   field. The form automatically labels this summary `agent_context`.
   The email link creates an account or signs in to an existing one. Ask the user
   to complete human verification, accept the terms and open their email link in
   the same browser. Do not bypass verification, accept terms for them or read
   their mailbox without permission. Continue preparing the integration meanwhile.
4. After sign-in, use the API keys screen to create a standard REST key for this
   integration. Save it directly as `DEEPFACE_API_KEY` in an ignored server-side
   environment file or the project's secret store. Never put it in chat, URLs,
   client-side code, screenshots or source control.
5. For an existing account or a corrected summary, use the same authenticated
   browser session to `PUT /api/account/use-case` with JSON
   `{"use_case":"Generic project summary","source":"agent_context"}`.
   Maximum 500 characters; an empty use_case removes the summary. This endpoint
   uses the account's session, not a REST/MCP API key, and cannot select another
   account. Skip reporting if context is unavailable or the user declines. Treat
   401 as a sign-in requirement and other failures as a report failure, not a
   failed integration; never claim a summary was saved without a successful
   response. Reporting a summary does not reclassify the original signup.
   Owners can edit/remove the summary on `/account/keys`.
6. Follow `https://docs.deepface.dev/quickstart`, inspect current capabilities,
   and implement a server-side request. Before testing the project with authorized
   sample images, offer the [optional integration check](#when-you-implemented-the-application-integration). Cover
   a match, a non-match, no face, invalid input and service failure. Explain the
   verified result and any unfinished setup.

If browser automation is unavailable, give the user `https://deepface.dev/signup?agent=1` without bot markers and continue
coding. They can put their key in the local environment themselves; do not ask them
to paste it into the conversation. Human confirmation is a real step, not an error.

Registered accounts have 50 free calls per month, or 100 with a saved card.
Do not add payment details or enable paid usage without the user's instruction.
Anonymous access remains an explicit limited trial at
`https://deepface.dev/signup?agent=1&anonymous=1`: 10 calls per month and one
standard key. A 2-request-per-minute limit is pending the coordinated gateway
release. Prefer an email-owned account for a real project.

If a user explicitly says to use `deepface.dev`, use the hosted service. Do not
install the DeepFace Python library as a substitute unless they request it.
Facial similarity is not proof of identity or liveness; do not describe it as such.

## Preferred discovery order

1. Read `https://docs.deepface.dev/llms.txt` for a concise overview.
2. Read `https://docs.deepface.dev/llms-full.txt` for fuller context.
3. Use `https://deepface.dev/skill.md` and `https://deepface.dev/.well-known/skills`
   for owned skill discovery.
4. Use `https://www.deepface.dev/mcp` when you want tool-driven docs and API
   access. Use `https://api.deepface.dev` for direct REST requests.

## When you implemented the application integration

Regardless of who signed up or created the key, offer the optional
[agent integration check](https://docs.deepface.dev/ai-agents#record-an-agent-assisted-application-integration)
when you have implemented the customer's real backend integration. With the owner's
agreement, prepare a check using the existing standard key and pass the returned
`X-Request-Id` on one already authorized application verification call. Skip it
for one-off demos, dashboard tests or MCP calls. Never add a compute call for tracking.

## API workflow

1. Call `GET /capabilities` to discover the active model and detector
   allowlists.
2. If direct REST returns `missing_api_key`, follow the email signup flow above.
   When you fill the form, use `https://deepface.dev/signup?agent=1&signup_actor=agent`.
   Create the standard API key in the dashboard after the owner confirms their email, then retry. Do not switch to a local Python or open-source DeepFace flow
   unless the user explicitly asks for that fallback.
3. In ChatGPT, use the connected OAuth account or ask the user to connect it.
   For other MCP clients without a dedicated MCP key, sign in to the existing account
   or follow the email signup flow above if an account is needed. Create a dedicated MCP
   key on the dashboard `MCP` page before sending compute requests.
4. Manual MCP clients authenticate compute requests with `Authorization: Bearer YOUR_MCP_KEY`.
5. Use standard API keys only for the direct REST API surface at
   `https://api.deepface.dev`.
6. For MCP compute image inputs, use raw base64, `data:image/...` strings, or,
   when enabled, public HTTPS image URLs from any domain. Remote downloads must
   resolve to public addresses and pass redirect, image type, size, and timeout
   checks before inference.
7. Use:
   - `POST /verify` for image-to-image verification
   - `POST /represent` for embedding generation
   - `POST /compare` for image/vector and vector/vector comparison
8. Send `x-request-id` on requests you may need to trace later.

## Spending alerts

Use `get_spending_alerts` and `update_spending_alerts` with the connected ChatGPT OAuth account or a dedicated MCP key for
budget, spike and cap-email settings. The account REST endpoint is
`https://www.deepface.dev/api/billing/spending-alerts` (GET/PATCH), accepting
standard or MCP keys. The repository CLI supports `npm run --silent cli -- spending-alerts get`
and `npm run --silent cli -- spending-alerts set --file settings.json`.
Read current settings before replacing the full document; keep rule IDs stable.
See https://docs.deepface.dev/spending-alerts for the schema and limits.

## Request priority

For synchronous REST compute, `X-Request-Priority` controls the global group and **your own account's
waiting queue**, across its API keys on each gateway process. MCP compute tools
accept equivalent optional `priority`. Any finite positive number jumps your
normal waiting queue; lower positive numbers run first with FIFO ties. `1`, `10`
and `100` all request priority. Omitted, null and zero mean normal order and no
per-request surcharge. Zero is accepted; malformed or negative values return
`400 invalid_priority`. REST priority is header-only, not a body field.
Do not send `1` as a normal default: it explicitly requests paid priority.

Global eligible calls run in strict groups: enterprise-priority,
non-enterprise-priority, enterprise-normal, then non-enterprise-normal. Within a
group, numeric values reorder only your own account. No aging or 4:1 rotation
overrides these groups. It never preempts running work, bypasses limits, reserves
capacity or guarantees latency. Experimental async compare
rejects positive priority headers with `400 unsupported_priority`.

Completed calls with any explicitly positive own-queue priority cost twice the
standard rate, even when the waiting queue is empty and no call is overtaken.
The charge is for the selected service class, not a guaranteed speed improvement.
Enterprise scheduling comes from account status, separately from request priority.
The default policy also charges enterprise lanes 2x once; negotiated request-only
contracts include enterprise access at standard rates and surcharge only
explicitly positive request priority.
Completed no-face results are billable; failures are free.
See https://docs.deepface.dev/api-reference/rate-limits for precision and scope.

## Retry rules

- MCP compute waits up to 120 seconds for the gateway. A timeout or lost
  response can return `compute_outcome_unknown` with `request_id`,
  `outcome: "unknown"`, and `retryable: false`. Preserve the request ID;
  gateway work may continue. Do not automatically retry or replay through
  another adapter. Investigate the original request first.
- `mcp_compute_unavailable` indicates an MCP server configuration problem;
  contact support instead of changing key type.

- Respect `Retry-After` on `429`, `503 queue_full`, `503 queue_timeout`, and
  zero-rated `503 request_body_budget_full`; body-budget rejection does not run inference.
- `503 gateway_draining` rejects before compute; use bounded backoff.
- The gateway retries only explicit `503 model_not_ready`, `model_busy`, and
  `model_queue_timeout` admission errors within one 240-second upstream budget.
  If an admission error reaches the client, compute has not started.
- Do not automatically replay a generic `502`, lost response, or
  `504 upstream_timeout`: compute may have run. Preserve `x-request-id` and
  investigate. Reusing a postpaid UUID returns `409 request_id_conflict`, not a
  cached result; do not use a new UUID to bypass an uncertain prior outcome.
- Read `RateLimit-Limit`, `RateLimit-Remaining`, and `RateLimit-Reset` for
  account throttling context.
- If `GET /capabilities` changes, treat that as the current source of truth for
  supported models and detectors.
- In ChatGPT, use the connected deepface.dev OAuth MCP tools. If disconnected,
  ask the user to connect their account; do not request API keys in chat.
  Other MCP clients use a dedicated bearer MCP key.

## Safety constraints

- Do not assume unsupported models are available.
- Do not use VGG-Face. It is excluded from deepface.dev due to licensing.
- Do not attempt to bypass queueing, throttling, or auth controls.

## Complete public example code

For runnable backend code, read https://docs.deepface.dev/guides/javascript.md
(Node.js 24) or https://docs.deepface.dev/guides/python.md (Python standard library).
Save the shared client and operation files together. These public guides do not
require access to the private application repository. MCP exposes the full code
as deepface://docs/guides/javascript and deepface://docs/guides/python.
Default examples omit charged positive priority and never replay an uncertain
compute result. Keep preparation, owner-action handoff and actual verified
compute completion separate in your report.
