Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add BagelHole/DevOps-Security-Agent-Skills --skill llm-cost-optimizationgit clone --depth 1 https://github.com/BagelHole/DevOps-Security-Agent-SkillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/bagelhole/devops-security-agent-skills/llm-cost-optimization)<a href="https://agentmods.dev/skills/bagelhole/devops-security-agent-skills/llm-cost-optimization"><img src="https://agentmods.dev/badge/skills/bagelhole/devops-security-agent-skills/llm-cost-optimization.svg" alt="Measured on agentmods" height="20"></a>- NVIDIA SkillSpector pass
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00049 | $0.02428 |
| Opus 5 | $0.00024 | $0.01214 |
| Sonnet 5 | $0.00010 | $0.00486 |
| Haiku 4.5 | $0.00005 | $0.00243 |
Grade A, and why
llm-cost-optimization scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 287 lines — stays where its author put it; the contents beside it link to each section on GitHub.
LLM Cost Optimization
Cut LLM costs by 50–90% with the right combination of caching, model selection, prompt optimization, and self-hosting.
When to Use This Skill
Use this skill when:
- LLM API spend is growing faster than revenue
- You need to attribute AI costs to teams, products, or customers
- Implementing caching to avoid redundant LLM calls
- Deciding when to switch from API providers to self-hosted models
- Optimizing prompt length without sacrificing quality
Cost Levers by Impact
| Strategy | Typical Savings | Effort |
|---|---|---|
| Semantic caching | 20–50% | Low |
| Model right-sizing | 30–70% | Low |
| Prompt compression | 10–30% | Medium |
| Provider caching (prompt cache) | 10–25% | Low |
| Batching offline workloads | 50% (Batch API) | Medium |
| Self-hosting 7–8B models | 80–95% at scale | High |
| Quantization | 30–50% VRAM cost | Medium |
Track Costs First
# Use LiteLLM's cost tracking (automatic per-model pricing)
import litellm
response = litellm.completion(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
)
cost = litellm.completion_cost(response)
print(f"Cost: ${cost:.6f}")
# Add custom cost callbacks
def log_cost(kwargs, completion_response, start_time, end_time):
cost = kwargs.get("response_cost", 0)
model = kwargs.get("model")
user = kwargs.get("user")
# Send to your analytics DB
db.record_cost(user=user, model=model, cost=cost)
litellm.success_callback = [log_cost]
Model Right-Sizing
# Route by task complexity — don't use GPT-4o for everything
def get_model_for_task(task_type: str) -> str:
routing = {
"classification": "gpt-4o-mini", # ~30× cheaper than gpt-4o
"summarization": "gpt-4o-mini",
"extraction": "gpt-4o-mini",
"simple_qa": "gpt-4o-mini",
"complex_reasoning": "gpt-4o",
"code_generation": "claude-sonnet-4-6",
"creative_writing": "claude-opus-4-6",
}
return routing.get(task_type, "gpt-4o-mini")
# Cost comparison (per 1M tokens, 2025 approx.)
# gpt-4o-mini: input $0.15 / output $0.60
# gpt-4o: input $2.50 / output $10.00
# claude-sonnet-4-6: input $3.00 / output $15.00
# llama-3.1-8b (self): ~$0.05–0.10 all-in (GPU amortized)
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 8d ago First seen · 287 lines · 49 tokens per session scan A 93152256a3f7
llm-cost-optimization is a skill published in the GitHub repository BagelHole/DevOps-Security-Agent-Skills (1,058 stars, last pushed 3mo ago), licensed MIT. It adds 49 tokens to every session and 2,428 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
bedrock
AWS Bedrock foundation models for generative AI. Use when invoking foundation models, building AI applications, creating embeddings, configuring model access, or implementing RAG patterns.
implementing-aws-macie-for-data-classification
Implement Amazon Macie to automatically discover, classify, and protect sensitive data in S3 buckets using machine learning and pattern matching for PII, financial data, and credentials detection.
agentic-eks-bootstrap
Bootstrap an AWS EKS cluster optimized for Agentic AI workloads — Karpenter v1.2+ GPU node pools, EKS Auto Mode, Kubernetes 1.32+ with DRA 1.35 GA, VPC CNI, GPU Operator, and baseline observability. Use when starting a new EKS cluster that will host vLLM, Inference Gateway, Langfuse, or Kagent.
ai-gateway-guardrails
Enforce Input/Output Guardrails at the LLM Gateway layer — PII redaction, Prompt Injection defense, Jailbreak detection, Toxicity filter, and Tool Allow-list. Integrates Bedrock Guardrails, NeMo Guardrails, Llama Guard 3, and regex/regex-ML policies on Bifrost/LiteLLM with Langfuse audit trail.
gpu-resource-management
Design GPU orchestration on EKS using Karpenter v1.2+ NodePools, KEDA scale-to-zero, and DRA 1.35 GA for multi-instance GPU (MIG) partitioning. Right-size NodePool for p5/g6e/trn2 instance mix, spot/on-demand split, consolidation, and topology-aware scheduling.
inference-gateway-routing
Configure kgateway v2.0+ as L1 and Bifrost v1.x or LiteLLM v1.60+ as L2 for a 2-Tier Inference Gateway on EKS. Apply Cascade Routing (Haiku→Sonnet→Opus fallback), Semantic Router (intent-based model pick), and HTTPRoute with OTel trace propagation to Langfuse.