Skip to content

feat: prompt caching support and fix per-key usage tracking - #1

Merged
semidark merged 2 commits into
mainfrom
opencode/shiny-comet
Apr 23, 2026
Merged

semidark merged 2 commits into
mainfrom
opencode/shiny-comet

Conversation

@semidark

Copy link
Copy Markdown
Owner
  • Add docs/PROMPT_CACHING.md: comprehensive guide with validated test results (93-97% cache hit rate on gpt-4.1), best practices, KQL monitoring queries, and cost impact analysis
  • Add infra/test-prompt-caching.sh: automated validation script that verifies prompt_cache_key and prompt_cache_retention work through the proxy
  • Fix infra/usage_callback.py: usage was being logged under the Azure provider API key hash instead of the client Bearer token hash. Switch to litellm_params.metadata.user_api_key (LiteLLM's internal hash of the client key) as the primary key identifier; retain _hash_key(kwargs[api_key]) only as last-resort fallback
  • Update scripts/usage-report.py: add Cached and Cache % columns to both key and model views; add --debug/-v flag to make KQL query output optional; remove duplicate code block; fix column index alignment; fix cost field key (CostNorm -> Cost)
  • Update README, docs/ARCHITECTURE.md, docs/DEPLOYMENT_SUMMARY.md, docs/USAGE_ANALYSIS.md with prompt caching guidance and cache hit rate KQL queries

Nico Thomaier added 2 commits April 23, 2026 12:55
- Add docs/PROMPT_CACHING.md: comprehensive guide with validated test
  results (93-97% cache hit rate on gpt-4.1), best practices, KQL
  monitoring queries, and cost impact analysis
- Add infra/test-prompt-caching.sh: automated validation script that
  verifies prompt_cache_key and prompt_cache_retention work through
  the proxy
- Fix infra/usage_callback.py: usage was being logged under the Azure
  provider API key hash instead of the client Bearer token hash.
  Switch to litellm_params.metadata.user_api_key (LiteLLM's internal
  hash of the client key) as the primary key identifier; retain
  _hash_key(kwargs[api_key]) only as last-resort fallback
- Update scripts/usage-report.py: add Cached and Cache % columns to
  both key and model views; add --debug/-v flag to make KQL query
  output optional; remove duplicate code block; fix column index
  alignment; fix cost field key (CostNorm -> Cost)
- Update README, docs/ARCHITECTURE.md, docs/DEPLOYMENT_SUMMARY.md,
  docs/USAGE_ANALYSIS.md with prompt caching guidance and cache hit
  rate KQL queries
@semidark
semidark merged commit 55a73ea into main Apr 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant