Connect Google Gemini to Claude Code

Generate content with Gemini models, count tokens, and create embeddings. Add Toolspoke to Claude Code once and it can use 9 Google Gemini actions. Your Google Gemini credential stays in Toolspoke, and you choose which actions Claude Code may call.

Set it up in Claude Code

Three steps, the first one once for every toolkit you will ever add.

  1. Add Toolspoke to Claude Code

    Run it in your project, then /mcp to sign in

    claude mcp add --transport http toolspoke https://toolspoke.com/mcp

    The sign-in opens in your browser, and Toolspoke asks you to approve it.

  2. Install Google Gemini and connect it

    Add Google Gemini to a project in your Toolspoke workspace.

    API key. You provide it once, when you install the connector. Toolspoke encrypts it at rest and decrypts it only for the length of a single call, and the gateway attaches it to the outbound request itself, so it is never part of the arguments an agent sends.

    API key
    aistudio.google.com → Get API key
  3. Choose what Claude Code may do

    All 9 actions start on. Switch off any of the 2 actions that change something in Google Gemini, and Claude Code gets a refusal if it tries.

What you can ask Claude Code for

A few of the Google Gemini actions that only read, so they are safe to try first.

  • Turn one piece of text into an embedding vector, for similarity search, clustering or retrieval
  • Embed several strings in one request, returning one vector per string in the order given
  • Read one uploaded file's record: display name, MIME type, size, expiry, and its `state`

What Claude Code can do in Google Gemini

7 actions read, one writes and one deletes or permanently changes something.

Reads

  • List models

    List 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. Call this before generate_content or embed_content whenever a model id is not certain: this connector deliberately hard-codes no model names, because Google's roster changes faster than a file in a repository can. Note that ids come back in "models/gemini-…" form, while every operation here takes the bare id without the "models/" prefix. Free, and the cheapest proof that the key works.

  • Get model

    Read one model by id: display name, description, input and output token limits, default sampling settings, and which generation methods it supports. Use it to confirm a model can do what a request needs, that it lists embedContent before calling embed_content, or that its inputTokenLimit is large enough for a prompt count_tokens just measured. A 404 means this key cannot reach that id; call list_models to see what it can.

  • Count tokens

    Count how many input tokens a prompt would use against a given model, without generating anything and without being billed. A read, because nothing is created and nothing is charged. Use it before generate_content to check a prompt fits the model's inputTokenLimit, which get_model reports. Takes the same `contents` that generate_content takes, so count exactly what you intend to send. It measures input only; output tokens, usually the larger cost, are not predicted.

  • Embed content

    Turn one piece of text into an embedding vector, for similarity search, clustering or retrieval. A read: it creates nothing and stores nothing, it only measures. Use an embedding model, not a generation model, "gemini-embedding-001" is the current one, and list_models shows which ids list embedContent among their supported methods. Set task_type to match what the vector is for; Gemini tunes the embedding to it, and using RETRIEVAL_QUERY for a search query against a corpus embedded with RETRIEVAL_DOCUMENT is what makes retrieval work. output_dimensionality shortens the vector when storage matters. For many strings at once, call batch_embed_contents instead.

  • Batch embed contents

    Embed several strings in one request, returning one vector per string in the order given. Prefer this over calling embed_content repeatedly. Gemini counts each request against a per-minute rate limit, so one batch of fifty strings costs one request instead of fifty. Same model, task_type and dimensionality rules as embed_content, applied to every string in the batch. A read: nothing is created or stored.

  • List files

    List 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":…}}. That URI is the reason to call this. Gemini deletes uploaded files automatically after 48 hours, so a file listed yesterday may already be gone. Uploading is not offered here, it needs Google's resumable multipart upload, which this connector does not carry, so this lists what was put there by other means.

  • Get file

    Read one uploaded file's record: display name, MIME type, size, expiry, and its `state`. State is what this is usually called for, a freshly uploaded video sits at PROCESSING and a generate_content call referring to it fails until it reaches ACTIVE. Returns metadata only; the bytes are not downloadable through this API. Get the id from list_files.

Writes

  • Generate content

    Generate a response from a Gemini model. This is the operation that costs money, which is why it is a write while count_tokens and list_models are reads, and why it is not the health check. Streaming is out of scope: the whole response comes back at once, with its candidates, finish reason, safety ratings and token counts. `contents` is Gemini's own conversation form, a list of turns, each with a role and a list of parts, so a single question is [{"role":"user","parts":[{"text":"…"}]}] and a multi-turn conversation alternates "user" and "model" roles. For a structured answer, set response_mime_type to "application/json" and give a response_schema. Call list_models first if the model id is not certain, and count_tokens first if the prompt might not fit. The prompt is prose and the response is a model's own output, so neither is written to the audit log.

Deletes or permanently changes

  • Delete file

    Delete one uploaded file from the Gemini File API. There is no trash and no undo: the bytes go, and any generate_content call still referring to that fileUri fails from then on. Files expire by themselves after 48 hours, so deleting early is only worth doing when the content should not sit there that long. Get the id from list_files.

Google Gemini in Claude Code: questions

Does Claude Code see my Google Gemini credential?

No. The credential is stored encrypted in Toolspoke, and the gateway adds it to each call. Claude Code only ever talks to Toolspoke, and the dashboard shows the last four characters of the credential and nothing more.

Can I stop Claude Code from changing things in Google Gemini?

Yes. Each of the 9 actions can be switched off for a project. Turn off the 2 that change something and Claude Code can only read.

Will 9 actions crowd Claude Code's context?

No. Toolspoke shows Claude Code five bridge tools, plus a guide where a toolkit has one, and Claude Code searches for the Google Gemini action it needs when it needs it. Adding more toolkits does not add more tools to its list.

Can I add it once for every project?

Yes. Add --scope user to the command and Claude Code keeps Toolspoke in every project on this machine. Without it, the server is added to the project you ran the command in.

What does it cost?

Tool calls are free on every plan, and a Google Gemini call does not run in a sandbox, so it bills nothing.

Try Google Gemini in Claude Code

Free to start, and tool calls cost nothing on any plan.