Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Optimize Gamma API performance and reduce latency. Use when experiencing slow response times, optimizing throughput, or improving user experience with Gamma integrations. Trigger with phrases like "gamma performance", "gamma slow", "gamma latency", "gamma optimization", "gamma speed".
.claude/skills/jeremylongshore-gamma-performance-tuning/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 36% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 67% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 7% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 130% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 43% | 0% |
Optimize Gamma API integration performance. Gamma's generate-poll-retrieve pattern means most latency is in generation time (10-60s), not API call overhead. Optimize by: reducing poll overhead, parallelizing batch operations, caching results, and choosing the right generation parameters.
gamma-sdk-patterns)| Operation | Typical Latency | Notes | |-----------|----------------|-------| | POST /generations | 200-500ms | Just starts the generation | | GET /generations/{id} (poll) | 100-300ms | Per poll request | | Full generation (poll to completion) | 10-60s | Depends on content + cards | | GET /themes | 100-200ms | Cacheable | | GET /folders | 100-200ms | Cacheable |
typescript// src/gamma/smart-poll.ts // Adaptive polling: start fast, slow down over time export async function smartPoll( gamma: GammaClient, generationId: string, opts = { maxTimeMs: 180000 } ): Promise<GenerateResult> { const deadline = Date.now() + opts.maxTimeMs; let interval = 2000; // Start at 2s while (Date.now() < deadline) { const result = await gamma.poll(generationId); if (result.status === "completed") return result; if (result.status === "failed") throw new Error("Generation failed"); // Adaptive backoff: poll faster early, slower later await new Promise((r) => setTimeout(r, interval)); interval = Math.min(interval * 1.5, 10000); // Max 10s between polls } throw new Error(`Poll timeout after ${opts.maxTimeMs}ms`); }
typescript// src/gamma/cache.ts import NodeCache from "node-cache"; const cache = new NodeCache({ stdTTL: 3600 }); // 1 hour for static data export async function getCachedThemes(gamma: GammaClient) { const key = "gamma:themes"; const cached = cache.get(key); if (cached) return cached; const themes = await gamma.listThemes(); cache.set(key, themes); return themes; } export async function getCachedFolders(gamma: GammaClient) { const key = "gamma:folders"; const cached = cache.get(key); if (cached) return cached; const folders = await gamma.listFolders(); cache.set(key, folders); return folders; } // Cache generation results (useful for showing status) export async function cacheGenerationResult( generationId: string, result: GenerateResult ) { cache.set(`gamma:gen:${generationId}`, result, 86400); // 24 hours }
typescript// src/gamma/batch.ts import pLimit from "p-limit"; const limit = pLimit(3); // Max 3 concurrent generations export async function batchGenerate( gamma: GammaClient, requests: Array<{ content: string; exportAs?: string }> ): Promise<Array<{ index: number; result?: GenerateResult; error?: string }>> { const results = await Promise.allSettled( requests.map((req, index) => limit(async () => { const { generationId } = await gamma.generate({ content: req.content, outputFormat: "presentation", exportAs: req.exportAs, }); const result = await smartPoll(gamma, generationId); return { index, result }; }) ) ); return results.map((r, i) => { if (r.status === "fulfilled") return r.value; return { index: i, error: (r.reason as Error).message }; }); }
typescript// Shorter content = faster generation // "brief" text = fewer AI-generated words per card = faster // SLOWER: extensive text on many cards await gamma.generate({ content: "Comprehensive 20-card guide to machine learning...", outputFormat: "presentation", textAmount: "extensive", // More text per card = slower }); // FASTER: brief text, fewer implied cards await gamma.generate({ content: "5-card overview of ML basics: supervised, unsupervised, reinforcement, deep learning, applications", outputFormat: "presentation", textAmount: "brief", // Less text per card = faster }); // FASTEST: preserve mode (no AI text generation) await gamma.generate({ content: "Your pre-written slide content here...", outputFormat: "presentation", textMode: "preserve", // Uses your text as-is, no AI rewriting });
typescript// src/gamma/preload.ts // Fetch themes and folders at app startup, not per-request let preloaded = false; export async function preloadGammaData(gamma: GammaClient) { if (preloaded) return; const [themes, folders] = await Promise.all([ gamma.listThemes(), gamma.listFolders(), ]); // Cache for the session cache.set("gamma:themes", themes, 0); // No TTL (until restart) cache.set("gamma:folders", folders, 0); preloaded = true; console.log(`Preloaded ${themes.length} themes, ${folders.length} folders`); }
typescript// src/gamma/optimized-client.ts import http from "node:http"; import https from "node:https"; // Reuse TCP connections const agent = new https.Agent({ keepAlive: true, maxSockets: 10, keepAliveMsecs: 60000, }); export function createOptimizedClient(apiKey: string) { const base = "https://public-api.gamma.app/v1.0"; const headers = { "X-API-KEY": apiKey, "Content-Type": "application/json" }; async function request(method: string, path: string, body?: unknown) { const res = await fetch(`${base}${path}`, { method, headers, body: body ? JSON.stringify(body) : undefined, // @ts-ignore — agent support in Node.js agent, }); if (!res.ok) throw new Error(`Gamma ${res.status}`); return res.json(); } return { generate: (body: any) => request("POST", "/generations", body), poll: (id: string) => request("GET", `/generations/${id}`), listThemes: () => request("GET", "/themes"), listFolders: () => request("GET", "/folders"), }; }
| Operation | Target | Action if Exceeded | |-----------|--------|-------------------| | Theme/folder lookup | < 50ms (cached) | Verify cache hit | | Generation start | < 500ms | Check network latency | | Full generation (5 cards) | < 30s | Use textAmount: "brief" | | Full generation (10+ cards) | < 60s | Split into smaller decks | | Batch of 10 presentations | < 3 min | Use concurrency limit of 3 |
| Issue | Cause | Solution | |-------|-------|----------| | High latency on first request | Cold TCP connection | Use keep-alive agent | | Cache miss storm | Cache expired simultaneously | Stagger TTLs | | Batch rate limiting | Too many concurrent requests | Reduce p-limit concurrency | | Poll timeout | Complex generation | Increase timeout, simplify content |
Proceed to gamma-cost-tuning for credit optimization.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 25,011 | 20,632 | -18% | 1 | 1 | 0% | 4,036 | 5,483 | +36% | 0 | 0 | — |
case-02 | fail→pass | 20,781 | 14,579 | -30% | 1 | 1 | 0% | 3,145 | 5,244 | +67% | 0 | 0 | — |
case-03 | fail→fail | 20,261 | 18,393 | -9% | 1 | 1 | 0% | 3,274 | 5,023 | +53% | 0 | 0 | — |
case-04 | fail→pass | 21,825 | 7,217 | -67% | 1 | 1 | 0% | 3,269 | 3,506 | +7% | 0 | 0 | — |
case-05 | pass→pass | 11,879 | 5,070 | -57% | 1 | 1 | 0% | 1,942 | 2,963 | +53% | 0 | 0 | — |
case-06 | fail→pass | 11,884 | 9,581 | -19% | 1 | 1 | 0% | 1,236 | 2,839 | +130% | 0 | 0 | — |
case-07 | fail→pass | 16,578 | 8,586 | -48% | 1 | 1 | 0% | 1,760 | 2,525 | +43% | 0 | 0 | — |
case-08 | fail→pass | 10,744 | 3,675 | -66% | 1 | 1 | 0% | 1,759 | 2,681 | +52% | 0 | 0 | — |
case-09 | fail→fail | 19,781 | 13,564 | -31% | 1 | 1 | 0% | 2,498 | 4,418 | +77% | 0 | 0 | — |
case-10 | fail→pass | 8,755 | 7,744 | -12% | 1 | 1 | 0% | 1,517 | 2,503 | +65% | 0 | 0 | — |
case-11 | pass→pass | 14,434 | 6,634 | -54% | 1 | 1 | 0% | 1,778 | 2,246 | +26% | 0 | 0 | — |
case-12 | pass→pass | 9,649 | 5,404 | -44% | 1 | 1 | 0% | 1,567 | 2,874 | +83% | 0 | 0 | — |
case-13 | pass→pass | 11,136 | 8,602 | -23% | 1 | 1 | 0% | 1,963 | 3,486 | +78% | 0 | 0 | — |
case-14 | pass→pass | 10,712 | 2,992 | -72% | 1 | 1 | 0% | 1,771 | 2,488 | +40% | 0 | 0 | — |
case-15 | fail→pass | 15,101 | 3,404 | -77% | 1 | 1 | 0% | 1,755 | 2,647 | +51% | 0 | 0 | — |
case-16 | pass→pass | 15,217 | 11,548 | -24% | 1 | 1 | 0% | 1,801 | 3,303 | +83% | 0 | 0 | — |
case-17 | pass→pass | 10,777 | 9,997 | -7% | 1 | 1 | 0% | 2,094 | 4,209 | +101% | 0 | 0 | — |
case-18 | pass→pass | 13,612 | 9,076 | -33% | 1 | 1 | 0% | 1,589 | 2,881 | +81% | 0 | 0 | — |
case-19 | fail→fail | 8,635 | 7,579 | -12% | 1 | 1 | 0% | 1,754 | 3,644 | +108% | 0 | 0 | — |
case-20 | fail→fail | 20,219 | 22,247 | +10% | 1 | 1 | 0% | 2,968 | 5,681 | +91% | 0 | 0 | — |
case-21 | pass→pass | 17,038 | 18,722 | +10% | 1 | 1 | 0% | 2,854 | 5,407 | +89% | 0 | 0 | — |
case-22 | pass→pass | 12,860 | 16,406 | +28% | 1 | 1 | 0% | 2,235 | 4,358 | +95% | 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. 22 cases were attempted. The headline lift of +36 percentage points is the difference between those two pass rates over the 22 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.