Agent skill · Backend & API

gemini-integration

Google Gemini API 集成指南:提供 AI 分析、提示词工程、流式响应和多模态处理的最佳实践。 Use when: 需要集成 Gemini API、编写提示词、处理流式响应、多模态输入。

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill gemini-integration --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 20 KB
Bundled scripts: none
Path: skills/ai-llm/gemini-integration/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

Review
written from the skill's own SKILL.md · Aug 5, 2026

What it does

Provides a standardized flow for integrating Google Gemini API, including AI analysis, prompt engineering, streaming responses, and multimodal input handling. It supports multiple tasks: analysis via Gemini, prompt design, streaming outputs, and multimodal inputs (text, images, documents). It includes examples for environment setup, client configuration, streaming, multimodal analyses (images and PDFs), multi-turn dialogues, structured JSON outputs, and error handling. The skill is intended for backend/API work and uses the claude-code tool in its declared tools.

How it works

  • Environment and client setup: shows environment variables (GEMINI_API_KEY) and how to configure Vercel envs. It provides a TypeScript-based Gemini client with getModel and getStreamingModel functions that set safety settings and generation config (temperature, topP, topK, maxOutputTokens).
  • Basic text generation: generateText(prompt) obtains a model from getModel(), calls generateContent, and returns result.response.text(); includes a GeminiError class for failures.
  • Streaming: generateStream(prompt, onChunk) uses getStreamingModel(), iterates over result.stream, concatenates chunks, and invokes onChunk for each piece; includes error handling with GeminiError.
  • Frontend streaming: useStreamingChat hook and StreamingMessage component illustrate consuming streaming data via ReadableStream and server-sent events-like data: data: { text } chunks, and data: [DONE] end signal.
  • Multimodal inputs: analyzeImage(imageBase64, mimeType, prompt) uses gemini-1.5-pro for vision tasks, constructing an imagePart with inlineData. analyzeImageFromUrl fetches image, converts to base64, then calls analyzeImage. Document analysis includes analyzePDF(pdfBase64, prompt) and analyzeMultipleFiles(files, prompt) using gemini-1.5-pro with multiple parts.
  • Multi-turn dialogue: createChatSession(systemPrompt) initializes a chat with optional system prompt, using startChat and history; sendMessage and sendMessageStream support both standard and streaming messages; getHistory returns formatted chat messages.
  • Structured output: generateJSON(prompt, schema) builds a structured prompt enforcing a JSON output according to a given schema, cleans markdown code blocks, and parses JSON; includes an example interface StockAnalysis and usage.
  • Error handling: GeminiError class is defined to capture message and cause (and later code hints at GeminiRateLimit in truncated portion).

When to use it

Use this skill when you need to:

  • integrate Google Gemini API for AI analysis
  • write and optimize prompts (prompt engineering)
  • implement streaming responses
  • handle multimodal inputs (text, images, documents)
  • build financial analysis AI features
  • implement multi-turn dialogue systems

What it can touch

  • Environment: GEMINI_API_KEY in .env.local and Vercel environment variables.
  • Code: TypeScript files under src/services/ai/* (gemini-client.ts, generate.ts, streaming.ts, vision.ts, document.ts, chat.ts), app/api/ai/stream/route.ts, useStreamingChat.ts, StreamingMessage.tsx, structured.ts, errors.ts.
  • Tools: declared tool is claude-code.

Caveats

  • Not for other LLM providers (OpenAI, Claude) or local model deployment or fine-tuning.
  • Uses gemini-2.0-flash by default; certain multimodal tasks use gemini-1.5-pro for vision and document tasks.
  • Error handling sections reference GeminiError and GeminiRateLimit (truncated in provided snippet), so implementers should refer to the complete file for full error definitions.
  • The skill relies on environment variable configuration and network access to Gemini API; behavior depends on API availability and token safety settings.
From the SKILL.md

# Gemini Integration (Google Gemini API 集成指南) > 🤖 **核心理念**: 标准化 Gemini API 集成流程,确保 AI 功能的可靠性、性能和用户体验。 ## When to Use This Skill 使用此技能当你需要: - 集成 Google Gemini API 进行 AI 分析 - 编写和优化提示词 (Prompt Engineering) - 实现流式响应 (Streaming Response) - 处理多模态输入 (文本、图片、文档) - 构建金融分析 AI 功能 - 实现多轮对话系统 ## Not For / Boundaries 此技能不适用于: - 其他 LLM 提供商 (OpenAI, Claude 等) - 本地模型部署 - 模型微调 (Fine-tuning) --- ## Quick Reference ### 🎯 Gemini 集成标准工作流 ``` 需求分析 → 模型选择 → 提示词设计 → API 集成 → 流式处理 → 测试验证 ↓ ↓ ↓ ↓ ↓ ↓ 场景定义 性能/成本 结构化输出 错误处理 用户体验 质量评估 ``` ### 📋 集成前必问清单 | 问题 | 目的 | |------|------| | 1. 使用哪个模型? | gemini-2.0-flash / gemini-1.5-pro | | 2. 需要流式响应吗? | 长文本生成建议流式 | | 3. 输入类型是什么? | 纯文本 / 图片 / 文档 | | 4. 输出格式要求? | 自由文本 / JSON / 结构化 | | 5. 上下文长度需求? | 影响模型选择和成本 | | 6. 安全过滤级别? | 金融场景需要适当配置 | ### 🔍 模型选择指南 | 模型 | 适用场景 | 特点 | |------|----------|------| | `gemini-2.0-flash` | 通用任务、快速响应 | 速度快、成本低 | | `gemini-1.5-pro` | 复杂分析、长上下文 | 能力强、上下文长 | | `gemini-1.5-flash` | 平衡性能和成本 | 中等速度和能力 | --- ## API 集成基础 ### 环境配置 ```bash # .env.local GEMINI_API_KEY=your_api_key_here # Vercel 环境变量同步 vercel env add GEMINI_API_KEY production vercel env add GEMINI_API_KEY preview ``` ### 基础客户端配置 ```typescript // src/services/ai/gemini-client.ts import

What's inside
Steps it walks through
  1. When to Use This Skill
  2. Not For / Boundaries
  3. Quick Reference
  4. 🎯 Gemini 集成标准工作流
  5. 📋 集成前必问清单
  6. 🔍 模型选择指南
  7. API 集成基础
  8. 环境配置
  9. 基础客户端配置
  10. 基础文本生成
  11. 流式响应处理
  12. 服务端流式生成
  13. API Route 流式响应
  14. 前端流式消费
Ships with 1 file
  • metadata.json
Commands it runs
Vercel 环境变量同步
vercel env add GEMINI_API_KEY production
vercel env add GEMINI_API_KEY preview
More from claude-skill-registry
All skills →
About this skill
What does the gemini-integration skill do?

Google Gemini API 集成指南:提供 AI 分析、提示词工程、流式响应和多模态处理的最佳实践。 Use when: 需要集成 Gemini API、编写提示词、处理流式响应、多模态输入。

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill gemini-integration --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going