Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Connect AI agents to Google Gemini

Scalekit connector
Open markdown

The Google Gemini connector lets your AI agent act in each user's Google Gemini account. Each user connects their own Google Gemini API key once, and Scalekit sends it with every call, so your agent never handles credentials. It comes with 26 tools.

Tools
26
What they doRead · write · destructive
10 · 12 · 410 read12 write4 destructive
Users sign in with

Setup

  1. Install the SDK

    Terminal window
    npm install @scalekit-sdk/node dotenv
  2. Set your credentials

    Add your Scalekit credentials to your .env file. Find values in app.scalekit.com > Developers > API Credentials.

    .env
    SCALEKIT_ENVIRONMENT_URL=<your-environment-url>
    SCALEKIT_CLIENT_ID=<your-client-id>
    SCALEKIT_CLIENT_SECRET=<your-client-secret>
  3. Create the Google Gemini connection

    In AgentKit > Connections, create a Google Gemini connection. The name you give it is the connection_name your code passes. See Configure connections.

  4. Authorize a user and make your first call

    quickstart.mts
    import { ScalekitClient } from '@scalekit-sdk/node'
    import 'dotenv/config'
    import { createInterface } from 'node:readline/promises'
    const scalekit = new ScalekitClient(
    process.env.SCALEKIT_ENVIRONMENT_URL,
    process.env.SCALEKIT_CLIENT_ID,
    process.env.SCALEKIT_CLIENT_SECRET,
    )
    const actions = scalekit.actions
    const connector = 'gemini'
    const identifier = 'user_123'
    // Generate an authorization link for the user
    const { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })
    console.log('Authorize Google Gemini:', link)
    const rl = createInterface({ input: process.stdin, output: process.stdout })
    await rl.question('Press Enter after authorizing...')
    rl.close()
    // Make your first call
    const result = await actions.executeTool({
    connector,
    identifier,
    toolName: 'gemini_list_batches',
    toolInput: {},
    })
    console.log(result)
    Terminal window
    npx tsx quickstart.mts

    Each user opens the link once and enters their Google Gemini credentials there. See Authorize a user for the full flow and statuses.

Tools

Pass the exact name to execute_tool
Try in PlaygroundRequest a tool
  • gemini_count_tokensCount the input tokens a prompt uses on a Gemini model, including any system instruction and tool declarations you pass.Read-only

    Count Tokens

    Count the input tokens a prompt uses on a Gemini model, including any system instruction and tool declarations you pass. Returns totalTokens, cachedContentTokenCount and per-modality promptTokensDetails. Use before gemini_generate_content to check a prompt fits the model's inputTokenLimit or to estimate cost. Counting is free.

    Inputs

    modelstringrequired
    Model id without the models/ prefix, for example gemini-3.8-flash. Token counts differ between models.
    contentsarray
    Conversation turns, oldest first. Each turn has a role (user or model) and a parts array. A part is one of: text ({"text": "..."}); inline media as base64 ({"inlineData": {"mimeType": "image/png", "data": "<base64>"}}), for images, audio, video or PDF up to the request size limit; or a file reference ({"fileData": {"mimeType": "video/mp4", "fileUri": "https://generativelanguage.googleapis.com/v1beta/files/abc-123"}}) for a file already in the Files API or a public YouTube URL. Function results go back as {"functionResponse": {"name": "...", "response": {...}}}. Example: [{"role": "user", "parts": [{"text": "Summarize this in one line."}]}]. Use prompt instead for a single text turn.
    promptstring
    Single user text turn. Shortcut for contents when you only need to send text; ignored when contents is set.
    system_instructionstring
    System instruction that sets the model's role, tone or rules. Text only.
    toolsarray
    Tools the model may use. Each entry is one tool object: {"googleSearch": {}} grounds the answer in Google Search; {"urlContext": {}} lets the model read URLs in the prompt; {"codeExecution": {}} lets it run Python; {"fileSearch": {"fileSearchStoreNames": ["fileSearchStores/my-store"]}} searches a File Search store; {"functionDeclarations": [{"name": "get_weather", "description": "Get the weather", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}]} declares functions the caller runs. Example: [{"googleSearch": {}}].
  • gemini_get_batchGet a batch job's status and, once finished, its results.Read-only

    Get Batch

    Get a batch job's status and, once finished, its results. Returns name, done, metadata (state such as BATCH_STATE_RUNNING or BATCH_STATE_SUCCEEDED, batchStats counts, output) and response; inline batches carry inlinedResponses, file batches carry a responsesFile name in the Files API. Use to poll a batch from gemini_create_batch or gemini_create_embeddings_batch until done is true. Use gemini_list_batches to find batch names.

    Inputs

    namestringrequired
    Batch resource name in the form batches/{id}, as returned in the name field when the batch was created.
  • gemini_get_cached_contentGet one context cache's metadata.Read-only

    Get Cached Content

    Get one context cache's metadata. Returns name, model, displayName, createTime, updateTime, expireTime and usageMetadata.totalTokenCount. Cached content itself is not returned. Use to check when a cache expires. Use gemini_list_cached_contents to find cache names.

    Inputs

    namestringrequired
    Cache resource name in the form cachedContents/{id}, as returned in the name field by gemini_create_cached_content or gemini_list_cached_contents.
  • gemini_get_fileGet one Files API file's metadata.Read-only

    Get File

    Get one Files API file's metadata. Returns name, displayName, mimeType, sizeBytes, sha256Hash, createTime, expirationTime, state, uri, downloadUri, videoMetadata and any processing error. File bytes are not returned. Use to check that a file is ACTIVE before passing its uri to gemini_generate_content, or to follow a video delivered by uri. Use gemini_list_files to find file names.

    Inputs

    namestringrequired
    File resource name in the form files/{id}, as returned in the name field by gemini_list_files. This is not the file's uri.
  • gemini_get_interactionGet a stored interaction by id, including background runs still in progress.Read-only

    Get Interaction

    Get a stored interaction by id, including background runs still in progress. Returns id, status, model or agent, created and updated times, steps (thoughts, tool calls, model_output with text, images or video) and usage. Use to poll a background interaction or video render until status is completed, or to reread a past result. Use gemini_create_interaction to start one.

    Inputs

    interaction_idstringrequired
    Interaction id, the id field returned by gemini_create_interaction or gemini_generate_video (for example v1_ChdhYmNk...).
    include_inputboolean
    Include the user_input steps in the returned interaction.
  • gemini_get_modelGet one Gemini API model's details.Read-only

    Get Model

    Get one Gemini API model's details. Returns name, baseModelId, version, displayName, description, input and output token limits, supportedGenerationMethods, thinking support and default temperature, topP and topK. Use to check a model's limits or supported methods. Use gemini_list_models to browse all models.

    Inputs

    modelstringrequired
    Model id without the models/ prefix, for example gemini-3.8-flash. Use gemini_list_models to see valid ids.
  • gemini_list_batchesList batch jobs in the API key's project, both generateContent and embedding batches.Read-only

    List Batches

    List batch jobs in the API key's project, both generateContent and embedding batches. Returns operations, each with name (batches/{id}), metadata (model, displayName, state, batchStats, createTime) and done, plus nextPageToken. Use to find batches and their states. Use gemini_get_batch for one batch's results.

    Inputs

    filterstring
    Optional list filter in the standard Google list filter syntax.
    page_sizeinteger
    Maximum number of batches per page. Defaults to 50; the API caps it at 1000.
    page_tokenstring
    Page token from the nextPageToken field of the previous response. Leave empty for the first page.
  • gemini_list_cached_contentsList the explicit context caches in the API key's project.Read-only

    List Cached Contents

    List the explicit context caches in the API key's project. Returns cachedContents with name, model, displayName, createTime, updateTime, expireTime and usageMetadata.totalTokenCount, plus nextPageToken. Cached content itself is not returned. Use to find a cache name to reuse or clean up. Use gemini_get_cached_content for one cache.

    Inputs

    page_sizeinteger
    Maximum number of caches per page. Defaults to 100; the API caps it at 1000.
    page_tokenstring
    Page token from the nextPageToken field of the previous response. Leave empty for the first page.