Skip to main content

Google Gemini Setup

Gemini is available in AxonFlow Community and Enterprise. That matters because many teams want a second cloud provider for multimodal or Google-centric workflows without taking an enterprise dependency on day one.

Runtime Defaults

AxonFlow's Gemini provider defaults to:

  • Provider name: gemini
  • Default model: gemini-2.0-flash
  • Default endpoint: https://generativelanguage.googleapis.com

The runtime also supports newer model names such as gemini-2.5-flash and gemini-2.5-pro when your Google account has access.

Environment Variables

export GOOGLE_API_KEY=your-google-api-key
export GOOGLE_MODEL=gemini-2.0-flash
export GOOGLE_TIMEOUT_SECONDS=120 # Request timeout in seconds (default: 120)
export GOOGLE_ENDPOINT=https://generativelanguage.googleapis.com # Custom endpoint

YAML Configuration

version: "1.0"

llm_providers:
gemini:
enabled: true
credentials:
api_key: ${GOOGLE_API_KEY}
config:
model: ${GOOGLE_MODEL:-gemini-2.0-flash}

Good Fits

  • Google ecosystem teams
  • Multimodal and large-context workflows
  • Community deployments that want provider diversity without enterprise-only gating
  • Search, document understanding, and multimodal enterprise assistants that need Gemini with governed rollout paths

Proxy Mode

import { AxonFlow } from '@axonflow/sdk';

const axonflow = new AxonFlow({
endpoint: 'http://localhost:8080',
clientId: process.env.AXONFLOW_CLIENT_ID,
clientSecret: process.env.AXONFLOW_CLIENT_SECRET,
});

const response = await axonflow.proxyLLMCall({
userToken: 'user-123',
query: 'Review this product strategy and identify the biggest execution risks.',
requestType: 'chat',
context: {
provider: 'gemini',
model: 'gemini-2.0-flash',
},
});

console.log(response.data);

Gateway Mode

import { AxonFlow } from '@axonflow/sdk';
import { GoogleGenerativeAI } from '@google/generative-ai';

const prompt = 'Review this product strategy and identify the biggest execution risks.';

const axonflow = new AxonFlow({
endpoint: 'http://localhost:8080',
clientId: process.env.AXONFLOW_CLIENT_ID,
clientSecret: process.env.AXONFLOW_CLIENT_SECRET,
});

const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY!);
const model = genAI.getGenerativeModel({ model: 'gemini-2.0-flash' });

const ctx = await axonflow.getPolicyApprovedContext({
userToken: 'user-123',
query: prompt,
});

if (!ctx.approved) {
throw new Error(`Blocked: ${ctx.blockReason}`);
}

const approvedPrompt =
typeof ctx.approvedData.query === 'string' ? String(ctx.approvedData.query) : prompt;

const result = await model.generateContent(approvedPrompt);
const output = result.response.text();

await axonflow.auditLLMCall({
contextId: ctx.contextId,
responseSummary: output.slice(0, 200),
provider: 'gemini',
model: 'gemini-2.0-flash',
tokenUsage: {
promptTokens: 0,
completionTokens: 0,
totalTokens: 0,
},
latencyMs: 250,
});

If your Gemini client exposes token usage metadata in your application path, pass those real counts into auditLLMCall instead of zeros.

Multimodal Workflows

Gemini is a good match for image-plus-text workflows in Gateway Mode because your application can call the Gemini SDK directly after pre-check approval, then audit the result back into AxonFlow.

Notes for Production Teams

  • Gemini is community-available in AxonFlow.
  • context.provider = "gemini" is still a routing preference unless you make it strict for the request.
  • If your organization expects to standardize on multiple cloud providers, Gemini makes a good second provider alongside OpenAI or Anthropic in community and evaluation environments.

Troubleshooting

IssueCauseFix
403 Permission deniedAPI not enabledEnable Gemini API in Google Cloud Console
429 Rate limitedQuota exceededCheck quota in Google Cloud Console
Model not foundWrong model IDUse model IDs from Google AI Studio

See Also