AI & Machine LearningGoogle Gemini Integration
AI & Machine Learning

Google Gemini Integration

Google Gemini API client for AI text generation, chat conversations, and content creation. Provides access to Google's advanced language models for various generative AI tasks.

Google Gemini

Category: AI & Machine Learning
Provider Key: googleGemini
SDK Packages: @google/generative-ai@^0.24.1

Google Gemini API client for AI text generation, chat conversations, and content creation. Provides access to Google's advanced language models for various generative AI tasks.


Configuration

To use Google Gemini in your project, add it to your project integrations and provide the following configuration:

ParameterTypeRequiredDescription
apiKeystringYesGoogle AI Studio API key
modelstringNoModel to use (e.g., 'gemini-pro', 'gemini-pro-vision')
temperaturenumberNoTemperature for generation (0.0 to 1.0)
maxOutputTokensnumberNoMaximum tokens in response
topPnumberNoTop-p sampling value
topKnumberNoTop-k sampling value

Example Configuration

{
  "provider": "googleGemini",
  "configuration": [
    { "name": "apiKey", "value": "your-apiKey" },
    { "name": "model", "value": "your-model" },
    { "name": "temperature", "value": 0 },
    { "name": "maxOutputTokens", "value": 0 },
    { "name": "topP", "value": 0 },
    { "name": "topK", "value": 0 }
  ]
}

Available Methods

Quick reference:

  • Generation: generateContent, generateContentStream
  • Chat: startChat
  • Utilities: countTokens
  • Embeddings: embedContent, batchEmbedContents

Generation

generateContent

Generate Content

Generate text content from a prompt

Parameters:

ParameterTypeRequiredDescription
promptstringYesThe text prompt for generation
imagesArrayNoArray of image data (base64 or URLs) for vision models
safetySettingsObjectNoSafety settings for content filtering

IntegrationAction example:

{
  "extendClassName": "IntegrationAction",
  "name": "generateContentAction",
  "provider": "googleGemini",
  "action": "generateContent",
  "parameters": [
    { "parameterName": "prompt", "parameterValue": "'your-prompt'" },
    { "parameterName": "images", "parameterValue": "[]" },
    { "parameterName": "safetySettings", "parameterValue": "{}" }
  ],
  "contextPropertyName": "generateContentResult"
}

MScript example:

await _googleGemini.generateContent({
  prompt: /* string */,
  images: /* Array */,
  safetySettings: /* Object */,
})

Service library example:

const { getIntegrationClient } = require("integrations");
const client = await getIntegrationClient("googleGemini");
const result = await client.generateContent({
  prompt: /* string */,
  images: /* Array */,
  safetySettings: /* Object */,
});

generateContentStream

Generate Content Stream

Stream generated content for longer responses

Parameters:

ParameterTypeRequiredDescription
promptstringYesThe text prompt for generation
onChunkFunctionYesCallback function for each streamed chunk

IntegrationAction example:

{
  "extendClassName": "IntegrationAction",
  "name": "generateContentStreamAction",
  "provider": "googleGemini",
  "action": "generateContentStream",
  "parameters": [
    { "parameterName": "prompt", "parameterValue": "'your-prompt'" },
    { "parameterName": "onChunk", "parameterValue": "'your-onChunk'" }
  ],
  "contextPropertyName": "generateContentStreamResult"
}

MScript example:

await _googleGemini.generateContentStream({
  prompt: /* string */,
  onChunk: /* Function */,
})

Service library example:

const { getIntegrationClient } = require("integrations");
const client = await getIntegrationClient("googleGemini");
const result = await client.generateContentStream({
  prompt: /* string */,
  onChunk: /* Function */,
});

Chat

startChat

Start Chat

Start a multi-turn chat conversation

Parameters:

ParameterTypeRequiredDescription
historyArrayNoPrevious conversation history
generationConfigObjectNoGeneration configuration for this chat

IntegrationAction example:

{
  "extendClassName": "IntegrationAction",
  "name": "startChatAction",
  "provider": "googleGemini",
  "action": "startChat",
  "parameters": [
    { "parameterName": "history", "parameterValue": "[]" },
    { "parameterName": "generationConfig", "parameterValue": "{}" }
  ],
  "contextPropertyName": "startChatResult"
}

MScript example:

await _googleGemini.startChat({
  history: /* Array */,
  generationConfig: /* Object */,
})

Service library example:

const { getIntegrationClient } = require("integrations");
const client = await getIntegrationClient("googleGemini");
const result = await client.startChat({
  history: /* Array */,
  generationConfig: /* Object */,
});

Utilities

countTokens

Count Tokens

Count tokens in a text prompt

Parameters:

ParameterTypeRequiredDescription
textstringYesText to count tokens for

IntegrationAction example:

{
  "extendClassName": "IntegrationAction",
  "name": "countTokensAction",
  "provider": "googleGemini",
  "action": "countTokens",
  "parameters": [
    { "parameterName": "text", "parameterValue": "'your-text'" }
  ],
  "contextPropertyName": "countTokensResult"
}

MScript example:

await _googleGemini.countTokens({
  text: /* string */,
})

Service library example:

const { getIntegrationClient } = require("integrations");
const client = await getIntegrationClient("googleGemini");
const result = await client.countTokens({
  text: /* string */,
});

Embeddings

embedContent

Embed Content

Embed text for semantic search or similarity

Parameters:

ParameterTypeRequiredDescription
contentstringYesText content to embed
taskTypestring ("RETRIEVAL_QUERY", "RETRIEVAL_DOCUMENT", "SEMANTIC_SIMILARITY", "CLASSIFICATION", "CLUSTERING")NoTask type for embedding (e.g., 'RETRIEVAL_QUERY', 'RETRIEVAL_DOCUMENT')
modelstringNoEmbedding model to use (default: 'embedding-001')

IntegrationAction example:

{
  "extendClassName": "IntegrationAction",
  "name": "embedContentAction",
  "provider": "googleGemini",
  "action": "embedContent",
  "parameters": [
    { "parameterName": "content", "parameterValue": "'your-content'" },
    { "parameterName": "taskType", "parameterValue": "'your-taskType'" },
    { "parameterName": "model", "parameterValue": "'your-model'" }
  ],
  "contextPropertyName": "embedContentResult"
}

MScript example:

await _googleGemini.embedContent({
  content: /* string */,
  taskType: /* string */,
  model: /* string */,
})

Service library example:

const { getIntegrationClient } = require("integrations");
const client = await getIntegrationClient("googleGemini");
const result = await client.embedContent({
  content: /* string */,
  taskType: /* string */,
  model: /* string */,
});

batchEmbedContents

Batch Embed Contents

Batch embed multiple texts

Parameters:

ParameterTypeRequiredDescription
contentsArray<string>YesArray of text contents to embed
taskTypestring ("RETRIEVAL_QUERY", "RETRIEVAL_DOCUMENT", "SEMANTIC_SIMILARITY", "CLASSIFICATION", "CLUSTERING")NoTask type for embedding
modelstringNoEmbedding model to use

IntegrationAction example:

{
  "extendClassName": "IntegrationAction",
  "name": "batchEmbedContentsAction",
  "provider": "googleGemini",
  "action": "batchEmbedContents",
  "parameters": [
    { "parameterName": "contents", "parameterValue": "'your-contents'" },
    { "parameterName": "taskType", "parameterValue": "'your-taskType'" },
    { "parameterName": "model", "parameterValue": "'your-model'" }
  ],
  "contextPropertyName": "batchEmbedContentsResult"
}

MScript example:

await _googleGemini.batchEmbedContents({
  contents: /* Array<string> */,
  taskType: /* string */,
  model: /* string */,
})

Service library example:

const { getIntegrationClient } = require("integrations");
const client = await getIntegrationClient("googleGemini");
const result = await client.batchEmbedContents({
  contents: /* Array<string> */,
  taskType: /* string */,
  model: /* string */,
});