Who pays
Your app never holds the person’s password or their Allternit session. It holds a token that can only do what the scopes allow, and the person can revoke it at any time.
App-driven spend never triggers auto top-up. When the person’s credits run out, calls fail with
402 user_credits_exhausted.
Register an app
- Open platform.allternit.com → OAuth apps and pick a project.
- Create the app: name, logo URL, homepage URL, privacy policy URL, and the client type.
- Add the redirect URIs your app will use (see Redirect rules).
- Copy the client id (
oapp_…). For a confidential app the console shows the client secret (alt_ocs_…) once. Only its hash is stored. Rotate secret issues a new one and shows it once. - Add test users (up to 100 email addresses).
- When you are ready for anyone to sign in, choose Submit for review. You can withdraw a submission.
An app object has
id, client_id, name, logo_url, homepage_url, privacy_url, client_type, secret_prefix, state, scopes, redirect_uris, created_at and updated_at. Creating an app, and rotating the secret, add client_secret once (null for a public app).
App states and review
Allternit reviews every app before it goes live. Until an Allternit admin approves it, your app stays in testing: only test users and the owner can link it, and nobody can set a limit above $50. A person who is not on the list gets
403 app_not_approved_for_user, both when they approve and on every call.
Only an Allternit admin moves an app from in_review to live, or to suspended.
Client types
Use confidential for a server. Use public for a browser app, a mobile app or a local tool. PKCE with
S256 is required for every client. plain is refused.
Scopes
If you leave
scope out of the authorize URL, it defaults to inference. No other Allternit scope can be reached with an app token.
Redirect rules
- At most 10 redirect URIs per app.
- The scheme is
https.httpis allowed only forlocalhost,127.0.0.1and[::1], on any port. - No custom schemes, no fragments, no user info in the URL.
- The match is exact: no wildcards, no prefixes, and the query string must match.
client_id or redirect_uri does not match, Allternit shows a 400 error page. It never redirects to an address you did not register.
The flow
1. Send the person to authorize
Other errors, after your redirect URI is trusted, come back as a redirect to
redirect_uri with error, error_description and state.
2. The consent page
Allternit shows the person your app name, logo and homepage, what each scope means in plain words, and a monthly spend limit (suggested $10, no more than $50 while your app is not live). The person taps Allow or Deny. A signed-out person signs in first and comes back to the same request. The request lives 15 minutes.3. The code
Allow sends the browser to yourredirect_uri?code=…&state=…. Deny sends error=access_denied. The code lasts 5 minutes and works once. Using it a second time revokes the tokens it issued.
4. Exchange the code
POST https://api.allternit.com/oauth2/token, form encoded.
The response is
200 with Cache-Control: no-store.
refresh_token is present only when offline_access was granted, and lasts 90 days.
5. Refresh
POST /oauth2/token with grant_type=refresh_token, refresh_token, client_id, and client_secret for confidential apps.
- Do not send
scope. Ascopeon refresh isinvalid_scope. The new token keeps the scopes of the grant. - Every refresh gives a new access token and a new refresh token. The old refresh token stops working.
- If a network retry sends the old refresh token again within 30 seconds, you get the same new pair back.
- After 30 seconds, the old token counts as stolen. Allternit revokes the whole grant and answers
400 invalid_grant. The person must approve again. - The grant must still hold
offline_access.
6. Revoke
POST /oauth2/revoke, form encoded: token, client_id, and client_secret for confidential apps. It answers 200 even for a token it does not know. Revoking a refresh token revokes the whole grant and all its access tokens. The person can also revoke from their account.
7. Userinfo
GET /oauth2/userinfo with Authorization: Bearer alt_oat_…. It needs the profile scope (403 insufficient_scope without it).
sub is an opaque id that is stable for one person in your app and different in every other app. It is not the person’s Allternit id. Do not compare it across apps.
8. Usage
GET https://api.allternit.com/api/v1/oauth/usage with an alt_oat_ token that has the usage scope.
Metadata
GET /.well-known/oauth-authorization-server lists the endpoints, S256, the two auth methods and the four scopes.
Call models
Send the access token to the chat completions endpoint.- Only
POST /v1/chat/completions, with theinferencescope. App tokens reach nothing else on the Platform API. - Models in the open lane, plan models and Copilot models are refused for apps (
403). Use the models listed for Allternit credits. - Before each call Allternit reserves the most the call could cost (your
max_tokenstimes the model price). If that would pass the monthly limit, it answers402 app_spend_cap_reachedand calls no model. If the person’s credits are too low, it answers402 user_credits_exhaustedand calls no model. After the call it settles to the real cost. Setmax_tokensso the reserve is not larger than you need. - 60 requests a minute for each grant. Past that,
429 rate_limitedwith aretry-afterheader.
Errors
OAuth endpoints use the RFC 6749 shape:{"error": "…", "error_description": "…"}. Other endpoints use {"error": {"code": "…", "message": "…"}}.
Browser apps (CORS)
/oauth2/token, /oauth2/revoke, /oauth2/userinfo and /.well-known/oauth-authorization-server answer Access-Control-Allow-Origin: *, without credentials, and read no cookies. A public app that runs in the browser can call them with PKCE. Keep tokens out of the URL and out of long-lived storage you do not control.
Example: a browser app with PKCE
Related pages
- Apps with access to your account: what people see and can change
- Authentication: project keys, and where app tokens fit
- OAuth API: the runtime’s own gizzi sign-in
- Errors