Skip to content

Google Gemini

Google AI Studio provides access to Gemini models with a generous free tier (up to 1,500 requests/day for Gemini 2.0 Flash).

Setup

Get an API key at aistudio.google.com.

const agent = new Agent({
name: 'my-agent',
model: {
provider: 'google',
model: 'gemini-2.0-flash',
},
systemPrompt: 'You are a helpful assistant.',
});
Terminal window
npx wrangler secret put GOOGLE_AI_KEY
ModelContextBest for
gemini-2.0-flash1MFast, general purpose (recommended)
gemini-1.5-pro2MComplex tasks, large documents
gemini-1.5-flash1MCost-efficient tasks

Environment variable

interface Env {
GOOGLE_AI_KEY: string;
}

Notes

Google AI Studio uses an OpenAI-compatible endpoint, so the integration is seamless with no special configuration needed.