Skip to content

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

ProviderAPIpi-goNotes
Anthropiccache_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 affinitysession ID forwarded (openai.go:323-326)
OpenAI Responses✅ automaticsession ID forwarded (openairesponses.go:339-340)
Google Gemini✅ context caching APInot 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 cachedContent reference).
  • Cache hit metrics for OpenAI Chat are not surfaced — streaming usage collapses to a single TotalTokens field (openai.go:94).
  • Anthropic cache write tier — pi-go does not let callers choose 1h cache writes selectively (it’s tied to CacheRetention).