gemini-api-integration
What it does
This tool helps you connect your computer programs with Google Gemini's artificial intelligence. It teaches how to make Gemini understand and respond to text, images, and even audio/video, and allows it to perform specific actions.
When to use it
- βWhen starting to use Gemini in a new project.
- βWhen you want your program to understand images or audio.
- βTo make Gemini respond faster or perform specific tasks.
Skill link
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/gemini-api-integration/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βHow do I connect Gemini so it can answer questions about images?β
5 new skills a week. 1 minute to read.
How it works
You add special code to your program that communicates with the Gemini API. This code selects the right model, sends the data (text, image, etc.), and receives the response.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Gemini API Integration
Overview
This skill guides AI agents through integrating Google Gemini API into applications β from basic text generation to advanced multimodal, function calling, and streaming use cases. It covers the full Gemini SDK lifecycle with production-grade patterns.
When to Use This Skill
- Use when setting up Gemini API for the first time in a Node.js, Python, or browser project
- Use when implementing multimodal inputs (text + image/audio/video)
- Use when adding streaming responses to improve perceived latency
- Use when implementing function calling / tool use with Gemini
- Use when optimizing model selection (Flash vs Pro vs Ultra) for cost and performance
- Use when debugging Gemini API errors, rate limits, or quota issues
Step-by-Step Guide
1. Installation & Setup
Node.js / TypeScript:
npm install @google/generative-ai
Python:
pip install google-generativeai
Set your API key securely:
read -rsp "Gemini API key: " GEMINI_API_KEY
echo
export GEMINI_API_KEY
2. Basic Text Generation
Node.js:
import { GoogleGenerativeAI } from "@google/generative-ai";
const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash" });
const result = await model.generateContent("Explain async/await in JavaScript");
console.log(result.response.text());
Python:
import google.generativeai as genai
import os
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
model = genai.GenerativeModel("gemini-1.5-flash")
response = model.generate_content("Explain async/await in JavaScript")
print(response.text)
3. Streaming Responses
const result = await model.generateContentStream("Write a detailed blog post about AI");
for await (const chunk of result.stream) {
process.stdout.write(chunk.text());
}
4. Multimodal Input (Text + Image)
import fs from "fs";
const imageData = fs.readFileSync("screenshot.png");
const imagePart = {
inlineData: {
data: imageData.toString("base64"),
mimeType: "image/png",
},
};
const result = await model.generateContent(["Describe this image:", imagePart]);
console.log(result.response.text());
5. Function Calling / Tool Use
const tools = [{
functionDeclarations: [{
name: "get_weather",
description: "Get current weather for a city",
parameters: {
type: "OBJECT",
properties: {
city: { type: "STRING", description: "City name" },
},
required: ["city"],
},
}],
}];
const model = genAI.getGenerativeModel({ model: "gemini-1.5-pro", tools });
const result = await model.generateContent("What's the weather in Mumbai?");
const call = result.response.functionCalls()?.[0];
if (call) {
// Execute the actual function
const weatherData = await getWeather(call.args.city);
// Send result back to model
}
6. Multi-turn Chat
const chat = model.startChat({
history: [
{ role: "user", parts: [{ text: "You are a helpful coding assistant." }] },
{ role: "model", parts: [{ text: "Sure! I'm ready to help with code." }] },
],
});
const response = await chat.sendMessage("How do I reverse a string in Python?");
console.log(response.response.text());
7. Model Selection Guide
| Model | Best For | Speed | Cost |
|---|---|---|---|
gemini-1.5-flash |
High-throughput, cost-sensitive tasks | Fast | Low |
gemini-1.5-pro |
Complex reasoning, long context | Medium | Medium |
gemini-2.0-flash |
Latest fast model, multimodal | Very Fast | Low |
gemini-2.0-pro |
Most capable, advanced tasks | Slow | High |
Best Practices
- β
Do: Use
gemini-1.5-flashfor most tasks β it's fast and cost-effective - β Do: Always stream responses for user-facing chat UIs to reduce perceived latency
- β Do: Store API keys in environment variables, never hard-code them
- β Do: Implement exponential backoff for rate limit (429) errors
- β
Do: Use
systemInstructionto set persistent model behavior - β Don't: Use
gemini-profor simple tasks β Flash is cheaper and faster - β Don't: Send large base64 images inline for files > 20MB β use File API instead
- β Don't: Ignore safety ratings in responses for production apps
Error Handling
try {
const result = await model.generateContent(prompt);
β¦
FAQ
What's the difference between Flash, Pro, and Ultra models?
Flash is faster and cheaper for simple tasks. Pro is good for complex reasoning. Ultra is the most advanced, but can be slower and more expensive.
What is 'streaming'?
It's when the AI's response arrives piece by piece, instead of waiting for everything to be ready. This makes it seem like the AI responded faster.
What is 'function calling'?
It's a way to teach the AI to use specific tools or functions within your program, like looking up the weather for a city.
Details
Original description by the author
Use when integrating Google Gemini API into projects. Covers model selection, multimodal inputs, streaming, function calling, and production best practices.
Popularity
- GitHub stars
- 48k
- Ranking position
- #4707
- License
- MIT
- Updated
- 10/15/2026
Comments
- β¦
More skills from this repository
00-andruia-consultant
48kHelps your agent start or improve AI projects. It analyzes code, suggests tools, and creates action plans in Spanish.
007
48kLets your agent perform security audits and threat modeling. It's useful for protecting projects against attacks and vulnerabilities.
10-andruia-skill-smith
48kHelps your agent create or improve AI tools. It defines how tools work, writes documentation, and validates the structure.
20-andruia-niche-intelligence
48kLets your agent create a summary about a specific industry. It's useful for understanding the context, rules, usage patterns, and risks of a project, using reliable sources.
Similar skills
add-model-provider
394kLets your agent connect a new AI model provider to OpenClaw using safe setup commands, keep API keys out of plain text, and run a live test.
acp-router
394kHelps your agent send a task to a coding assistant such as Claude Code or Cursor through OpenClaw, so the work runs in that tool.
browser-automation
394kTeaches your agent to control web pages step by step, including logins, tabs, and recovery when a page stops responding.