Connect to Google Gemini
Connect to Google Gemini and use their models for AI-powered apps and automations in Retool.
Google Gemini provides advanced AI models for text, image, audio, and video understanding through the Gemini API. You can create a Google Gemini resource so you can build AI-powered apps and workflows that leverage advanced multimodal processing, long context windows, and Google's AI infrastructure.
What you can do with Google Gemini in Retool
After you create a Google Gemini resource in Retool, you can:
- Generate, summarize, classify, and extract information from text using Gemini's language models.
- Build conversational, multi-turn chat experiences with context-aware responses.
- Analyze images to generate captions, extract entities, or answer questions about visual content.
- Generate images from text descriptions using Gemini's image models.
- Process long documents or large datasets using Gemini's extended context windows.
Supported models
Google Gemini resources require you to bring your own key for authentication. Retool-managed keys aren't available for Google Gemini.
The following models are available with your own API key:
| Model | Resource queries | Agent support |
|---|---|---|
| Gemini 2.0 Flash | ||
| Gemini 2.5 Flash | ||
| Gemini 2.5 Pro | ||
| Gemini 3 Flash (Preview) | ||
| Gemini 3 Pro Image | ||
| Gemini 3.1 Flash Image | ||
| Gemini 3.1 Flash-Lite (Preview) | ||
| Gemini 3.1 Pro (Preview) | ||
| Gemini 3.5 Flash | ||
| Gemini 3.6 Flash | ||
| Gemini 3.8 Flash | ||
| Gemini 4 Argon |
Specify the model ID in your queries. Refer to Google's Gemini documentation for the complete list of available model versions.
To limit which models this resource can query, refer to Restrict available models.
Before you begin
Before creating a Google Gemini resource, you need:
- Retool permissions: Ability to create and manage resources in your Retool organization.
- Google AI API key: An API key from Google AI Studio.
- Enabled Gemini API: The Gemini API enabled in your Google Cloud project.
Create a Google Gemini resource
Create a resource to connect Retool to Google Gemini and configure authentication. Once connected, you can then select it when writing queries to make use of its available models.
Follow these steps to create a Google Gemini resource in Retool.
Create a new resource
Navigate to Resources in the main navigation and click Create new > Resource and search for Google Gemini. Then, click the Google Gemini tile to create a new resource.
Configure connection settings
Specify a name for the resource that identifies it within your organization. Include a description that can provide more context to users about how to use the resource.
Configure authentication
This resource requires you to provide your own API key. Retool-managed keys are not available for Google Gemini.
Google Gemini resources require an API key and a connection mode.
Connection
Choose Direct to connect to Google's default Gemini API endpoint, or Proxy or custom endpoint to route requests through a proxy server or a custom Gemini-compatible endpoint.
Base URL
Available only when Connection is set to Proxy or custom endpoint, and required in that mode. The endpoint Retool sends requests to.
https://your-proxy.example.com
API key
Your Google AI API key from Google AI Studio. Required for both connection modes.
Retrieve your API key from Google AI Studio. If you don't have a key, click Create API key to generate one.
Headers
Available only when Connection is set to Proxy or custom endpoint. Add custom request headers, such as headers your proxy requires for authentication.
Create dedicated API keys for Retool to best manage and revoke access without disruption. All API keys used with Retool are encrypted and stored securely.
Enable Google Search grounding (optional)
Google Search grounding lets you enable Google web searches during response generation. When you turn it on, queries that use this resource can access real-time web results to improve response accuracy and relevance.
To enable Google Search grounding for a supported model, turn on Enable Google Search grounding for supported models in the Advanced options section.
Restrict available models
You can optionally limit access to one or more models provided by this resource. This can be useful for limiting access to models that have higher usage costs. Set this while creating the resource, or later by editing it.
- Click Advanced options and select the checkbox next to Restrict this resource to selected models. Allowed models shows the models available for use. All models are selected by default.
- Uncheck the box next to any models you want to disable. At least one model must be selected.
- Click Create resource or Save changes.
Once this setting is applied, users can only use a model that's enabled. If a user attempts to use a restricted model, Retool displays an error message that a restricted model is not allowed by this AI provider resource's model list.
If the resource uses a Retool-managed key, the available model list includes only models that are available when using the provided key.
Whenever you make changes to the list of available models, verify that the selected default models for Ask AI and the app builder are enabled. If not:
- Ask AI cannot be used until a different default model is selected.
- The app builder attempts to fall back to another model. If this is also unavailable, the agent cannot be used.
Save the resource
Click Create resource to save your Google Gemini resource. The resource is now available for use in apps and workflows.
AI resources do not have a Test connection button. To verify your configuration, create a new app and ask the agent to test the resource for you.
Interact with Google Gemini data
Once you've created a Google Gemini resource, you can interact with Gemini models using Retool.
Retool recommends using the app builder so you can use natural language to build React-based apps using AI.
- To use Gemini models in the app builder, reference the resource in the prompt with
@, such as@Google Gemini. Refer to the data and functions documentation to learn more. - For classic apps, workflows, and agents, refer to the AI queries documentation to learn how to write a resource query.
Best practices
Follow these best practices to keep your Google Gemini usage secure and cost-efficient.
Security
- Rotate credentials regularly: Roll your Google AI API key periodically from Google AI Studio, and immediately if a key is ever exposed.
- Create separate API keys for Retool: Use a dedicated Google AI API key for Retool so you can revoke or rotate access without disrupting other integrations.
- Use resource environments: Organizations on an Enterprise plan can configure multiple resource environments to maintain separate Google AI API keys for production, staging, and development.
Manage token usage and cost
- Choose the smallest capable model: Use a faster, cheaper model (e.g. Gemini Flash) for simple tasks like classification or extraction, and reserve Pro models for tasks that need deeper reasoning or large context windows.
- Set output token limits: Configure a maximum output token limit appropriate to the task to avoid paying for unnecessarily long responses.
- Trim conversation history: For chat use cases, truncate or summarize older messages instead of sending the full history on every request. Gemini bills for all input tokens, including message history.
- Monitor usage: Track token consumption and spend in Google AI Studio to catch unexpected usage spikes early.
Related resources
Create a resource
Learn how to create and manage resources in Retool.
Resource environments
Configure separate credentials for production and non-production environments.
AI models
Learn about Retool-managed and self-managed AI model keys.
Google Vertex AI
Connect to Gemini models within your own GCP infrastructure.
Gemini API documentation
Official Google Gemini API documentation.