Setu Recipes: reusable digital workers across every app.Browse templates

Integrations / Google Gemini

Google Gemini

Google's Gemini API: generate text, list models, count tokens and create embeddings.

5 actions API key 5 read0 write Calls generativelanguage.googleapis.com

Connect

TypeScript
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "gemini" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();

Permissions requested

This toolkit uses a single credential and requests no scopes.

Actions

Count tokensreadgemini.count_tokensCount how many tokens a text prompt uses for a given Gemini model.
InputTypeDescription
modelstringRequiredModel id without the models/ prefix
textstringRequiredThe text to count
TypeScript
await setu.execute({
  userId: "user_1",
  action: "gemini.count_tokens",
  input: {
    "model": "<model>",
    "text": "<text>"
  },
});
Create embeddingreadgemini.embed_contentCreate a text embedding vector with a Gemini embedding model.
InputTypeDescription
modelstringRequiredEmbedding model id without the models/ prefix, e.g. gemini-embedding-001
textstringRequiredText to embed
taskTypestringOptionalOptional task type, e.g. RETRIEVAL_QUERY
outputDimensionalityintegerOptionalOptional vector size
TypeScript
await setu.execute({
  userId: "user_1",
  action: "gemini.embed_content",
  input: {
    "model": "<model>",
    "text": "<text>"
  },
});
Generate textreadgemini.generate_contentGenerate a text response from a Gemini model for a prompt, with an optional system instruction.
InputTypeDescription
modelstringRequiredModel id without the models/ prefix, e.g. gemini-2.5-flash
promptstringRequiredThe user prompt
systemInstructionobjectOptionalOptional system instruction as {parts: [{text: ...}]}
generationConfigobjectOptionalOptional settings such as temperature and maxOutputTokens
TypeScript
await setu.execute({
  userId: "user_1",
  action: "gemini.generate_content",
  input: {
    "model": "<model>",
    "prompt": "<prompt>"
  },
});
Get modelreadgemini.get_modelGet one Gemini model's details: display name, token limits and supported generation methods.
InputTypeDescription
modelstringRequiredModel id without the models/ prefix
TypeScript
await setu.execute({
  userId: "user_1",
  action: "gemini.get_model",
  input: {
    "model": "<model>"
  },
});
List modelsreadgemini.list_modelsList the Gemini models available to this key with their token limits and supported methods.
InputTypeDescription
pageSizeintegerOptionalModels per page (default 50, max 1000)
pageTokenstringOptionalToken from a previous response
TypeScript
await setu.execute({
  userId: "user_1",
  action: "gemini.list_models",
  input: {},
});