Use the Google Gemini API from your app without shipping the key
Guide · Full API reference
Shipping a provider key inside a mobile or frontend app means anyone can extract it
from the binary. MyAppToken is a reverse proxy that keeps your Google Gemini key
server-side: your app swaps the base URL, authenticates users with a short-lived JWT,
and the proxy injects the key on the way to the provider. Works with generateContent across Gemini models, including multimodal image input. streamGenerateContent streams token-by-token when called with ?alt=sse; without it Gemini's JSON-array format arrives buffered.
1. Point a service at Google Gemini
In the dashboard, create an app and add a service:
gemini → https://generativelanguage.googleapis.com/v1beta
Paste your Google Gemini key into the service's token vault — it is stored encrypted, masked from then on, and rotatable without an app release.
2. Get a per-user JWT
JWT=$(curl -s -X POST https://api.myapptoken.com/api/v1/auth/simple \
-H 'Content-Type: application/json' \
-d '{"app_id": "<app-id>", "user_id": "user-123"}' | jq -r .access_token)
3. Call Google Gemini through the proxy
Auth injection: Gemini's x-goog-api-key header scheme is built in — the proxy strips your app's JWT and injects the Google AI key server-side.
curl https://api.myapptoken.com/api/v1/proxy/<app-id>/gemini/models/gemini-2.5-flash:generateContent \
-H "Authorization: Bearer $JWT" \
-H 'Content-Type: application/json' \
-d '{"contents": [{"parts": [{"text": "Hello"}]}]}'
In app code the whole change is the base URL and the credential:
// Swift — before let baseURL = "https://generativelanguage.googleapis.com/v1beta" let apiKey = "<provider key shipped in the app>" // after let baseURL = "https://api.myapptoken.com/api/v1/proxy/<app-id>/gemini" let apiKey = sessionJWT // from /auth/simple, expires in 1 h
What you get on top
- Per-user rate limits with rolling windows and automatic cooldowns — a 429 with retry time past the limit.
- Per-user analytics: requests, traffic, latency and status per end user, not just per key.
- Abuse response: disable one user in a click; enable Firebase App Check so only genuine builds of your app can call the proxy.
- Key rotation and failover between multiple keys, no app update.
Start free — no credit card; the Free plan covers 10,000 requests a month. Full details in the docs.