Skip to main content

Authentication

The Faces API accepts two authentication methods: JWT tokens (issued at login, and the only credential that can manage API keys) and API keys (for long-lived application access). Both are passed as a Bearer token in the Authorization header.

JWT tokens

JWTs are issued by /auth/register-email and /auth/login. They expire 30 days after they are issued; refresh one before then, or log in again.

Register

The password needs 8 to 64 characters, with at least one uppercase letter, one lowercase letter and one digit. The response has the same shape as login’s below, plus activation_required and activation_checkout_url: a new account starts with a $0 balance, and that URL adds its first credit. See the Quickstart.

Login

email also accepts your username. Response:
A wrong email or password answers 401 with {"detail": "Invalid email or password"}.

Refresh

Returns a fresh JWT, in the same shape as login, without requiring re-login. The JWT you send must still be valid: an expired one answers 401, and you must log in again.

Who am I

data holds user_id, username, email and name. Your own face is always me.

API keys

API keys are the recommended method for production applications. They support optional budget caps, expiration, and restrictions on which faces and models can be used. Managing keys (creating, listing, updating and revoking them) needs a JWT. An API key sent to these routes answers 401.

Create an API key

A value outside any of those ranges, or a field not in the table, is refused with a 422 naming it:
The response includes the full API key once; it cannot be retrieved again:

List API keys

Update an API key

Takes name, budget_usd, reset_spent, allowed_face_ids, allowed_llm_models, and the three clear_* flags. Nothing else: a field this route does not act on is refused with a 422 naming it, rather than accepted and ignored.
A key’s expiry is fixed when the key is made. There is no way to change it. To change when a key expires, revoke it and create a new one.

Revoke an API key


Budget caps

When a budget cap is set on an API key, every paid request checks the remaining budget before proceeding. Once the key has spent its cap, the API returns:
Raise budget_usd, or send "reset_spent": true, with Update an API key. The account’s own balance is checked too. When it is empty or frozen, any key gets a 402 naming the balance rather than the key, such as "Insufficient credit balance. Please top up your account to make requests." Top up credits via the billing API or the dashboard.

Face and model restrictions

The allowed_face_ids field restricts which faces can be used with a key. Pass face aliases (not UUIDs):
The allowed_llm_models field restricts which LLM models can be used:
Requests using a model not in the allowed list are rejected with 403 Forbidden. Null or omitted fields allow all faces/models, appropriate for unrestricted keys.

A key limited to faces

A key with allowed_face_ids can do two things, both only for the faces it lists:
  • ask them: choices, chat, states and decisions;
  • read them: GET /v1/faces/{alias} and its avatars.
Each request must name one of its faces. One that names no face answers 403:
One that names a face the key does not list answers 403:
Every other route, listing faces included, answers 403 to such a key:
A key without allowed_face_ids keeps its owner’s access to everything else.

What needs a signed-in session

Some routes change the account itself. They take a JWT, and answer 403 to any API key, limited or not:

Error codes

The /auth/* routes answer bad or missing credentials the same way, with 401 and WWW-Authenticate: Bearer. A wrong current password on PATCH /auth/me or /auth/change-password is 403. A key belonging to someone else answers 404, not 403, and so does a key id that is not a UUID. Neither tells you whether the key exists. See Errors for the codes the rest of the API uses, which of them are worth retrying, and the reference code to quote when you report a failure.