Skip to content
Back to skills

2118 Cost Optimization Across Providers 21a9310f

ASecurity

```python PROVIDER_PRICING = { "anthropic/claude-3-opus": {"prompt": 15.0, "completion": 75.0}, "anthropic/claude-3.5-sonnet": {"prompt": 3.0, "completion": 15.0}, "anthropic/claude-3-haiku": {"prompt": 0.25, "completion": 1.25}, "openai/gpt-4-turbo": {"prompt": 10.0, "completion": 30.0}, "openai/gpt-4": {"prompt": 30.0, "completion": 60.0}, "openai/gpt-3.5-turbo": {"prompt": 0.5, "completion": 1.5}, "meta-llama/llama-3.1-70b-instruct": {"prompt": 0.52, "completion":

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 31, 2026
ai-agentspython

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned May 31, 2026

npx -y skills add tools-only/X-Skills --skill 2118-cost-optimization-across-providers_21a9310f --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 2118 Cost Optimization Across Providers 21a9310f?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 2118 Cost Optimization Across Providers 21a9310f
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-2118-cost-optimization-across-providers-21a9310f/badge)](https://www.skillsdirectory.com/skills/tools-only-2118-cost-optimization-across-providers-21a9310f)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Cost Optimization Across Providers

## Cost Optimization Across Providers

### Provider Cost Comparison
```python
PROVIDER_PRICING = {
    "anthropic/claude-3-opus": {"prompt": 15.0, "completion": 75.0},
    "anthropic/claude-3.5-sonnet": {"prompt": 3.0, "completion": 15.0},
    "anthropic/claude-3-haiku": {"prompt": 0.25, "completion": 1.25},
    "openai/gpt-4-turbo": {"prompt": 10.0, "completion": 30.0},
    "openai/gpt-4": {"prompt": 30.0, "completion": 60.0},
    "openai/gpt-3.5-turbo": {"prompt": 0.5, "completion": 1.5},
    "meta-llama/llama-3.1-70b-instruct": {"prompt": 0.52, "completion": 0.75},
    "meta-llama/llama-3.1-8b-instruct": {"prompt": 0.06, "completion": 0.06},
}

def estimate_cost(
    model: str,
    prompt_tokens: int,
    completion_tokens: int
) -> float:
    """Estimate cost for request."""
    pricing = PROVIDER_PRICING.get(model, {"prompt": 10.0, "completion": 30.0})
    return (
        prompt_tokens * pricing["prompt"] / 1_000_000 +
        completion_tokens * pricing["completion"] / 1_000_000
    )

def find_cheapest_model(
    required_quality: str,
    required_context: int
) -> str:
    """Find cheapest model meeting requirements."""
    candidates = []

    for model, pricing in PROVIDER_PRICING.items():
        # Check context (would need to look up actual limits)
        avg_cost = (pricing["prompt"] + pricing["completion"]) / 2
        candidates.append((model, avg_cost))

    candidates.sort(key=lambda x: x[1])
    return candidates[0][0]
```

Files in this skill

  • README.md1.3 KB
  • skill.md1.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.