gemini-api-integration
하는 일
이 도구는 프로그램을 Google Gemini의 인공지능과 연결하는 데 도움을 줍니다. Gemini가 텍스트, 이미지, 심지어 오디오와 비디오를 이해하고 응답하도록 만드는 방법과, 특정 작업을 수행하게 하는 방법을 알려 줍니다.
사용하는 경우
- ✓새 프로젝트에서 Gemini를 사용하기 시작할 때.
- ✓프로그램이 이미지나 오디오를 이해하게 하고 싶을 때.
- ✓Gemini가 더 빠르게 응답하거나 특정 작업을 수행하도록 만들 때.
스킬 링크
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/gemini-api-integration/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“Gemini가 이미지에 관한 질문에 답할 수 있도록 연결하려면 어떻게 해야 하나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
Gemini API와 통신하는 특별한 코드를 프로그램에 추가합니다. 이 코드는 알맞은 모델을 고르고, 데이터(텍스트, 이미지 등)를 보내고, 응답을 받습니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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);
…
자주 묻는 질문
Flash, Pro, Ultra 모델은 어떻게 다른가요?
Flash는 간단한 작업에 더 빠르고 저렴합니다. Pro는 복잡한 추론에 좋습니다. Ultra는 가장 고급이지만 더 느리고 비쌀 수 있습니다.
「스트리밍」이란 무엇인가요?
AI의 응답이 모두 준비될 때까지 기다리지 않고 조금씩 나뉘어 도착하는 방식입니다. 그래서 AI가 더 빨리 응답하는 것처럼 느껴집니다.
「함수 호출」이란 무엇인가요?
AI가 프로그램 안의 특정 도구나 함수를 사용하도록 가르치는 방법입니다. 예를 들어 도시의 날씨를 조회하는 식입니다.
상세 정보
작성자의 원본 설명
Use when integrating Google Gemini API into projects. Covers model selection, multimodal inputs, streaming, function calling, and production best practices.
인기도
- GitHub 스타
- 48k
- 순위
- #4707
- 라이선스
- MIT
- 업데이트
- 2026. 10. 15.
댓글
- …
이 저장소의 다른 스킬
00-andruia-consultant
48k에이전트가 AI 프로젝트를 시작하거나 개선할 수 있도록 코드를 분석하고 스페인어로 실행 계획을 세워 줍니다.
007
48k에이전트가 보안 감사와 위협 모델링을 수행해 공격과 취약점으로부터 프로젝트를 보호하도록 돕습니다.
10-andruia-skill-smith
48k에이전트가 AI 도구의 작동 방식을 정의하고 문서를 쓰며 구조를 검증하도록 돕습니다.
20-andruia-niche-intelligence
48k에이전트가 신뢰할 수 있는 자료를 바탕으로 특정 산업의 맥락, 규칙, 사용 패턴, 위험을 정리한 요약을 만들도록 돕습니다.
비슷한 스킬
add-model-provider
394k에이전트가 안전한 설정 명령으로 새 AI 모델 제공자를 OpenClaw에 연결하고, API 키를 평문으로 두지 않으며, 실시간 테스트를 실행하도록 돕습니다.
acp-router
394k에이전트가 OpenClaw를 통해 Claude Code나 Cursor 같은 코딩 도우미에 작업을 전달해, 작업이 그 도구에서 실행되도록 돕습니다.
browser-automation
394k에이전트가 로그인, 탭, 페이지 응답이 멈췄을 때의 복구를 포함해 웹 페이지를 단계별로 조작하도록 가르칩니다.