> For the complete documentation index, see [llms.txt](https://docs.fastn.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fastn.ai/connectors/catalog/ai-ml/google-gemini.md). Agents can also search and read this documentation through its [MCP server](https://docs.fastn.ai/~gitbook/mcp).

# Google Gemini

Google Gemini provides AI models. Generate content and embeddings, count tokens, run batches, and manage cached content, files and corpora.

![Google Gemini logo](https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2Fgit-blob-601dd3cfefa97c3054bf719a6c4e0a6b09697b9b%2Fgoogle-gemini.png?alt=media)

|                    |                                                                             |
| ------------------ | --------------------------------------------------------------------------- |
| **Category**       | [AI and ML](https://docs.fastn.ai/connectors/catalog/ai-ml.md)              |
| **Website**        | [ai.google.dev](https://ai.google.dev)                                      |
| **Authentication** | API key, OAuth 2.0                                                          |
| **Slug**           | `googleGemini`                                                              |
| **On fastn.ai**    | [Embed Google Gemini in your product](https://fastn.ai/integrations/gemini) |

## Setup

Your customers sign in to Google Gemini through Fastn's own OAuth app, so nothing needs setting up first. To show your own app on the consent screen instead, add your OAuth app on the connector's **Auth** tab under **Manage providers**.

## Connect in Fastn

Your customers connect Google Gemini from your widget. To connect an account yourself:

1. Go to **Build → Integrations → Connectors** and search for **Google Gemini**.
2. Select **Connect** on the Google Gemini card.

   <figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2Fgit-blob-586dd03cdc0c6904263f58928d7a531eae2f85df%2Fconnect-search.png?alt=media" alt="The Connectors page in Fastn with ServiceNow typed in the search box and the ServiceNow card showing a Connect button"><figcaption><p>Search for the connector, then select Connect on its card. ServiceNow is shown here.</p></figcaption></figure>
3. Google Gemini offers more than one sign-in method. Choose one in **Auth Method**, then:
   * For a key or credential method, fill in the fields the form asks for, using the values from [Setup](#setup) above. Then select **Connect**.

     <figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2Fgit-blob-51fb88ef328c525b5b11f8d7094bab11efc333b8%2Fconnect-credentials.png?alt=media" alt="The Connect ServiceNow dialog with an optional account name and the Instance, Username and Password fields, and Cancel and Connect buttons"><figcaption><p>A connect form that asks for credentials. Each connector asks for its own fields.</p></figcaption></figure>
   * For OAuth 2.0, keep the **Default** auth provider, or choose your own OAuth app if you added one. Pick the **Scopes** you need, select **Authorize**, then sign in to Google Gemini and approve access in the window that opens.

     <figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2Fgit-blob-0e2bbdd7109cec207402cf6883484b8525b7fbf5%2Fconnect-oauth.png?alt=media" alt="The Connect Salesforce dialog for OAuth 2.0 with the Default auth provider, an optional account name, the Scopes selector and an Authorize button"><figcaption><p>A connect form for OAuth 2.0. Salesforce is shown here.</p></figcaption></figure>
4. Check that the connection appears under **Operate → Connections** with the status `Active`. Your workflows can now use Google Gemini's actions.

For more detail, see [Connect an app](https://docs.fastn.ai/build/integrations/connectors/connect-an-app.md).

## Actions

<table><thead><tr><th width="240">Action</th><th width="260">Slug</th><th>What it does</th></tr></thead><tbody><tr><td>Batch Embed Contents</td><td><code>batchEmbedContents</code></td><td>Generate embeddings for multiple inputs in one call. Each request mirrors embedContent (content, taskType, title, outputDimensionality) and must include model: models/{id}.</td></tr><tr><td>Batch Generate Content</td><td><code>batchGenerateContent</code></td><td>Submit an asynchronous Batch Mode job that runs many generateContent requests at ~50% cost with a ~24h SLA. Provide inlined requests or a file (files/{id}) as input. Returns a long-running operation; poll with getBatch.</td></tr><tr><td>Cancel Batch</td><td><code>cancelBatch</code></td><td>Cancel a running Batch Mode job by id (batches/{id}:cancel).</td></tr><tr><td>Count Tokens</td><td><code>countTokens</code></td><td>Count the tokens for a given input under a model. Accepts either contents[] or a full generateContentRequest (mutually exclusive). Returns totalTokens and modality breakdowns.</td></tr><tr><td>Create Cached Content</td><td><code>createCachedContent</code></td><td>Create a context cache (cachedContents) holding contents/tools/systemInstruction for a specific model, reusable across generateContent calls to reduce input token cost. Set expiry via ttl ('3600s') or expireTime.</td></tr><tr><td>Create Corpus</td><td><code>createCorpus</code></td><td>Creates an empty semantic retrieval corpus (Gemini API v1beta corpora.create) owned by the signed-in user; a project can hold up to 10 corpora. If no ID is given, Google derives one from displayName plus a random suffix. Requires a Google OAuth 2.0 connection; Google scope: generative-language.retriever. Remove it with Delete Corpus. Returns the created Corpus with its name.</td></tr><tr><td>Delete Batch</td><td><code>deleteBatch</code></td><td>Delete a Batch Mode job by id (batches/{id}).</td></tr><tr><td>Delete Cached Content</td><td><code>deleteCachedContent</code></td><td>Delete a context cache by id (cachedContents/{id}). Returns an empty body on success.</td></tr><tr><td>Delete Corpus</td><td><code>deleteCorpus</code></td><td>Deletes a semantic retrieval corpus (Gemini API v1beta corpora.delete). Without force=true Google refuses (FAILED_PRECONDITION) if the corpus still contains documents. Requires a Google OAuth 2.0 connection; Google scope: generative-language.retriever. Returns an empty body on success.</td></tr><tr><td>Delete File</td><td><code>deleteFile</code></td><td>Delete an uploaded file by name (files/{id}). Returns an empty body on success.</td></tr></tbody></table>

<details>

<summary>View 19 more actions</summary>

<table><thead><tr><th width="240">Action</th><th width="260">Slug</th><th>What it does</th></tr></thead><tbody><tr><td>Delete Tuned Model</td><td><code>deleteTunedModel</code></td><td>Permanently deletes one of the signed-in user's Gemini tuned models (Gemini API v1beta tunedModels.delete). Irreversible. Requires a Google OAuth 2.0 connection; Google scope: generative-language.tuning. Returns an empty body on success.</td></tr><tr><td>Embed Content</td><td><code>embedContent</code></td><td>Generate a text embedding vector from input content using an embedding model (e.g. gemini-embedding-001, text-embedding-004). Supports taskType, title, and outputDimensionality.</td></tr><tr><td>Generate Content</td><td><code>generateContent</code></td><td>Generate a model response from a list of Content inputs (text and multimodal). Supports system instructions, tools/function-calling, safety settings, and generationConfig (temperature, topK, topP, maxOutputTokens, responseMimeType, responseSchema, thinkingConfig). Returns candidates with content parts, finishReason, safetyRatings, plus usageMetadata.</td></tr><tr><td>Generate Content (OAuth)</td><td><code>generateContentOAuth</code></td><td>Generates a text answer from a Gemini model for a single prompt (Gemini API v1beta models.generateContent) using the signed-in user's Google OAuth token instead of an API key, so usage counts against that user's per-user quota. Requires a Google OAuth 2.0 connection; Google scope: generative-language.peruserquota. Use the API-key Generate Content action for the full request body. Returns candidates[] with content.parts[].text, finishReason and usageMetadata.</td></tr><tr><td>Get Batch</td><td><code>getBatch</code></td><td>Get the status/result of a Batch Mode job by id (batches/{id}). When done is true, response contains the inlined or file output.</td></tr><tr><td>Get Cached Content</td><td><code>getCachedContent</code></td><td>Get a single context cache by id (cachedContents/{id}).</td></tr><tr><td>Get Corpus</td><td><code>getCorpus</code></td><td>Gets one semantic retrieval corpus by ID (Gemini API v1beta corpora.get). Read-only. Requires a Google OAuth 2.0 connection; Google scope: generative-language.retriever.readonly (or generative-language.retriever). Returns the Corpus (name, displayName, createTime, updateTime).</td></tr><tr><td>Get File</td><td><code>getFile</code></td><td>Get metadata for a single uploaded file by name (files/{id}), including its processing state and uri.</td></tr><tr><td>Get Model</td><td><code>getModel</code></td><td>Get metadata for a specific model (token limits, supported generation methods, default sampling params).</td></tr><tr><td>Get Tuned Model</td><td><code>getTunedModel</code></td><td>Gets one Gemini tuned model by ID (Gemini API v1beta tunedModels.get), including its base model, state, tuning task and hyperparameters. Read-only. Requires a Google OAuth 2.0 connection; Google scope: generative-language.tuning.readonly (or generative-language.tuning). Returns the TunedModel.</td></tr><tr><td>List Batches</td><td><code>listBatches</code></td><td>List Batch Mode jobs for the API key's project. Paginated.</td></tr><tr><td>List Cached Contents</td><td><code>listCachedContents</code></td><td>List the context caches (cachedContents) for the API key's project. Paginated.</td></tr><tr><td>List Corpora</td><td><code>listCorpora</code></td><td>Lists the semantic retrieval corpora (document collections) owned by the signed-in user (Gemini API v1beta corpora.list). Read-only. Requires a Google OAuth 2.0 connection; Google scope: generative-language.retriever.readonly (or generative-language.retriever). Returns corpora[] (name, displayName, createTime, updateTime) and nextPageToken.</td></tr><tr><td>List Files</td><td><code>listFiles</code></td><td>List the files uploaded via the Gemini Files API for the API key's project. Paginated.</td></tr><tr><td>List Models</td><td><code>listModels</code></td><td>List the models available through the Gemini Developer API, with their token limits and supported generation methods. Paginated.</td></tr><tr><td>List Tuned Models</td><td><code>listTunedModels</code></td><td>Lists the Gemini tuned (fine-tuned) models the signed-in user owns or can access (Gemini API v1beta tunedModels.list). Read-only. Requires a connection made with the Google OAuth 2.0 auth method; Google scope: generative-language.tuning.readonly (or generative-language.tuning). Returns tunedModels[] (name, displayName, baseModel, state, createTime) and nextPageToken; an empty object when the user has none.</td></tr><tr><td>Stream Generate Content</td><td><code>streamGenerateContent</code></td><td>Streaming variant of generateContent. Returns incremental GenerateContentResponse chunks server-sent. Same request body as generateContent. Use alt=sse query param for server-sent events framing.</td></tr><tr><td>Update Cached Content</td><td><code>updateCachedContent</code></td><td>Update a context cache's expiry (only ttl or expireTime are mutable). Pass updateMask to indicate which field changes.</td></tr><tr><td>Upload File (metadata)</td><td><code>uploadFile</code></td><td>Upload a text file to the Gemini Files API in one multipart request (metadata + content). Binary files are not supported by the engine.</td></tr></tbody></table>

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.fastn.ai/connectors/catalog/ai-ml/google-gemini.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
