Skip to main content

Connect to Google Gemini

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.
  • 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:

ModelResource queriesAgent supportAssist 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

Specify the model ID in your queries. Refer to Google's Gemini documentation for the complete list of available model versions.

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 and Assist about how to use the resource.

Configure authentication

Bring your own key only

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.

Example
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 separate API keys for Retool

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.

Save the resource

Click Create resource to save your Google Gemini resource. The resource is now available for use in apps and workflows.

Note

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.

Switch to the new app builder

Retool recommends using the new 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.