| name | cost-aggregation |
| description | Consolidates provider-specific AI costs into unified metrics across Anthropic, OpenAI, Google Gemini, GitHub Copilot, and Ollama. Enables apples-to-apples cost comparison and savings analysis. |
| skill | cost-aggregation |
| version | 1.0.0 |
| task_id | COST-002 |
| depends_on | ["COST-001"] |
| author | senior-engineer |
| status | active |
Cost Aggregation Skill (COST-002)
Consolidates provider-specific AI costs into unified metrics across 5 providers:
Anthropic, OpenAI, Google Gemini, GitHub Copilot, and Ollama (local/zero-cost).
Purpose
Enable apples-to-apples cost comparison across AI providers for any given task,
supporting model selection optimization (COST-003) and budget enforcement (COST-001).
API
from src.skills.cost_aggregation.scripts.cost_aggregator import CostAggregator
agg = CostAggregator()
result = agg.aggregate_task_cost(
task_type="code_review",
input_tokens=5000,
output_tokens=2000,
model_variants={
"anthropic": "claude-sonnet-4.6",
"openai": "gpt-5.4",
"google": "gemini-2.0",
"copilot": "claude-sonnet-4.6",
"ollama": "mistral:latest"
}
)
trend = agg.cost_trend_for_provider("anthropic", "2026-05-01", "2026-05-28")
health = agg.provider_health_check()
agg.record_usage("anthropic", "claude-sonnet-4.6", 5000, 2000)
Providers
| Provider | Auth | Cost Model | Zero-Cost |
|---|
| anthropic | ANTHROPIC_API_KEY | per-token | No |
| openai | OPENAI_API_KEY | per-token | No |
| google | GOOGLE_API_KEY | per-token | No |
| copilot | GITHUB_TOKEN | per-use | No |
| ollama | (none) | local | Yes |
Configuration
Provider pricing is configured in src/config/providers.yaml.
Update that file when providers change their published rates.
Performance
aggregate_task_cost(): <10ms (pure computation, no network calls)
provider_health_check(): <1ms when cached (5-minute TTL)
- Cost accuracy: ±2% vs published rates
Files
src/skills/cost-aggregation/
├── SKILL.md # This file
├── scripts/
│ ├── __init__.py
│ ├── cost_aggregator.py # Main CostAggregator class
│ └── providers/
│ ├── __init__.py
│ ├── base_provider.py # Abstract base class
│ ├── anthropic_provider.py # Anthropic claude-* models
│ ├── openai_provider.py # OpenAI GPT-* models
│ ├── google_provider.py # Google Gemini models
│ ├── copilot_provider.py # GitHub Copilot (per-use)
│ └── ollama_provider.py # Ollama local (zero-cost)
└── tests/
├── __init__.py
└── test_cost_aggregator.py # 80+ test cases
Dependencies
COST-001 (cost_budgeter): Uses same rate structure pattern
pyyaml: providers.yaml loading
pytest: Test suite
Self-Improvement
This skill participates in the framework's continuous improvement cycle
(see skill-improvement-feedback).
When you use cost-aggregation during a task, include a skill_feedback entry
in your HANDBACK to help improve it over time:
skill_feedback:
- skill_name: cost-aggregation
effectiveness_score: 0.85
clarity_score: 0.90
coverage_gaps:
- "Specific scenario the skill did not address"
improvement_suggestions:
- "Concrete change that would have helped"
usage_context: "One sentence on how you used this skill"
Positive feedback is as valuable as critical feedback. Three or more
feedback items for this skill automatically trigger an improvement task.