๊ฐ€์ž… ํ›„ ์ดˆ๋Œ€ ๋งํฌ๋ฅผ ๊ณต์œ ํ•˜๋ฉด ๋™์˜์ƒ ์žฌ์ƒ ๋ฐ ์ดˆ๋Œ€ ๋ณด์ƒ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture ๆŠ•็จฟใฏๅ€‹ไบบใฎๆ„่ฆ‹ใงใ™ใ€‚
๊ฐ€์ž… May 2026
279 ํŒ”๋กœ์ž‰ ์ค‘    408 ํŒฌ
# Practical ways to use the Claude Agent SDK ๐Ÿ’ฐ Track agent costs per step and per model to optimize your budget. Cost and Usage Tracking uses `total_cost_usd` and `modelUsage` to monitor token consumption and costs in real time. ๐Ÿ“Œ Title: Cost and Usage Tracking ๐Ÿ”— URL: ๐Ÿงฉ Overview ` gives cumulative estimated cost per call. `modelUsage` breaks down tokens by model. Prompt caching optimization can significantly reduce costs. ๐Ÿ›  How to use it Read `total_cost_usd` from `ResultMessage`. Deduplicate using `AssistantMessage` IDs for accurate per-step accounting. ๐Ÿ— Practical usage - Monitor `total_cost_usd` per `query()` call and trigger alerts when thresholds are exceeded. - Use `modelUsage` to break down costs between sub-agent Haiku and main Opus usage, visualizing where costs concentrate. - Set `ENABLE_PROMPT_CACHING_1H=1` to extend TTL from 5 minutes to 1 hour, preventing cache misses across many short sessions. - Accumulate `total_cost_usd` across multiple `query()` calls for session-level cost management. ๐Ÿ’ก Use cases ๐Ÿ“Š Per-step cost visualization dashboard ๐Ÿ”” Automatic budget threshold alerts โšก Prompt cache optimization for cost reduction โš ๏ธ Watch out `total_cost_usd` is an approximate estimate. Use the Usage and Cost API / Console for authoritative billing. The SDK doesn't provide session totals โ€” accumulate on the app side. #ClaudeAgentSDK# #AI#
๋” ๋ณด๊ธฐ