본문으로 건너뛰기
Skillpedia
에이전트48k · #4707

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가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/gemini-api-integration/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

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-flash for 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 systemInstruction to set persistent model behavior
  • ❌ Don't: Use gemini-pro for 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.

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#4707
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬