Authentication
How to authenticate a request to the Tessen API, and what a key can and cannot do.
Every request except the public price list authenticates with an API key sent as a Bearer token. A key acts as your Tessen account: the models you may call, the wallet that pays, and the usage that is recorded are all your account's.
Authorization: Bearer tes_...Where a key comes from
- Console keys. Create one in the Console under Keys. The secret begins tes_, is shown exactly once, and only a hash is stored — there is no endpoint that returns it again and nobody at Tessen can read it.
- CLI credentials.
tessen auth:loginsigns a machine in with a device code you approve in your browser and receives a tes_ credential bound to your identity. OpenCode uses it; you never paste it.
Keys are created and revoked only by a signed-in person. A key cannot create or revoke keys, so a leaked key cannot mint a stronger one.
Permissions
When you create a key in the Console you choose its permissions: "Send model requests" and "Read models and usage", both ticked by default. The Gateway records them on the key as chat:write, chat:read, models:read and usage:read.
The Gateway does not currently restrict developer endpoints by these permissions. A key created with only one of them can still call every endpoint in this reference that your account may use. Treat every key as a full-access credential for your account, and protect and rotate it accordingly. Console-created keys can never create or revoke other keys.
Keep keys secret
- Read the key from an environment variable or a secret manager, as the examples do.
- Never put a key in browser code, a mobile app, a public repository or a log.
- Revoke a key in the Console the moment it may have been exposed. A revoked key answers 401 immediately.
What can fail
| Status · code | Meaning |
|---|---|
401 authentication_required | The Authorization header is missing. |
401 invalid_api_key | The key is unknown, malformed or revoked. |
| 403 | The key is valid but not permitted — for example a program the account is not enrolled in (zero_entitlement_required). |