Catalog
BerriAI/view-usage

BerriAI

view-usage

Query spend and token activity on a live LiteLLM proxy. Shows daily usage broken down by user, team, org, tag, job, or model. Use when the user wants to see costs, token counts, request volume, or job-level attribution for a given date range.

v1.0LATEST
NewUpdated Oct 12, 2026

View Usage

Query daily activity and spend data from a live LiteLLM proxy.

Setup

Ask for these if not already known:

LITELLM_BASE_URL  — e.g. https://my-proxy.example.com
LITELLM_API_KEY   — proxy admin key

API reference: https://docs.litellm.ai/docs/proxy/users#get-user-spend

Ask the user

  1. View by — overall / user / team / org / tag / job (default: overall)
  2. Date range — default to current month if not given
  3. Filter by model? (optional)
  4. Job tag(s)? (optional) — for job cost attribution, ask which request tag identifies the job, for example job:nightly-eval or job=batch-import.

Job cost attribution

LiteLLM attributes per-request costs through request tags. For LLM jobs, prefer tagging requests with a stable job label such as job:<job-name> and then query tag APIs:

  • Use /tag/daily/activity?tags=<tag> for daily spend, tokens, request count, and model/provider breakdowns for one or more job tags.
  • Use /global/spend/tags?tags=<tag> for a top-level spend total by tag over a date range.
  • If the user asks "which jobs cost the most?", call /global/spend/tags without a tags filter, sort by spend descending, and present the top tags that look like job labels.

Endpoints

Overall spend (across all users)

curl -s "$BASE/user/daily/activity?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD&page_size=30" \
  -H "Authorization: Bearer $KEY"

Overall request and token volume

curl -s "$BASE/global/activity?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD" \
  -H "Authorization: Bearer $KEY"

By team

curl -s "$BASE/team/daily/activity?team_ids=<team_id>&start_date=YYYY-MM-DD&end_date=YYYY-MM-DD" \
  -H "Authorization: Bearer $KEY"

By org

curl -s "$BASE/organization/daily/activity?organization_ids=<org_id>&start_date=YYYY-MM-DD&end_date=YYYY-MM-DD" \
  -H "Authorization: Bearer $KEY"

By user

curl -s "$BASE/user/daily/activity?user_id=<user_id>&start_date=YYYY-MM-DD&end_date=YYYY-MM-DD" \
  -H "Authorization: Bearer $KEY"

By tag or job

curl -s "$BASE/tag/daily/activity?tags=<tag>&start_date=YYYY-MM-DD&end_date=YYYY-MM-DD&page_size=30" \
  -H "Authorization: Bearer $KEY"

For multiple tags, pass a comma-separated list:

curl -s "$BASE/tag/daily/activity?tags=job:nightly-eval,job:batch-import&start_date=YYYY-MM-DD&end_date=YYYY-MM-DD&page_size=30" \
  -H "Authorization: Bearer $KEY"

Top tag spend

curl -s "$BASE/global/spend/tags?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD" \
  -H "Authorization: Bearer $KEY"

Filter to a specific job tag:

curl -s "$BASE/global/spend/tags?tags=<tag>&start_date=YYYY-MM-DD&end_date=YYYY-MM-DD" \
  -H "Authorization: Bearer $KEY"

Response shape

{
  "results": [
    {
      "date": "2026-03-14",
      "metrics": {
        "spend": 1.23,
        "prompt_tokens": 45000,
        "completion_tokens": 12000,
        "total_tokens": 57000,
        "api_requests": 120,
        "successful_requests": 118,
        "failed_requests": 2
      },
      "breakdown": {
        "models": { "gpt-4o": { "metrics": { "spend": 1.23, ... } } }
      }
    }
  ],
  "metadata": { "page": 1, "page_size": 10, "total_count": 31 }
}

Note: top-level key is results (not data).

Summarize with python3

curl -s "$BASE/user/daily/activity?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD&page_size=30" \
  -H "Authorization: Bearer $KEY" | python3 -c "
import sys, json
d = json.load(sys.stdin)
rows = d.get('results', [])
print('{:<12} {:>10} {:>12} {:>10}'.format('Date', 'Requests', 'Tokens', 'Spend'))
print('-' * 46)
total_spend = 0
for r in rows:
    m = r.get('metrics', {})
    print('{:<12} {:>10} {:>12} ${:>9.4f}'.format(
        r.get('date', ''),
        m.get('api_requests', 0),
        m.get('total_tokens', 0),
        m.get('spend', 0),
    ))
    total_spend += m.get('spend', 0)
print('-' * 46)
print('{:<12} {:>10} {:>12} ${:>9.4f}'.format('TOTAL', '', '', total_spend))
"

Error handling

Before processing results, check the HTTP status:

  • 401/403 — invalid or expired LITELLM_API_KEY; ask the user to verify
  • 404 — endpoint not available; check LiteLLM proxy version supports activity endpoints
  • Empty results — no activity in the given date range; confirm dates are correct

Instructions

  1. Ask for date range — default to current month.
  2. Run the appropriate endpoint. For job attribution, prefer tag endpoints and ask for the job tag if it was not provided.
  3. Print a table: Date | Requests | Tokens | Spend.
  4. Show totals row at the bottom.
  5. Highlight any days with failed_requests > 0.
  6. If metadata.total_pages > 1, offer to fetch remaining pages.
Files1
1 files · 1.0 KB

Select a file to preview

Overall Score

79/100

Grade

B

Good

Grades are signals, not a certification. Always review a skill yourself before use.

Safety

76

Quality

82

Clarity

85

Completeness

72

Summary

A skill that queries spend and token usage data from a live LiteLLM proxy via REST API. The agent uses curl to fetch JSON activity data across multiple grouping dimensions (user, team, org, tag, job), and optionally pipes results through python3 to format and summarize metrics. It requires a valid proxy URL and admin API key.

Static Analysis Findings

1 finding

Patterns detected by deterministic static analysis before AI scoring. Hover over any finding code for detailed information and remediation guidance.

Command Injection
SEC-011Dynamic Shell Eval

Shell eval/exec of dynamic content

SKILL.mdeval`

Detected Capabilities

curl network requestpython3 script executionJSON parsing and formattingenvironment variable readAPI key authentication

Trigger Keywords

Phrases that agents use to match this skill to user intent.

view usage costslitellm proxy metricstoken spend analysisjob cost attributionrequest volume breakdownapi spending report

Risk Signals

WARNING

Shell eval/exec of dynamic content (SEC-011: inline python3 -c)

SKILL.md, Summarize with python3 section
WARNING

Credential exposure: LITELLM_API_KEY stored and transmitted via curl header

SKILL.md, Setup and all endpoint sections
INFO

Outbound network requests to external proxy URL (SEC-060)

SKILL.md, curl endpoints

Referenced Domains

External domains referenced in skill content, detected by static analysis.

docs.litellm.aimy-proxy.example.com

Use Cases

  • View daily spend and token consumption across all users on a proxy
  • Attribute costs to specific jobs or requests using tag-based filtering
  • Compare spending trends across teams, orgs, or individual users
  • Identify which jobs or tags are consuming the most resources
  • Debug API request failures by viewing failed_request counts over time
  • Generate billing reports broken down by date, team, or model

Quality Notes

  • Clear setup section requesting required credentials (base URL and API key)
  • Well-documented endpoint reference with LiteLLM API link
  • Multiple endpoint examples covering all requested grouping dimensions (user, team, org, tag, job)
  • Comprehensive response shape documentation with JSON structure shown
  • Error handling section covers HTTP status codes (401, 403, 404) and empty results
  • Python3 summarization example is concrete and immediately usable
  • Job cost attribution explanation is clear and includes tag-based filtering strategy
  • Instructions are step-by-step and actionable
  • allowed-tools field correctly scopes usage to curl and python3
  • No scaffolding or supporting scripts provided—skill relies on inline curl/python patterns
Model: claude-haiku-4-5-20251001Analyzed: Oct 12, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Use BerriAI/view-usage in your dev environment

Command Palette

Search for a command to run...