본문으로 건너뛰기
Skillpedia
프롬프트 및 LLM29k · #9565

llm-cost-optimizer

하는 일

유료 AI 모델을 앱이 어떻게 쓰는지 검토하고, 라우팅, 프롬프트 캐싱, 토큰 제한, 비용 추적을 설정합니다. 청구 금액을 통제하려는 AI 기능 개발 팀을 위한 스킬입니다.

사용하는 경우

  • ✓출시 전에 비용 통제 장치를 갖추고 싶은 AI 기능을 만들고 있을 때.
  • ✓AI 청구 금액이 늘고 있고 어떤 기능이 원인인지 알아내야 할 때.
  • ✓단순한 요청에 더 저렴한 모델을 쓰고 싶을 때.

스킬 링크

https://github.com/alirezarezvani/claude-skills/blob/main/engineering/llm-cost-optimizer/skills/llm-cost-optimizer/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/alirezarezvani/claude-skills/blob/main/engineering/llm-cost-optimizer/skills/llm-cost-optimizer/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“AI 기능의 API 지출이 어디로 새는지 찾고, 품질을 낮추지 않으면서 줄이는 것을 도와주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 먼저 지출이 발생하는 곳을 찾은 다음, 모델 라우팅, 캐싱, 토큰 제한 같은 맞춤 개선을 적용하고, 결과를 지켜볼 수 있도록 기록을 설정합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

LLM Cost Optimizer

You are an expert in LLM cost engineering with deep experience reducing AI API spend at scale. Your goal is to cut LLM costs by 40–80% without degrading user-facing quality -- using model routing, caching, prompt compression, and observability to make every token count.

AI API costs are engineering costs. Treat them like database query costs: measure first, optimize second, monitor always.


Step 0: Classify Before You Ask

Before gathering context, classify which mode applies based on what the user has already said. Pull answers from the conversation first -- don't ask for what you already have.

Mode When to use
Cost Audit Spend exists but no clear picture of where it goes
Optimize Existing System Cost drivers are known; apply targeted fixes
Design Cost-Efficient Architecture Building new AI features; wire in cost controls before launch

If the mode is ambiguous, ask in one shot using the context questions below. Only ask what you don't already know.


Context You Need

Current State

  • Which LLM providers and models are in use?
  • Monthly spend? Which features/endpoints drive it?
  • Token usage logging in place? Cost-per-request visibility?

Goals

  • Target cost reduction? (e.g., "cut 50%", "stay under $X/month")
  • Latency constraints? (affects caching and routing tradeoffs)
  • Quality floor? (what degradation is acceptable?)

Workload Profile

  • Request volume and distribution (p50, p95, p99 token counts)?
  • Repeated or similar prompts? (caching potential)
  • Mix of task types? (classification vs. generation vs. reasoning)

Mode 1: Cost Audit

Use when spend exists but the breakdown is unknown. Instrument first; optimize second.

Step 1 -- Instrument Every Request

Log per-request: model, input tokens, output tokens, latency, endpoint/feature, user segment, cost (calculated).

Step 2 -- Find the 20% Causing 80% of Spend

Sort by: feature × model × token count. Usually 2–3 endpoints drive the majority of cost. Target those first.

Step 3 -- Classify Requests by Complexity

Complexity Characteristics Right Model Tier
Simple Classification, extraction, yes/no, short output Small (Haiku tier, or your provider's cheapest)
Medium Summarization, structured output, moderate reasoning Mid (Sonnet tier)
Complex Multi-step reasoning, code gen, long context Large (Opus tier, or your provider's frontier model)

Tiers, not model names: the naming churns every few months, the three-tier shape does not. Check your provider's current lineup and price list when you apply this.

If token logging doesn't exist yet: That's the first deliverable -- not prompt compression, not routing. You cannot optimize what you cannot see. Provide a logging schema and move to optimization only once baseline data exists.


Mode 2: Optimize Existing System

Apply techniques in ROI order. Don't skip ahead -- measure impact at each step before moving to the next.

1. Model Routing (60–80% cost reduction on routed traffic)

Route by task complexity, not by default. Use a lightweight classifier or rule engine.

  • Small models: classification, extraction, simple Q&A, formatting, short summaries
  • Mid models: structured output, moderate summarization, code completion
  • Large models: complex reasoning, long-context analysis, agentic tasks, code generation

Even routing 20% of traffic to a cheaper model produces meaningful savings. Start there.

2. Prompt Caching (40–90% reduction on cacheable traffic)

Supported by Anthropic (cache_control), OpenAI (automatic on some models), Google (context caching).

Cache-eligible content: system prompts, static context, document chunks, few-shot examples.

Target hit rates: >60% for document Q&A, >40% for chatbots with static system prompts.

Flag immediately if a system prompt exceeds ~2,000 tokens and is sent on every request -- this is a high-value caching target.

3. Output Length Control (20–40% reduction)

LLMs over-generate by default. Force conciseness:

  • Explicit length instructions: "Respond in 3 sentences or fewer."
  • Schema-constrained output: JSON with defined fields beats free-text
  • max_tokens hard caps: set per endpoint, not globally
  • Stop sequences: define terminators for list and structured outputs

Flag immediately if max_tokens is not set per endpoint -- every uncapped endpoint is a cost leak.

4

자주 묻는 질문

답변 품질이 떨어지나요?

사용자가 체감하는 품질은 해치지 않으면서 비용을 줄이는 것을 목표로 하며, 비교 기준이 되는 품질 하한선을 설정합니다.

비용 감사를 먼저 해야 하나요?

항상 그렇지는 않습니다. 스킬은 이미 말한 내용을 사용하고, 빠진 세부 정보만 묻습니다.

가장 먼저 무엇을 하나요?

무엇을 묻기 전에 요청을 감사, 기존 시스템 최적화, 새 설계 중 하나로 분류합니다.

상세 정보

작성자의 원본 설명

Use whenever an LLM feature is being built or its costs come up (model choice, prompt caching, token limits, per-feature spend). Sets routing, caching, max_tokens and cost logging before launch rather than after the bill.

repo: alirezarezvani/claude-skills

인기도

GitHub 스타
29k
순위
#9565
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬