Short-lived tokens beat API keys for mobile apps
A provider API key is a bearer secret with no identity and no expiry. That's fine on your own server. In a mobile app it's the wrong tool: every user shares one credential, it never expires, and the only way to kill it is to rotate it and break every user at once.
What a per-user token gives you
Instead, the app exchanges a user identifier for a short-lived token (a one-hour JWT) and calls the provider through a proxy with it:
POST /api/v1/auth/simple → { access_token, expires_in: 3600 }
POST /api/v1/proxy/<app>/openai/chat/completions
Authorization: Bearer <token>
Now every request is tied to a user. That unlocks three things a static key can't do:
- Revocation without a release — disable one abusive user instantly; everyone else keeps working.
- Per-user rate limits — cap usage per person, not per key, so one user can't drain your quota.
- Per-user analytics — see cost and traffic by end user, not just one undifferentiated key total.
One honest limit: if the token endpoint accepts any caller-chosen ID, an attacker can mint tokens for fresh IDs, so per-ID limits are damage control, not verified identity. Pair them with app attestation, limits on token issuance, and an overall budget. Read more: Firebase App Check: what it actually protects (and what it doesn't).
The expiry is the point
A leaked token stops working within the hour, and the server can refuse a user sooner. A leaked key works until you notice and revoke it — and revoking it breaks every legitimate user until an app update ships. Expiry bounds what one stolen token can do; it does not replace server-side limits and budgets. Read more: Ephemeral tokens: how a mobile app should get an access token for AI APIs.
The real provider key stays server-side the whole time. See the docs for the auth flow, or start free.
Stop shipping your API key inside your app.
Swap the base URL, keep the provider's native API, and let the proxy inject your key server-side.
Start free