google-gemini-api

jezweb/claude-skills · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/jezweb/claude-skills --skill google-gemini-api
0 commentsdiscussion
summary

Multimodal AI with Gemini 2.5 and 3 models, supporting text, images, video, audio, PDFs, function calling, thinking mode, and real-time web grounding.

  • Supports three deployment approaches: Node.js SDK (@google/genai), fetch-based REST API for edge runtimes, and chat helpers for multi-turn conversations
  • Handles multimodal inputs (images, video, audio, PDFs) with 1,048,576 token context window; thinking mode enabled by default for enhanced reasoning quality
  • Includes function calling wi
skill.md

Google Gemini API - Complete Guide

Version: 3.0.0 (14 Known Issues Added) Package: @google/[email protected] (⚠️ NOT @google/generative-ai) Last Updated: 2026-01-21


⚠️ CRITICAL SDK MIGRATION WARNING

DEPRECATED SDK: @google/generative-ai (sunset November 30, 2025) CURRENT SDK: @google/genai v1.27+

If you see code using @google/generative-ai, it's outdated!

This skill uses the correct current SDK and provides a complete migration guide.


Status

✅ Phase 1 Complete:

  • ✅ Text Generation (basic + streaming)
  • ✅ Multimodal Inputs (images, video, audio, PDFs)
  • ✅ Function Calling (basic + parallel execution)
  • ✅ System Instructions & Multi-turn Chat
  • ✅ Thinking Mode Configuration
  • ✅ Generation Parameters (temperature, top-p, top-k, stop sequences)
  • ✅ Both Node.js SDK (@google/genai) and fetch approaches

✅ Phase 2 Complete:

  • ✅ Context Caching (cost optimization with TTL-based caching)
  • ✅ Code Execution (built-in Python interpreter and sandbox)
  • ✅ Grounding with Google Search (real-time web information + citations)

📦 Separate Skills:

  • Embeddings: See google-gemini-embeddings skill for text-embedding-004

Table of Contents

Phase 1 - Core Features:

  1. Quick Start
  2. Current Models (2025)
  3. SDK vs Fetch Approaches
  4. Text Generation
  5. Streaming
  6. Multimodal Inputs
  7. Function Calling
  8. System Instructions
  9. Multi-turn Chat
  10. Thinking Mode
  11. Generation Configuration

Phase 2 - Advanced Features: 12. Context Caching 13. Code Execution 14. Grounding with Google Search

Common Reference: 15. Known Issues Prevention 16. Error Handling 17. Rate Limits 18. SDK Migration Guide 19. Production Best Practices


Quick Start

Installation

CORRECT SDK:

npm install @google/[email protected]

❌ WRONG (DEPRECATED):

npm install @google/generative-ai  # DO NOT USE!

Environment Setup

export GEMINI_API_KEY="..."

Or create .env file:

GEMINI_API_KEY=...

First Text Generation (Node.js SDK)

import { GoogleGenAI } from '@google/genai';

const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

const response = await ai.models.generateContent({
  model: 'gemini-2.5-flash',
  contents: 'Explain quantum computing in simple terms'
});

console.log(response.text);

First Text Generation (Fetch - Cloudflare Workers)

const response = await fetch(
  `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-goog-api-key': env.GEMINI_API_KEY,
    },
    body: JSON.stringify({
      contents: [{ parts: [{ text: 'Explain quantum computing in simple terms' }] }]
    }),
  }
);

const data = await response.json();
console.log(data.candidates[0].content.parts[0].text);

Current Models (2025)

Gemini 3 Series (December 2025)

gemini-3-flash

  • Context: 1,048,576 input tokens / 65,536 output tokens
  • Status: 🆕 Generally Available (December 2025)
  • Description: Google's fastest and most efficient Gemini 3 model for production workloads
  • Best for: High-throughput applications, low-latency responses, cost-sensitive production
  • Features: Enhanced multimodal, function calling, streaming, thinking mode
  • Benchmark Performance: Matches gemini-2.5-pro quality at gemini-2.5-flash speed/cost
  • Recommended for: Production use cases requiring speed + quality balance

gemini-3-pro-preview

  • Context: TBD (documentation pending)
  • Status: Preview release (November 18, 2025)
  • Description: Google's newest and most intelligent AI model with state-of-the-art reasoning
  • Best for: Most complex reasoning tasks, advanced multimodal understanding, benchmark-critical applications
  • Features: Enhanced multimodal (text, image, video, audio, PDF), function calling, streaming
  • Benchmark Performance: Outperforms Gemini 2.5 Pro on every major AI benchmark
  • ⚠️ Preview Models Warning: Preview models have NO SLAs and can change or be deprecated with little notice. Use GA (generally available) models for production. See Issue #13

Gemini 2.5 Series (General Availability - Stable)

gemini-2.5-pro

  • Context: 1,048,576 input tokens / 65,536 output tokens
  • Description: State-of-the-art thinking model for complex reasoning
  • Best for: Code, math, STEM, complex problem-solving
  • Features: Thinking mode (default on), function calling, multimodal, streaming
  • Knowledge cutoff: January 2025

gemini-2.5-flash

  • Context: 1,048,576 input tokens / 65,536 output tokens
  • Description: Best price-performance workhorse model
  • Best for: Large-scale processing, low-latency, high-volume, agentic use cases
  • Features: Thinking mode (default on), function calling, multimodal, streaming
  • Knowledge cutoff: January 2025

gemini-2.5-flash-lite

  • Context: 1,048,576 input tokens / 65,536 output tokens
  • Description: Cost-optimized, fastest 2.5 model
  • Best for: High throughput, cost-sensitive applications
  • Features: Thinking mode (default on), function calling, multimodal, streaming
  • Knowledge cutoff: January 2025

Model Feature Matrix

Feature 3-Flash 3-Pro (Preview) 2.5-Pro 2.5-Flash 2.5-Flash-Lite
Thinking Mode ✅ Default ON TBD ✅ Default ON ✅ Default ON ✅ Default ON
Function Calling
Multimodal ✅ Enhanced ✅ Enhanced
Streaming
System Instructions
Context Window 1,048,576 in TBD 1,048,576 in 1,048,576 in 1,048,576 in
Output Tokens 65,536 max TBD 65,536 max 65,536 max 65,536 max
Status GA Preview Stable Stable Stable

⚠️ Context Window Correction

ACCURATE (Gemini 2.5): Gemini 2.5 models support 1,048,576 input tokens (NOT 2M!) OUTDATED: Only Gemini 1.5 Pro (previous generation) had 2M token context window GEMINI 3: Context window specifications pending official documentation

Common mistake: Claiming Gemini 2.5 has 2M tokens. It doesn't. This skill prevents this error.


SDK vs Fetch Approaches

Node.js SDK (@google/genai)

Pros:

  • Type-safe with TypeScript
  • Easier API (simpler syntax)
  • Built-in chat helpers
  • Automatic SSE parsing for streaming
  • Better error handling

Cons:

  • Requires Node.js or compatible runtime
  • Larger bundle size
  • May not work in all edge runtimes

Use when: Building Node.js apps, Next.js Server Actions/Components, or any environment with Node.js compatibility

Fetch-based (Direct REST API)

Pros:

  • Works in any JavaScript environment (Cloudflare Workers, Deno, Bun, browsers)
  • Minimal dependencies
  • Smaller bundle size
  • Full control over requests

Cons:

  • More verbose syntax
  • Manual SSE parsing for streaming
  • No built-in chat helpers
  • Manual error handling

Use when: Deploying to Cloudflare Workers, browser clients, or lightweight edge runtimes


Text Generation

Basic Text Generation (SDK)

import { GoogleGenAI } from '@google/genai';

const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

const response = await ai.models.generateContent({
  model: 'gemini-2.5-flash',
  contents: 'Write a haiku about artificial intelligence'
});

console.log(response.text);

Basic Text Generation (Fetch)

const response = await fetch(
  `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent`,
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-goog-api-key': env.GEMINI_API_KEY,
    },
    body: JSON.stringify({
      contents: [
        {
          parts: [
            { text: 'Write a haiku about artificial intelligence' }
          ]
        }
      ]
    }),
  }
);

const data = await response.json();
console.log(data.candidates[0].content.parts[0].text);

Response Structure

{
  text: string,                  
how to use google-gemini-api

How to use google-gemini-api on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add google-gemini-api
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/jezweb/claude-skills --skill google-gemini-api

The skills CLI fetches google-gemini-api from GitHub repository jezweb/claude-skills and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/google-gemini-api

Reload or restart Cursor to activate google-gemini-api. Access the skill through slash commands (e.g., /google-gemini-api) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

Task Automation & Efficiency

Automate repetitive workflows and reduce manual effort

Example

Generate reports, summarize documents, draft communications

Save 3-5 hours per week on routine tasks

Knowledge Enhancement

Learn new skills, understand complex topics, get expert guidance

Example

Explain concepts, provide examples, suggest learning resources

Accelerate learning and skill development by 2x

Quality Improvement

Enhance output quality through reviews, suggestions, and refinements

Example

Review drafts, suggest improvements, catch errors

Improve work quality by 30-40% with less effort

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client with skill support
  • Clear understanding of task or problem to solve
  • Willingness to iterate and refine outputs

Time Estimate

15-45 minutes depending on use case complexity

Installation Steps

  1. 1.Install skill using provided installation command
  2. 2.Test with simple use case relevant to your work
  3. 3.Evaluate output quality and relevance
  4. 4.Iterate on prompts to improve results
  5. 5.Integrate into regular workflow if valuable

Common Pitfalls

  • Expecting perfect results without iteration
  • Not providing enough context in prompts
  • Using skill for tasks outside its intended scope
  • Accepting outputs without review and validation

Best Practices

✓ Do

  • +Start with clear, specific prompts
  • +Provide relevant context and constraints
  • +Review and refine all outputs before using
  • +Iterate to improve output quality
  • +Document successful prompt patterns

✗ Don't

  • Don't use without understanding skill limitations
  • Don't skip validation of outputs
  • Don't share sensitive information in prompts
  • Don't expect skill to replace human judgment

💡 Pro Tips

  • Be specific about desired format and style
  • Ask for multiple options to choose from
  • Request explanations to understand reasoning
  • Combine AI efficiency with human expertise

When to Use This

✓ Use When

Use when skill capabilities match your task, clear ROI on time saved, and you can validate outputs. Best for repetitive tasks, learning, and quality improvement.

✗ Avoid When

Avoid when task requires deep expertise you can't validate, involves sensitive decisions, or when learning process is more valuable than speed of completion.

Learning Path

  1. 1Familiarize yourself with skill capabilities and limitations
  2. 2Start with low-risk, non-critical tasks
  3. 3Progress to more complex and valuable use cases
  4. 4Build expertise through regular use and experimentation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.673 reviews
  • Meera Chawla· Dec 16, 2024

    Keeps context tight: google-gemini-api is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Hassan Kim· Dec 12, 2024

    google-gemini-api fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Kofi Farah· Dec 12, 2024

    google-gemini-api has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Harper Robinson· Dec 8, 2024

    Registry listing for google-gemini-api matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Ganesh Mohane· Dec 4, 2024

    google-gemini-api is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Harper Tandon· Dec 4, 2024

    Useful defaults in google-gemini-api — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Harper Verma· Nov 27, 2024

    google-gemini-api reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Hassan Huang· Nov 27, 2024

    I recommend google-gemini-api for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Sakshi Patil· Nov 23, 2024

    google-gemini-api fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Michael Khanna· Nov 23, 2024

    We added google-gemini-api from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

showing 1-10 of 73

1 / 8