agentleFS
kumaran-iskumaran-is/claude-code-onboarding/.claude/skills/gemini-api-dev/SKILL.md

gemini-api-dev

Skill36 starsChanged 6 months agoMITView on GitHub

Direct Gemini API development with google-genai (Python) and @google/genai (TypeScript). Use when building multimodal applications, function calling, structured output, context caching, embeddings, or code execution with Gemini models — without the ADK framework overhead.

  • Reads credentials
  • Installs packages

5 other projects use a version of this, 3 of them edited.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Invalid API key (401): Check GOOGLE_API_KEY env var — never hardcode keys.

    line 125
  2. Very specific:

    Model not found: Verify model ID against models.md.txt — model names change between releases.

    line 126
  3. Distinctive:

    Payload too large: Check 2MB limit for inline data.

    line 127
  4. Distinctive:

    After writing Gemini API integration code, dispatch:

    line 148

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Iron Law

ALWAYS FETCH CURRENT API DOCS BEFORE WRITING CODE — fetch https://ai.google.dev/gemini-api/docs/llms.txt first, then the specific capability page. Never generate Gemini API calls from memory; the API evolves rapidly.

Gemini API Development — Direct API (google-genai / @google/genai)

When to Use This Skill vs google-adk

Use CaseThis Skillgoogle-adk skill
Direct model API calls✅❌
Multimodal (image/audio/video)✅Partial
Embeddings API✅❌
Context caching✅❌
Code execution sandbox✅❌
Building structured AI agents❌✅
Session management / memory❌✅
Multi-agent orchestration❌✅

Current Models (as of 2026-03-15)

  • gemini-3.1-flash — 1M tokens, fast, balanced, multimodal. Default for most tasks.
  • gemini-3.1-pro — 1M tokens, complex reasoning, coding, research
  • gemini-3.1-pro-image — Image generation and editing

Legacy models are deprecated: gemini-2.5-*, gemini-2.0-*, gemini-1.5-* — do not use.

SDKs

  • Python: google-genai — uv add google-genai
  • TypeScript/NestJS: @google/genai — npm install @google/genai

Legacy SDKs are deprecated: google-generativeai (Python) and @google/generative-ai (JS) — do not use.

Quick Start

Python

from google import genai

client = genai.Client()  # uses GOOGLE_API_KEY env var
response = client.models.generate_content(
    model="gemini-3.1-flash",
    contents="Explain quantum computing"
)
print(response.text)

TypeScript (NestJS)

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

const ai = new GoogleGenAI({});  // uses GOOGLE_API_KEY env var
const response = await ai.models.generateContent({
  model: "gemini-3.1-flash",
  contents: "Explain quantum computing"
});
console.log(response.text);

Key Capabilities

CapabilityWhen to UseDoc Page
Text generationChat, completion, summarizationtext-generation.md.txt
MultimodalProcess images, audio, video, documentsimage-understanding.md.txt
Function callingLet the model invoke your functionsfunction-calling.md.txt
Structured outputGenerate valid JSON matching schemastructured-output.md.txt
Code executionRun Python in sandboxed environmentfetch from llms.txt
Context cachingCache large contexts for cost efficiencyfetch from llms.txt
EmbeddingsSemantic search, similarityembeddings.md.txt

Documentation Sources

Always fetch before writing code — the Gemini API evolves rapidly; never rely on memory.

SourceURLPurpose
Doc indexhttps://ai.google.dev/gemini-api/docs/llms.txtDiscover all available doc pages
Modelshttps://ai.google.dev/gemini-api/docs/models.md.txtCurrent model IDs and capabilities
Function callinghttps://ai.google.dev/gemini-api/docs/function-calling.md.txtTool use patterns
Structured outputhttps://ai.google.dev/gemini-api/docs/structured-output.md.txtJSON schema output
Embeddingshttps://ai.google.dev/gemini-api/docs/embeddings.md.txtEmbedding API
Text generationhttps://ai.google.dev/gemini-api/docs/text-generation.md.txtGeneration parameters
Image understandinghttps://ai.google.dev/gemini-api/docs/image-understanding.md.txtMultimodal inputs
SDK migrationhttps://ai.google.dev/gemini-api/docs/migrate.md.txtMigrate from legacy SDKs
REST API spechttps://generativelanguage.googleapis.com/$discovery/rest?version=v1betaAuthoritative API schema

Common Commands

# Python setup
uv add google-genai

# TypeScript setup
npm install @google/genai

# Set API key (get from Google AI Studio: aistudio.google.com)
export GOOGLE_API_KEY=your_key_here

# Verify SDK version
python -c "import google.genai; print(google.genai.__version__)"
node -e "const {GoogleGenAI}=require('@google/genai'); console.log('ok')"

Error Handling

Fetch https://ai.google.dev/gemini-api/docs/error-codes.md.txt for current error code reference.

Rate limits (429): Implement exponential backoff — do not retry immediately. Invalid API key (401): Check GOOGLE_API_KEY env var — never hardcode keys. Model not found: Verify model ID against models.md.txt — model names change between releases. Payload too large: Check 2MB limit for inline data; use File API for larger inputs.

# Python — retry with backoff on rate limit
import time
from google.api_core import retry
from google import genai

client = genai.Client()

@retry.Retry(predicate=retry.if_transient_error)
def generate_with_retry(prompt: str) -> str:
    response = client.models.generate_content(
        model="gemini-3.1-flash",
        contents=prompt,
    )
    return response.text

Post-Code Review

After writing Gemini API integration code, dispatch:

  • security-reviewer — API key handling, no keys in code, input sanitization before sending to model
  • code-reviewer — general quality, error handling completeness

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.