Google Gemini

Updated

Integrate a Google Gemini LLM into Conversational AI Engine.

Google Gemini provides advanced multimodal AI capabilities with fast performance and efficient processing for conversational AI applications.

Sample configuration

The following example shows how to configure Google Gemini LLM when starting a conversational AI agent.

from agora_agent import Agent, Gemini

# client is your configured Agora client
agent = (
    Agent(client)
    .with_stt(...)  # configure your STT vendor
    .with_llm(Gemini(
        api_key='your-google-api-key',
        model='gemini-2.0-flash',
        system_messages=[{'parts': [{'text': 'You are a helpful chatbot.'}], 'role': 'user'}],
        greeting_message='Good to see you!',
        failure_message='Hold on a second.',
        max_history=32,
    ))
    .with_tts(...)  # configure your TTS vendor
)
import { Agent, Gemini } from 'agora-agents';

// client is your configured Agora client
const agent = new Agent({ client })
  .withStt(/* configure your STT vendor */)
  .withLlm(new Gemini({
    apiKey: 'your-google-api-key',
    model: 'gemini-2.0-flash',
    systemMessages: [{ parts: [{ text: 'You are a helpful chatbot.' }], role: 'user' }],
    greetingMessage: 'Good to see you!',
    failureMessage: 'Hold on a second.',
    maxHistory: 32,
  }))
  .withTts(/* configure your TTS vendor */);
import "github.com/AgoraIO/agora-agents-go/v2/agentkit/vendors"

// client is your configured Agora client
agent := agentkit.NewAgent(client).WithStt(/* configure your STT vendor */).
  WithLlm(
    vendors.NewGemini(vendors.GeminiOptions{
        APIKey: "your-google-api-key",
        Model:  "gemini-2.0-flash",
        SystemMessages: []map[string]interface{}{
            {"parts": []map[string]interface{}{{"text": "You are a helpful chatbot."}}, "role": "user"},
        },
        GreetingMessage: "Good to see you!",
        FailureMessage:  "Hold on a second.",
        MaxHistory:      agora.Int(32),
    }),
).WithTts(/* configure your TTS vendor */)

Use the following llm configuration in your request:

"llm": {
   "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:streamGenerateContent?alt=sse&key=<api_key>",
   "system_messages": [
       {
           "parts": [
               {
                   "text": "You are a helpful chatbot"
               }
           ],
           "role": "user"
       }
   ],
   "max_history": 32,
   "greeting_message": "Good to see you!",
   "failure_message": "Hold on a second.",
   "params": {
       "model": "gemini-2.0-flash"
   },
   "style": "gemini"
}

Key parameters

llmrequired
urlstring
required

Note that the API key is passed in the URL query parameter. Get your API key from Google AI Studio.

system_messagesarray[object]
optional

Use parts array with text objects instead of simple content string.

stylestring
required

Set to gemini to use Gemini's message format.

ignore_emptyboolean
optional

Set to true to handle empty responses appropriately.

paramsobject
required
modelstring
required

Refer to Gemini models for available models.

For advanced configuration options, model capabilities, and detailed parameter descriptions, see the Google Gemini API documentation.