Back to skills
SKILL.md
2241 Monitoring Costs 3da71739
ASecurity```python def get_request_cost(response, model_pricing): usage = response.usage return calculate_cost( model_pricing, usage.prompt_tokens, usage.completion_tokens )
- 9 stars
- 0 votes
- 0 copies
- 0 views
- Added October 11, 2026
Works with
Security analysis
100/100npx -y skills add tools-only/X-Skills --skill 2241-monitoring-costs_3da71739 --agent claude-codeAre you the author of 2241 Monitoring Costs 3da71739?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/tools-only-2241-monitoring-costs-3da71739)# Monitoring Costs
## Monitoring Costs
### Per-Request Cost
```python
def get_request_cost(response, model_pricing):
usage = response.usage
return calculate_cost(
model_pricing,
usage.prompt_tokens,
usage.completion_tokens
)
response = client.chat.completions.create(...)
cost = get_request_cost(response, {"prompt": 10, "completion": 30})
print(f"Request cost: ${cost:.6f}")
```
### Dashboard Monitoring
```
openrouter.ai/activity shows:
- Per-request costs
- Daily/weekly/monthly totals
- Model breakdown
- Usage trends
```
### Budget Alerts
```
Set up monitoring:
1. Per-key credit limits
2. Daily spend tracking
3. Alerts when approaching limits
4. Automatic key disable at limit
```Attribution
Comments
Loading comments…