Capabilities
Prompt Caching
Reusing KV cache for repeated prefixes — TTL, breakpoints, session affinity
Read this when
- Optimizing cost / latency for repeat prefixes
- Adding caching to a new provider
See also the design-level concept doc at docs/concepts/ai/caching.md. pi-go controls caching with StreamOptions.CacheRetention (none, short, long) and a SessionID for affinity.
Compatibility
| Provider | API | pi-go | Notes |
|---|---|---|---|
| Anthropic | ✅ cache_control markers; 5m default + 1h ttl (extended TTL beta); up to 4 breakpoints | ⚠️ | terminal auto-breakpoint only (cache.go:50-74); 1h only on api.anthropic.com (cache.go:29-30) |
| OpenAI Chat | ✅ automatic; prompt_cache_key for affinity | ✅ | session ID forwarded (openai.go:323-326) |
| OpenAI Responses | ✅ automatic | ✅ | session ID forwarded (openairesponses.go:339-340) |
| Google Gemini | ✅ context caching API | ❌ | not wired |
| Claude CLI | ⚠️ session-level KV | ❌ |
Provider Documentation
pi-go Gaps
- Manual breakpoints for Anthropic (system prompt, tool definitions, prior turns) — pi-go places exactly one terminal marker.
- Google context caching not implemented at all (no
cachedContentreference). - Cache hit metrics for OpenAI Chat are not surfaced — streaming
usagecollapses to a singleTotalTokensfield (openai.go:94). - Anthropic cache write tier — pi-go does not let callers choose 1h cache writes selectively (it’s tied to
CacheRetention).