Authentication and API key safety
The Direct data API accepts Authorization: Bearer $API_KEY. A full API key is displayed only after creation or rotation; the platform stores only a one-way digest and prefix.
Least privilege
- Allow only the models and capabilities required by the workload.
- Set realistic RPM, TPM, and concurrency limits.
- Restrict source IP addresses for servers with fixed egress.
- Use separate keys for development, test, and production. Never distribute a Direct key in a browser or mobile app.
Store keys in a Secret Manager or equivalent and inject them as API_KEY. Do not place keys in Git, images, sample configuration, logs, errors, or analytics. If exposure is suspected, rotate immediately and revoke the old key. For routine rotation, deploy and verify the new key before revoking the old one.
Embedded clients must not hold Direct keys or AppClient secrets. See the Embedded architecture and token exchange.