मुख्य सामग्री पर जाएँ
Skillpedia
प्रॉम्प्ट और LLM29k · #9565

llm-cost-optimizer

यह क्या करती है

यह देखती है कि कोई ऐप भुगतान वाले AI models कैसे इस्तेमाल करता है, और routing, prompt caching, token सीमा और लागत ट्रैकिंग सेट करती है। यह उन टीमों के लिए है जो AI फ़ीचर बना रही हैं और अपने बिल नियंत्रित करना चाहती हैं।

कब इस्तेमाल करें

  • ✓जब आप AI फ़ीचर बना रहे हों और लॉन्च से पहले लागत नियंत्रण चाहें।
  • ✓जब आपका AI बिल बढ़ रहा हो और आपको पता लगाना हो कि कौन सा फ़ीचर इसे बढ़ा रहा है।
  • ✓जब आप सरल अनुरोधों के लिए सस्ता model इस्तेमाल करवाना चाहें।

Skill का लिंक

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

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/alirezarezvani/claude-skills/blob/main/engineering/llm-cost-optimizer/skills/llm-cost-optimizer/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे AI फ़ीचर का API खर्च कहाँ जा रहा है, यह ढूँढने और गुणवत्ता घटाए बिना उसे कम करने में मेरी मदद कीजिए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट पहले पता लगाता है कि खर्च कहाँ हो रहा है, फिर model routing, caching और token सीमा जैसे लक्षित सुधार लागू करता है, और नतीजों पर नज़र रखने के लिए logging सेट करता है।

तकनीकी सामग्री (मूल 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
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

agent-launcher-orchestrator

29k

आपके एजेंट को एक साफ़ लक्ष्य से शुरू करके, अपने खाते में Claude मैनेज्ड एजेंट की योजना बनाने, बनाने, जांचने और शेड्यूल करने में चरण-दर-चरण मदद करती है।

AI और एजेंटएजेंट

grade-iterate

29k

आपके एजेंट को किसी मैनेज्ड AI एजेंट के काम को रूब्रिक से आंकने और तय संख्या के दौरों में सुधारने देती है, ताकि वह कभी अनंत चक्र में न फंसे।

AI और एजेंटएजेंट

interview

29k

आपके एजेंट को AI एजेंट के विचार पर आपसे इंटरव्यू लेने और कुछ भी लॉन्च होने से पहले आपके जवाबों को सरल निर्माण योजना में बदलने देती है।

AI और एजेंटएजेंट

run-without-you

29k

आपके एजेंट को मैनेज्ड AI एजेंट शेड्यूल पर या किसी घटना पर चलाने में मदद करती है, लॉन्च से पहले cron समय की जांच के साथ।

प्रोडक्टिविटीऑटोमेशन

मिलती-जुलती skills