Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Prompt Caching — Cut Your API Costs in Go

Video #08 — Claude API in Go Series
Publish date: 2026-07-20
Type: Lightweight
Est. duration: ~16 min

What we cover

  • How prompt caching works and when it applies
  • Adding cache_control: ephemeral to system prompt blocks
  • Reading CacheReadInputTokens from the usage object
  • Real token-count comparisons: cached vs uncached calls
  • Caching conversation prefixes and large documents

Prerequisites

  • Go 1.23+
  • An Anthropic API key
  • Familiarity with episodes 01–02 (completions and system prompts)

Running the example

cd 08-prompt-caching
export ANTHROPIC_API_KEY=your_key_here
go run main.go

Project structure

.
├── README.md
├── go.mod
├── go.sum
└── main.go