Task type breakdown
The Model Leaderboard tells you which models carry your traffic and spend. The task type breakdown adds the second question people ask next: traffic for what? When requests carry a task tag, the gateway rolls them up per task type and the By task type card and the GET /model-insights/tasks route show, for each kind of work, how much of the chosen metric it took and which model led it.
What this is for
Without task tags, a model's share tells you little about why it costs what it costs. With them, you can see that one model handles most code review while another answers customer support, decide where a cheaper model would do, and check later whether the change moved the numbers. The breakdown covers the whole gateway, so it is for proxy admins and admin viewers.
Scenario
A platform team runs two coding assistants and a support bot through the gateway. Spend went up last month and nobody knows which product caused it. They add task:code_review and task:debugging tags to the assistants' requests and task:customer_support to the bot's, wait a day, and open the leaderboard. The breakdown shows debugging at 40 percent of spend, led by the most expensive model, so they route debugging to a cheaper tier and watch the share fall the following week.
Steps
-
Tag the requests. Send the task in the
x-spanway-tagsheader, or inmetadata.tagsin the body. Only task types in the catalogue below are recognised, and anything else rolls up asuncategorized. A few rules decide which tag counts. When a request carries several task tags, the first one in the catalogue wins. Atagslist at the top of the body replaces the header tags. Tags set on the key, its team or its project are added to the request's own tags, so you can tag a whole application once on its key. Whengeneral_settings.reject_clientside_metadata_tagsis on, a request that sendsmetadata.tagsis refused with 400, so use the header or key tags instead.curl -X POST http://localhost:4000/v1/chat/completions \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-H "x-spanway-tags: task:code_review" \-d '{"model": "claude-sonnet-5-5", "messages": [{"role": "user", "content": "Review this diff for bugs"}]}' -
Let the rollup catch up. Each request is added to the per day rollup together with its spend log, which is flushed every
proxy_batch_write_atseconds (10 by default, see the settings reference), so new requests appear within about that time. Calls the gateway makes for itself, such as shadow eval judges, guardrail judges and background cost checks, are left out so they do not inflate a model's share. Eval runs, playground calls and online scoring judge calls are counted like any other traffic, because they are real model usage billed to a key. -
Read the breakdown. In the Admin UI open Model Leaderboard under Observability, set From and To above the charts, and scroll to the By task type card. It follows the metric tab you picked on the Top models card, Requests, Spend or Tokens. From the command line:
curl "http://localhost:4000/model-insights/tasks?start_date=2026-09-16&end_date=2026-10-16&metric=spend" \-H "Authorization: Bearer $SPANWAY_API_KEY"metricisrequests,spendortokensand defaults tospend. Dates areYYYY-MM-DD, both days are included, the range defaults to the last 365 days and may not be longer than that.
Expected result
The card lists one row per task type seen in the range with Task, Category, Total, Share and Leading model. The route returns the same rows, sorted by the chosen metric:
{
"start_date": "2026-09-16",
"end_date": "2026-10-16",
"tasks": [
{
"task_type": "code_review",
"label": "Code Review",
"category": "Code",
"value": 412.5,
"share": 34.9,
"leader": "claude-sonnet-5-5",
"provider": "anthropic"
},
{
"task_type": "uncategorized",
"label": "Uncategorized",
"category": "General",
"value": 120.0,
"share": 10.2,
"leader": "gpt-6.1-sol",
"provider": "openai"
}
]
}
value is the total of the chosen metric for that task, share is its percentage of the total across every task, and leader and provider name the model group with the most usage on that task, adding up every deployment of the group.
Task catalogue
| Category | Task types |
|---|---|
| General | classification, content_writing, roleplay_fiction, conversation, research_reports, qa_knowledge, customer_support, summarization, translation |
| Agent | workflow_execution, multi_step_planning, tool_dispatch |
| Code | code_generation, debugging, code_review, frontend_ui, file_io, shell_execution |
| Data | data_extraction, data_transformation |
A request with no task: tag, or with a task type outside this list, is counted under uncategorized. The catalogue is fixed in this release, so pick the closest type rather than inventing one.
Errors
| What you see | Why | Fix |
|---|---|---|
400 Dates must use YYYY-MM-DD | A date was in another format. | Send start_date and end_date as YYYY-MM-DD. |
400 Date range must be between 1 and 365 days | The end date is before the start date, or the range is longer than a year. The page shows "The end date must not be before the start date." or "Pick at most 365 days." and keeps the last data it loaded. | Narrow the range. |
401 Authentication Error, No api key passed in. | No key was sent, or it is not valid. | Send Authorization: Bearer <key>. |
403 Only proxy admins can view deployment-wide model insights | The key belongs to an org admin, internal user or viewer. | Use a proxy admin or admin viewer key. |
500 DB not connected. This endpoint needs a database; set DATABASE_URL ... | The rollup lives in the database. | Set DATABASE_URL. |
| The card reads "No requests in this range carry a task tag, so any traffic shows as one Uncategorized row. ..." above a single Uncategorized row, or alone when the range has no requests | Nothing in the range was tagged. | Add task tags as in step 1 and widen the range. |
Everything shows as uncategorized | The tag is spelled differently from the catalogue, or the prefix task: is missing. | Compare the tag against the catalogue. |
Logs
The task breakdown reads the same rollup as the leaderboard, so the same two rollup lines apply, see model leaderboard logs and the log reference.
Related
- Model leaderboard, the ranking the breakdown sits under.
- Model Leaderboard page, every control on the page.
- Tag based routing, the other use of request tags.
- Cost tracking, where the spend figures come from.
- Model insights API reference.