How to connect Google Gemini to Toolspoke
Let your Toolspoke agents ask Gemini for a second opinion, check whether a long prompt fits a Gemini model, read files you've uploaded to Gemini, and create embeddings. An API key from Google AI Studio, and an agent that reviews plans with it.
Checked against Google Gemini's documentation on 2026-11-25.
Sometimes an agent's work is better with a second model's view: a review of a plan, a structured answer that matches a schema, or a Gemini model's read of an image or a video you've already uploaded. Toolspoke's Google Gemini toolkit calls the Gemini API with a key you create in Google AI Studio. Once it's installed, any agent in the project can use it, decide when to ask Gemini, and work with the answer in the same thread. This guide sets it up, then builds an agent that gets Gemini's review of a plan.
Setup takes about five minutes.
What an agent can do once it's connected
The toolkit has 9 named actions. Eight of them only read:
- Pick a model:
list_modelslists the Gemini models your key can call, with each model's input and output token limits and the methods it supports.get_modelreads one. The toolkit doesn't hard-code model names, because Google's lineup changes often, so an agent checks here first. - Check a prompt fits:
count_tokenscounts the input tokens a prompt would use against a model, without generating anything. Compare that with the model's input limit fromget_modelbefore sending a very long document. - Embeddings:
embed_contentturns one piece of text into a vector.batch_embed_contentsdoes many in one request, which counts as one request against Gemini's rate limits. - Uploaded files:
list_fileslists files in your key's Gemini Files API storage, with the URI a prompt uses to refer to each one.get_filereads one file's record, including its state. A freshly uploaded video staysPROCESSINGuntil it's ready.
Two actions change things:
| Action | What it does | Kind |
|---|---|---|
generate_content | Sends a prompt to a Gemini model and returns its answer. This is the call Google bills | Write |
delete_file | Deletes an uploaded file. There's no trash and no undo | Destructive |
generate_content is where the useful work happens. It takes Gemini's own conversation format, so it can carry:
- Text, for a second opinion or a rewrite.
- Inline data, such as a base64 image the agent includes in the prompt.
- A reference to an uploaded file, using the URI from
list_files. That's how Gemini reads a video, an audio file or a PDF. - A JSON schema the answer must match.
- Tools, such as Google Search grounding.
There's one gap to know about: the toolkit can't upload files. It only lists and uses files that were uploaded some other way, for example with Google's SDK. Gemini also deletes uploaded files by itself after 48 hours.
Streaming isn't offered. Each answer comes back whole.
What you need
- A Google account that can sign in to Google AI Studio.
- A Google Cloud project for the key. Every Gemini API key belongs to one. New AI Studio users get a default project and key automatically. If you already use Google Cloud, you import a project instead (step 1).
- A Toolspoke workspace, and a project to install the toolkit in.
Step 1: Pick the project the key belongs to
Rate limits apply per project, not per key, and billing belongs to the project. So the project matters more than the key.
- New to AI Studio: after you accept the terms, AI Studio creates a default project and key. You can rename the project in the Projects view.
- Already on Google Cloud: AI Studio doesn't create a default project for you. Open Dashboard in the left panel, choose Projects, then Import projects, pick the project and choose Import.
- Dashboard
- Projects
- Import projects
Google notes that imported projects, and projects created outside AI Studio, may need verification before they can use the free tier.
Step 2: Create an API key
- Open the API Keys page in AI Studio. For an imported project, Google says to create the key from that page so it lands in that project.
- Choose Create API key.
- Copy the key.
- Dashboard
- API Keys
Keys created in AI Studio are restricted to the Gemini API by default. If you're reusing an older key marked Unrestricted, choose Add restrictions → Restrict to Gemini API only, then Restrict key. Google's API now rejects unrestricted standard keys.
If Create API key is greyed out, you probably lack permission on that project. Google says you need Project Editor or a similar role, or a new project that isn't tied to an organization.
Step 3: Decide between the free tier and billing
Google documents two tiers:
- Free tier. Input and output tokens are free, but only some models are available. Google says content sent on the free tier is used to improve its products.
- Paid tier. Set up billing in AI Studio. You get higher rate limits and Google's most advanced models, and your content isn't used to improve Google's products. Usage is billed for every token a model processes, including reasoning tokens.
On every tier, Gemini limits requests per minute, input tokens per minute and requests per day. Hitting any one of them returns a rate-limit error. Daily request quotas reset at midnight Pacific time. If you share the project with other apps, your agents' calls count against the same limits.
Step 4: Install the Gemini toolkit in Toolspoke
- In Toolspoke, open the project your agents work in. Find Google Gemini in the marketplace and add it.
- Paste the API key from step 2.
list_models answered. The credential works.
Toolspoke checks the connection with list_models, which generates nothing. The key goes to Gemini in a request header, not in the URL. It's encrypted at rest, attached to each request by the gateway, and the agent never sees it. It never appears in the arguments an agent sends or in the audit log.
Step 5: Decide what agents may change
In the project's toolkit settings, Gemini's actions are grouped as read, write and destructive. Each one can be switched on or off for everyone in the project. An action that's switched off can't be called, whatever the prompt says.
A sensible start: leave the eight reads and generate_content on, and switch off delete_file. Files expire after 48 hours anyway, so deleting early is rarely needed.
Google Gemini actions in your project
Agents can call 8 of 9, and 1 of those can change something.
list_modelsList the Gemini models this API key can call, each with its id, display name, description, input and output token limits, and the list of methods it supports — generateContent, countTokens, embedContent and so on.get_modelRead one model by id: display name, description, input and output token limits, default sampling settings, and which generation methods it supports.count_tokensCount how many input tokens a prompt would use against a given model, without generating anything and without being billed.embed_contentTurn one piece of text into an embedding vector, for similarity search, clustering or retrieval.batch_embed_contentsEmbed several strings in one request, returning one vector per string in the order given.list_filesList the files uploaded to this API key's Gemini File API storage: each one's name, display name, MIME type, size, state, expiry, and the `uri` that a generate_content part refers to as {"fileData":{"mimeType":…,"fileUri":…}}.get_fileRead one uploaded file's record: display name, MIME type, size, expiry, and its `state`.
generate_contentGenerate a response from a Gemini model.
delete_fileDelete one uploaded file from the Gemini File API.
Every call is recorded with the agent and person behind it, the status and the duration. Toolspoke keeps the prompt and Gemini's answer out of the log.
Step 6: Build an agent that uses it
In Toolspoke, create an agent and describe its job in one sentence. The builder proposes the instructions, the toolkits it needs, a schedule and where it should answer. You add or skip each one, then create the agent. Every piece stays editable afterwards.
The agent replies in the thread it was asked in, and it can also be emailed. Every review it asks for is a generate_content call, which Google bills, so the audit log shows exactly how often it ran.
Try it
Ask the agent the way you'd ask a colleague for a second look:
- Ask Gemini to review this migration plan and list anything it would do differently. Then tell me where you two disagree.
- Which Gemini models can my key call, and which has the largest input token limit?
- Count how many tokens this 300-page spec would use on that model before you send it.
- List the files in my Gemini storage. Once the demo video is ACTIVE, ask Gemini to summarise it with timestamps.
- Have Gemini extract the invoice number, date and total from this text as JSON matching this schema.
The Google Gemini toolkit page lists every action.
Troubleshooting
Every call fails with an API key error.
The key may have been copied wrong, or it's an old standard key with no restrictions, which Google's API now rejects. In AI Studio, find the key's Unrestricted label and choose Add restrictions → Restrict to Gemini API only, or create a new key.
404 on a model.
Your key can't reach that model id, or the id has a models/ prefix. Ask the agent to call list_models and use the bare id.
429 errors.
You hit a per-minute or per-day limit, and limits are shared across the project. Wait, set up billing for a higher tier, or batch embeddings with batch_embed_contents.
generatecontent fails on a file.
The file is still PROCESSING (check with get_file), or it's more than 48 hours old and gone.
Questions
Can an agent upload a file to Gemini?
Not through this toolkit. It lists and uses files already in your Gemini storage.
Does the agent see my Gemini key?
No. The gateway attaches it to the request. The agent never sees it, and it's masked in the audit log.
Can I use a Vertex AI project instead?
This toolkit calls the Gemini API at generativelanguage.googleapis.com with an AI Studio key. It doesn't use Vertex AI endpoints.