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 aBearer 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
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:
401 with {"detail": "Invalid email or password"}.
Refresh
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 answers401.
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:
List API keys
Update an API key
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: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
Theallowed_face_ids field restricts which faces can be used with a key. Pass face aliases (not UUIDs):
allowed_llm_models field restricts which LLM models can be used:
403 Forbidden.
Null or omitted fields allow all faces/models, appropriate for unrestricted keys.
A key limited to faces
A key withallowed_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.
403:
403:
403 to such a key:
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 answer403 to any API key,
limited or not:
- closing the account;
- linking, listing and unlinking a ChatGPT account;
- changing a plan, a card or the balance: switching, cancelling and reactivating a plan, adding, changing and removing a card, topping up, and compile overflow;
- sharing, publishing and deleting a face.
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.