gemini-api-caching

Community

Optimize Gemini API calls, reduce costs and latency.

AuthorBerryKuipers
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Repeated, unoptimized calls to the Gemini API can incur high costs and introduce significant latency, degrading user experience. This Skill provides best practices for implementing robust caching strategies.

Core Features & Use Cases

  • Cache Versioning: Implements a global cache version constant for instant, project-wide cache invalidation when underlying models or prompts change.
  • Entity-Stable Keys: Guides the creation of cache keys based on stable entities (e.g., character-portrait:<id>) to prevent unnecessary cache busts from minor prompt tweaks.
  • Cache Read/Write Logic: Provides patterns for checking, storing, and retrieving cached content efficiently.
  • Use Case: When generating AI-powered content like character portraits or world images, use this Skill to ensure content is served from cache whenever possible, drastically reducing API calls and improving performance.

Quick Start

Example: Get a character portrait, using cache or generating new

const CACHE_VERSION = 'v2';

const getCacheKey = (entity, id) => ${CACHE_VERSION}-${entity}:${id};

async function getCharacterPortrait(character) {

const cacheKey = getCacheKey('character-portrait', character.id);

const cached = localStorage.getItem(cacheKey);

if (cached) {

console.log(✅ Cache hit: ${cacheKey});

return cached;

}

console.log(⚠️ Cache miss: ${cacheKey});

const imageUrl = await generateNewPortrait(character);

localStorage.setItem(cacheKey, imageUrl);

return imageUrl;

}

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: gemini-api-caching
Download link: https://github.com/BerryKuipers/claude-code-toolkit/archive/main.zip#gemini-api-caching

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository