Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when integrating Google Gemini API into projects. Covers model selection, multimodal inputs, streaming, function calling, and production best practices.
.claude/skills/lingxling-gemini-api-integration/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 49% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 16% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 59% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 61% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 40% | 0% |
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.
Node.js / TypeScript:
bashnpm install @google/generative-ai
Python:
bashpip install google-generativeai
Set your API key securely:
bashexport GEMINI_API_KEY="your-api-key-here"
Node.js:
javascriptimport { 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:
pythonimport 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)
javascriptconst result = await model.generateContentStream("Write a detailed blog post about AI"); for await (const chunk of result.stream) { process.stdout.write(chunk.text()); }
javascriptimport 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());
javascriptconst 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 }
javascriptconst 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());
| 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 |
gemini-1.5-flash for most tasks — it's fast and cost-effectivesystemInstruction to set persistent model behaviorgemini-pro for simple tasks — Flash is cheaper and fasterjavascripttry { const result = await model.generateContent(prompt); return result.response.text(); } catch (error) { if (error.status === 429) { // Rate limited — wait and retry with exponential backoff await new Promise(r => setTimeout(r, 2 ** retryCount * 1000)); } else if (error.status === 400) { // Invalid request — check prompt or parameters console.error("Invalid request:", error.message); } else { throw error; } }
Problem: API_KEY_INVALID error Solution: Ensure GEMINI_API_KEY environment variable is set and the key is active in Google AI Studio.
Problem: Response blocked by safety filters Solution: Check result.response.promptFeedback.blockReason and adjust your prompt or safety settings.
Problem: Slow response times Solution: Switch to gemini-1.5-flash and enable streaming. Consider caching repeated prompts.
Problem: RESOURCE_EXHAUSTED (quota exceeded) Solution: Check your quota in Google Cloud Console. Implement request queuing and exponential backoff.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 15,979 | 21,120 | +32% | 1 | 1 | 0% | 2,480 | 3,704 | +49% | 0 | 0 | — |
case-02 | fail→pass | 22,056 | 16,040 | -27% | 1 | 1 | 0% | 3,544 | 4,103 | +16% | 0 | 0 | — |
case-03 | fail→pass | 15,342 | 22,047 | +44% | 1 | 1 | 0% | 2,894 | 4,594 | +59% | 0 | 0 | — |
case-04 | fail→fail | 16,117 | 14,334 | -11% | 1 | 1 | 0% | 2,882 | 4,238 | +47% | 0 | 0 | — |
case-05 | fail→pass | 17,945 | 19,379 | +8% | 1 | 1 | 0% | 2,816 | 4,528 | +61% | 0 | 0 | — |
case-06 | fail→pass | 20,808 | 14,693 | -29% | 1 | 1 | 0% | 3,130 | 4,379 | +40% | 0 | 0 | — |
case-07 | fail→pass | 7,433 | 5,080 | -32% | 1 | 1 | 0% | 1,184 | 2,417 | +104% | 0 | 0 | — |
case-08 | pass→pass | 16,698 | 8,039 | -52% | 1 | 1 | 0% | 2,307 | 3,033 | +31% | 0 | 0 | — |
case-09 | pass→pass | 12,781 | 7,868 | -38% | 1 | 1 | 0% | 2,020 | 2,654 | +31% | 0 | 0 | — |
case-10 | pass→pass | 21,786 | 8,985 | -59% | 1 | 1 | 0% | 2,374 | 3,222 | +36% | 0 | 0 | — |
case-11 | fail→pass | 8,574 | 6,038 | -30% | 1 | 1 | 0% | 1,470 | 2,552 | +74% | 0 | 0 | — |
case-12 | pass→pass | 12,415 | 8,106 | -35% | 1 | 1 | 0% | 2,098 | 3,002 | +43% | 0 | 0 | — |
case-13 | pass→pass | 16,576 | 11,502 | -31% | 1 | 1 | 0% | 2,414 | 3,770 | +56% | 0 | 0 | — |
case-14 | pass→pass | 15,388 | 11,549 | -25% | 1 | 1 | 0% | 2,464 | 3,123 | +27% | 0 | 0 | — |
case-15 | pass→pass | 6,382 | 5,104 | -20% | 1 | 1 | 0% | 1,046 | 2,542 | +143% | 0 | 0 | — |
case-16 | fail→pass | 11,637 | 7,778 | -33% | 1 | 1 | 0% | 1,438 | 2,720 | +89% | 0 | 0 | — |
case-17 | pass→pass | 8,741 | 5,758 | -34% | 1 | 1 | 0% | 1,401 | 2,624 | +87% | 0 | 0 | — |
case-18 | pass→pass | 14,664 | 8,911 | -39% | 1 | 1 | 0% | 1,713 | 2,918 | +70% | 0 | 0 | — |
case-19 | fail→pass | 12,224 | 6,481 | -47% | 1 | 1 | 0% | 1,823 | 2,711 | +49% | 0 | 0 | — |
case-20 | pass→pass | 16,057 | 8,467 | -47% | 1 | 1 | 0% | 2,201 | 3,192 | +45% | 0 | 0 | — |
case-21 | pass→pass | 9,901 | 8,996 | -9% | 1 | 1 | 0% | 1,825 | 3,392 | +86% | 0 | 0 | — |
case-22 | fail→pass | 22,103 | 10,353 | -53% | 1 | 1 | 0% | 2,537 | 3,262 | +29% | 0 | 0 | — |
case-23 | pass→pass | 9,124 | 6,933 | -24% | 1 | 1 | 0% | 1,608 | 2,906 | +81% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +43 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.