Gemini Integration

Google Gemini is a drop-in alternative to OpenAI for most jekcms AI features. The big pitch: a generous free tier. At time of writing, Gemini gives you 15 requests per minute and 1.5 million tokens per day on gemini-2.0-flash for free — enough to run alt-text automation and light content assist across a modest site without ever paying.

You can run Gemini alone, use it as a fallback for OpenAI, or route specific features to Gemini while keeping others on OpenAI. See [OpenAI integration](/docs/integrations/openai) for how those features work; this page focuses on the Gemini-specific setup.

Getting your API key

  1. Go to [aistudio.google.com](https://aistudio.google.com) and sign in with a Google account
  2. Get API key (top-left) → Create API key
  3. If you have a GCP project, pick it; otherwise AI Studio makes a free one for you
  4. Copy the key — you'll see it once in plaintext

No billing setup required for free-tier usage. If you exceed free-tier quota, you'll get rate-limited responses rather than surprise charges — Gemini only bills if you've explicitly enabled paid tier on the project.

Adding the key to jekcms

  1. Admin → Settings → API Keys
  2. Paste the key into Gemini API key
  3. Save

Encrypted at rest with the same AES-256 scheme used for OpenAI and Stripe keys.

Model selection

Under Settings → AI → Model preferences, Gemini exposes:

  • gemini-2.0-flash — Default for content generation. Fast, multimodal, handles long context well (1M tokens). Free-tier friendly.
  • gemini-2.0-flash-lite — Cheaper, lower-latency sibling. Use for high-volume trivial tasks like alt-text and excerpts where top-tier reasoning is overkill.
  • gemini-2.0-pro — Higher quality for complex rewrites, but slower and hits free-tier quota faster.

Recommended assignments:

| Feature | Suggested model | |---|---| | Content assist (editor buttons) | gemini-2.0-flash | | Bulk post generation | gemini-2.0-flash | | Alt-text on uploaded images | gemini-2.0-flash-lite | | Excerpt generation | gemini-2.0-flash-lite | | Comment moderation classification | gemini-2.0-flash-lite |

You can override per-feature just like with OpenAI.

Free tier limits at a glance

Current Google AI Studio free tier (verify at [ai.google.dev/pricing](https://ai.google.dev/pricing) — these numbers shift):

  • 15 requests per minute per model
  • 1 million tokens per minute
  • 1,500 requests per day on flash, proportionally less on pro
  • 1.5M tokens per day on flash

For context: a typical blog post is 2–4k tokens input + 1–2k tokens output. That's hundreds of posts per day on a free tier, or thousands of alt-text generations.

When to prefer Gemini over OpenAI

Cost. If your workloads fit inside the free tier, Gemini is literally zero dollars. For a content site generating a few dozen posts + alt-text for every uploaded image, that's meaningful.

Vision tasks. Gemini's image understanding is on par with GPT-4o and cheaper per call. Alt-text automation and image-based classification (e.g., "does this user-uploaded image contain text?") are natural fits.

Long context. Gemini's 1M-token window beats OpenAI's 128k on gpt-4o. If you're feeding the model a full document to rewrite or asking it to reason across an entire category's worth of posts, Gemini handles it without chunking.

When to stay on OpenAI. Complex reasoning (legal/technical rewrites, code generation inside content), function calling reliability, and cases where you've already tuned prompts against GPT-4o's specific behavior.

Fallback chain

With both keys saved you can build a resilient chain. Under Settings → AI → Fallback:

Primary:   OpenAI (gpt-4o-mini)
Fallback:  Gemini (gemini-2.0-flash)

jekcms calls the primary first. If the response is a 429 (rate limit), 5xx, or timeout, it retries against the fallback with the same prompt. The user sees one successful generation; the fallback is invisible unless you check the AI usage logs.

You can also invert the order — put Gemini primary (free) and OpenAI fallback (quality insurance for the edge cases when Gemini rate-limits you). This is often the cheapest-per-quality configuration for mid-volume sites.

Per-feature routing

Beyond a global chain, the Model preferences table lets you pick a different provider+model for each feature. Example setup:

| Feature | Provider | Model | |---|---|---| | Content assist | OpenAI | gpt-4o-mini | | Bulk generation | Gemini | gemini-2.0-flash | | Alt-text | Gemini | gemini-2.0-flash-lite | | Excerpts | Gemini | gemini-2.0-flash-lite |

This mixes quality where it matters (live editor) with free-tier volume where it doesn't (background alt-text on thousands of images).

Troubleshooting

"API key not valid." Usually a copy-paste issue — trailing whitespace or only part of the key pasted. Re-paste from AI Studio.

"Resource has been exhausted." You hit the per-minute or per-day quota. Either wait (quotas reset), enable paid tier on the Google Cloud project backing your AI Studio key, or shift that feature to OpenAI temporarily.

Alt-text quality is poor. gemini-2.0-flash-lite is good but not great. Either upgrade that feature to gemini-2.0-flash, or route alt-text to OpenAI and keep everything else on Gemini.

Fallback not triggering. Check Admin → AI → Usage → Logs — fallback only kicks in on specific error codes (429, 5xx, timeout). A malformed prompt that returns a 400 is a user error, not a provider outage, so no fallback.

Be the first to know

New features, release notes & CMS guides — a couple of emails a month, no spam.