Connect Google Gemini
Create a Gemini API key in Google AI Studio, understand free and paid tiers, connect it to SiteTrellis, test it, and fix common errors.
Last updated:
Google's Gemini models can be reached with an API key created in Google AI Studio. This is the simplest route and does not require setting up Vertex AI or service accounts. The description below reflects Google's products as of writing; they change often, so check Google's Gemini API documentation for the current state.
Create the key in AI Studio#
- Go to
aistudio.google.com/apikeyand sign in with a Google account. - Click Create API key. You are asked to choose or create a Google Cloud project; AI Studio can create one for you. Using a dedicated project for SiteTrellis keeps its usage and billing separate.
- Copy the key. Gemini keys typically start with
AIza. You can come back to AI Studio and view or delete it later, but treat it as a secret anyway.
Free and paid tiers#
Gemini offers a free tier with low rate limits, and a paid tier that requires a billing account linked to the Google Cloud project behind the key.
- The free tier is fine for trying SiteTrellis in the playground. The rate limits are low enough that a live website with several visitors will frequently see 429 errors. On the free tier, Google's terms may allow your prompts and responses to be used to improve its products, so do not use it with real customer conversations if that matters to you. Check Google's current terms.
- The paid tier gives higher limits and different data terms. In AI Studio, open your key's project and use Set up billing (or enable billing for the project in the Google Cloud Console), then wait a few minutes for the change to apply.
Set spend limits#
In the Google Cloud Console, open Billing > Budgets & alerts for the billing account and create a budget with email alerts. Note that Google budgets alert but do not by default stop spending, so also keep an eye on the usage page in AI Studio, and consider quotas under IAM & Admin > Quotas for the Generative Language API to put an actual ceiling on request volume.
Paste it into SiteTrellis#
- In the dashboard open AI providers and add a key.
- Choose Google Gemini, name it, paste the key and save.
- Check that the status turns to ok.
- In your agent's model section select the key and pick a Gemini model from the list in the dashboard.
Typical errors#
| Message or code | Meaning | Fix |
|---|---|---|
| 400 "API key not valid" | Wrong or deleted key. | Copy the key again from AI Studio and rotate it in. |
| 400 FAILED_PRECONDITION | The free tier is not available in your country, or billing must be enabled. | Enable billing for the project. |
| 403 PERMISSION_DENIED | The API is not enabled for the project, the key is restricted, or the model is not available to you. | Enable the Generative Language API, remove incompatible restrictions, or choose another model. |
| 404 | Model name not available for your key. | Choose from the dashboard list. |
| 429 RESOURCE_EXHAUSTED | Rate or quota limit, common on the free tier. | Enable billing, wait, or add a fallback step. |
| 500, 503 overloaded | Google side load or incident. | Transient. A fallback step covers it. |
Data handling#
Messages and prompts go to Google under the terms of the tier your key's project is on (free and paid are treated differently). Review Google's Gemini API terms and additional terms for the details and mention them in your privacy policy. For how SiteTrellis handles your key and chat data, see Security and privacy.
Related: AI keys overview, Troubleshooting.