C.W.K.
Stream
Lesson 08 of 10 · published

Cost engineering — 돈이 어디 가나

~14 min · production, cost

Level 0수련생
0 XP0/100 lessons0/14 achievements
0/120 XP to next level120 XP to go0% complete

청구서가 predictable shape

2026 대부분 prompt-using system에 cost가 input token (context 큼) dominate, 그 다음 reasoning token (extended thinking on일 때), 그 다음 output token, 그 다음 다 나머지. Caching, model tier choice, reasoning routing이 가장 큰 3 lever.

Impact 순서로 lever

  1. Prompt caching — stable prefix에 5–10× reduction.
  2. Model-tier routing — 일상 request를 mid-tier로; hard에 top-tier 예약.
  3. Reasoning budget routing — 필요할 때만 reasoning enable.
  4. Context trimming — RAG top-K 더 tight, document compression, history에서 turn drop.
  5. Output discipline — schema-bound output이 free-form보다 작아.
  6. Provider competition — 주기적 비교; appropriate한 곳에 switch.

Optimize 안 할 것

  • Quality drop 측정 안 하고 quality를 cost로 trade X.
  • Tail cost가 issue일 때 average cost optimize X (한 slow long-context call이 1,000 cheap drown).
  • Operational complexity 안 optimize하고 cost optimize X.

Code

Request당 cost attribution·python
@dataclass
class CostBreakdown:
    input_tokens: int
    cache_read_tokens: int
    cache_write_tokens: int
    output_tokens: int
    thinking_tokens: int

    def total_usd(self, rates) -> float:
        return (
            self.input_tokens     * rates.input_per_tok
          + self.cache_read_tokens * rates.cache_read_per_tok
          + self.cache_write_tokens * rates.cache_write_per_tok
          + self.output_tokens    * rates.output_per_tok
          + self.thinking_tokens  * rates.thinking_per_tok
        )

External links

Exercise

한 production endpoint에 지난주 cost를 input / cached / output / thinking 별로 attribute. 가장 큰 bucket 식별. matching lever (caching, trimming, routing) 적용, 변화 측정.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.