ワンクリックで
clawcache-free
Smart LLM cost tracking and caching for Python
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Smart LLM cost tracking and caching for Python
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | ClawCache Free |
| description | Smart LLM cost tracking and caching for Python |
| version | 0.2.0 |
| author | ClawCache Team |
| category | Developer Tools |
| license | MIT |
ClawCache is a production-ready Python library that helps you track every penny spent on LLM APIs and automatically cache responses to slash costs.
Based on comprehensive simulation with 48 API calls across 4 common use cases:
| Metric | Value |
|---|---|
| Cache Hit Rate | 58.3% |
| Total Cost | $0.0062 |
| API Calls Saved | 28 out of 48 |
| Scenarios Tested | Code Review, Data Analysis, Content Generation, QA Support |
| Scenario | Calls | Cache Hits | Hit Rate |
|---|---|---|---|
| Code Review | 12 | 7 | 58.3% |
| Data Analysis | 12 | 8 | 66.7% |
| Content Generation | 12 | 7 | 58.3% |
| QA Support | 12 | 6 | 50.0% |
pip install clawcache
from clawcache.free.cost import async_monitor_cost
from clawcache.free.cache_basic import BasicCache
# Initialize cache
cache = BasicCache()
# Decorate your LLM function
@async_monitor_cost
async def my_llm_call(prompt, model="gpt-4-turbo"):
# Check cache first
cached = await cache.aget(prompt, model=model)
if cached:
return cached.content
# Make actual API call
response = await openai.ChatCompletion.acreate(
model=model,
messages=[{"role": "user", "content": prompt}]
)
# Cache the response
await cache.aset(prompt, response, model=model)
return response
# Use it
result = await my_llm_call("Explain quantum computing")
ClawCache automatically tracks all your LLM spending:
# See today's detailed cost report
clawcache --report
# Output shows:
# - Money spent today
# - Money saved via cache
# - Total API calls
# - Cache hit rate
# - Efficiency metrics
tiktoken when availableClawCache takes security seriously:
Customize ClawCache behavior via environment variables:
export CLAWCACHE_HOME=/path/to/cache # Default: ~/.clawcache
ClawCache supports composite cache keys for better accuracy:
# Cache by prompt + model + temperature
await cache.aset(
prompt,
response,
model="gpt-4-turbo",
temperature=0.7
)
| Model | Input ($/1M tokens) | Output ($/1M tokens) |
|---|---|---|
| GPT-4 Turbo | $10.00 | $30.00 |
| GPT-3.5 Turbo | $0.50 | $1.50 |
| Claude 3.5 Sonnet | $3.00 | $15.00 |
| Claude 3 Haiku | $0.25 | $1.25 |
@async_monitor_cost
async def review_code(code_snippet):
prompt = f"Review this code for bugs: {code_snippet}"
return await llm_call(prompt, model="gpt-4-turbo")
@async_monitor_cost
async def analyze_data(dataset):
prompt = f"Analyze this dataset: {dataset}"
return await llm_call(prompt, model="claude-3-5-sonnet")
@async_monitor_cost
async def generate_content(topic):
prompt = f"Write a blog post about: {topic}"
return await llm_call(prompt, model="gpt-3.5-turbo")
Based on typical usage patterns:
Want even more savings and insights? ClawCache Pro will include:
Free: Cost tracking with CLI reports + exact-match caching
Pro: Adds social sharing with charts + semantic caching + advanced analytics
Contributions welcome! Please:
MIT License - see LICENSE for details
Made with ❤️ for the AI community
Save money. Track costs. Build better.