Skip to main content

Google Gemini

Use Google’s Gemini models with RadarOS through the unified ModelProvider interface. Gemini offers strong multi-modal capabilities—vision, audio, and native file handling.

Setup

Install the Google GenAI SDK (required by RadarOS for Gemini support):
npm install @google/genai

Factory

import { google } from "@radaros/core";

const model = google("gemini-2.5-flash");
modelId
string
required
The Gemini model identifier.
config
object
Optional configuration. See Config below.

Supported Models

Model IDDescription
gemini-2.5-flashFast, efficient. Great for high-throughput and latency-sensitive apps.
gemini-2.5-proHighest capability. Best for complex reasoning and long-context tasks.

Config

apiKey
string
Google API key. If omitted, uses GOOGLE_API_KEY environment variable.

Example

const model = google("gemini-2.5-flash", {
  apiKey: process.env.GOOGLE_API_KEY,
});

Multi-Modal Support

Gemini supports vision, audio, and file content. Pass multi-modal content via ContentPart[] in messages:

Files & Documents

Gemini handles files natively — including PDF, CSV, XLSX, and more. It’s the only provider that supports XLSX directly:
import { Agent, google, type ContentPart } from "@radaros/core";
import { readFileSync } from "node:fs";

const agent = new Agent({
  name: "file-analyzer",
  model: google("gemini-2.5-flash"),
  instructions: "Analyze documents and data files thoroughly.",
});

// PDF analysis
const pdfResult = await agent.run([
  { type: "text", text: "Summarize the key findings." },
  {
    type: "file",
    data: readFileSync("report.pdf").toString("base64"),
    mimeType: "application/pdf",
    filename: "report.pdf",
  },
] as ContentPart[]);

// Excel file (XLSX) — only Gemini supports this natively
const xlsxResult = await agent.run([
  { type: "text", text: "What are the total sales by region?" },
  {
    type: "file",
    data: readFileSync("sales.xlsx").toString("base64"),
    mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
    filename: "sales.xlsx",
  },
] as ContentPart[]);

// CSV file
const csvResult = await agent.run([
  { type: "text", text: "Find the outliers in this dataset." },
  {
    type: "file",
    data: readFileSync("data.csv").toString("base64"),
    mimeType: "text/csv",
    filename: "data.csv",
  },
] as ContentPart[]);

Supported File Types

FormatMIME TypeSupport
PDFapplication/pdfFull
CSVtext/csvFull
XLSXapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheetFull (unique to Gemini)
Plain texttext/plainFull
HTMLtext/htmlFull
JSONapplication/jsonFull
Gemini processes file content natively via inlineData, making it the most versatile provider for document analysis tasks.

Realtime / Voice (Gemini Live)

For real-time voice agents, use googleLive() to create a Google Gemini Live provider:
import { VoiceAgent, googleLive } from "@radaros/core";

const agent = new VoiceAgent({
  name: "assistant",
  provider: googleLive("gemini-2.5-flash-native-audio-preview-12-2025"),
  instructions: "You are a voice assistant.",
});
googleLive() is a shorthand for new GoogleLiveProvider(). It accepts the same config:
googleLive("gemini-2.5-flash-native-audio-preview-12-2025", {
  apiKey: "...", // optional, defaults to GOOGLE_API_KEY env
});
Requires: npm install @google/genai See the Voice Agents docs for full details.

Full Example

import { Agent, google } from "@radaros/core";

const agent = new Agent({
  name: "Gemini Assistant",
  model: google("gemini-2.5-flash", {
    apiKey: process.env.GOOGLE_API_KEY,
  }),
  instructions: "You are a helpful assistant with strong multi-modal capabilities.",
});

const output = await agent.run("Summarize the key points of this document.");
console.log(output.text);