Skip to content

Token usage — Reference

API endpoints, response types, status codes, and MCP tools for GitHub Copilot token consumption and AI Credit monitoring across all four aggregation levels.

Endpoints

MethodPathAuthDescription
GET/api/runs/{id}/usageAPI key (run owner)Token usage summary for a single run
GET/api/workflow-runs/{id}/usageAPI key (project owner)Token usage summary for a workflow-run envelope
GET/api/projects/{id}/usageAPI key (project owner)Project-level usage, time-ranged (default: last 30 days)
GET/api/usageAdmin onlyApp-wide usage, time-ranged (default: last 30 days)

The following existing endpoints also include a token_usage field in their responses when usage data is available:

EndpointAdded fieldType
GET /api/projects/{id}/dashboardtoken_usageTokenUsageSummaryDto (nullable)
GET /api/overviewtoken_usageAppUsageDto (nullable)

Source: apps/Agentweaver.Api/Endpoints/UsageEndpoints.cs, apps/Agentweaver.Api/Metrics/MetricsDtos.cs.

Response types

TokenUsageSummaryDto

Returned by the run, workflow-run, and project usage endpoints.

FieldTypeDescription
input_tokenslongTotal prompt tokens across all turns in scope
output_tokenslongTotal completion tokens across all turns in scope
total_tokenslongSum of input_tokens + output_tokens
total_nano_aiulongTotal cost in nano-AIU units
by_modelTokenUsageByModelDto[]Per-model breakdown

TokenUsageByModelDto

FieldTypeDescription
model_idstringCopilot model identifier as returned by the SDK (e.g. gpt-4o)
input_tokenslongPrompt tokens attributed to this model
output_tokenslongCompletion tokens attributed to this model
total_nano_aiulongCost in nano-AIU attributed to this model

AppUsageDto

Returned by GET /api/usage and embedded in the overview response.

FieldTypeDescription
generated_utcstring (ISO-8601)Timestamp when this response was generated
from_utcstring (ISO-8601)Start of the query time range
to_utcstring (ISO-8601)End of the query time range
total_tokenslongTotal tokens across all projects in range
total_nano_aiulongTotal nano-AIU across all projects in range
by_projectProjectUsageDto[]Per-project breakdown
by_modelTokenUsageByModelDto[]Per-model breakdown across all projects

ProjectUsageDto

Appears in the by_project array of AppUsageDto.

FieldTypeDescription
project_idstringProject identifier
project_namestringProject display name
total_tokenslongTotal tokens attributed to this project
total_nano_aiulongTotal nano-AIU attributed to this project
by_modelTokenUsageByModelDto[]Per-model breakdown for this project

AIC conversion

1 AIC (AI Credit) = 1,000,000,000 nano-AIU
display value = total_nano_aiu / 1_000_000_000  (4 decimal places)

Status codes

CodeMeaning
200 OKUsage data returned (may be zero totals if no turns recorded yet)
400 Bad RequestInvalid query parameter (e.g. unparseable date)
401 UnauthorizedMissing or unrecognized API key
403 ForbiddenKey is valid but caller does not own the resource, or non-admin caller on /api/usage
404 Not FoundRun, workflow-run, or project id does not exist

Time range defaults

The project and app-level endpoints accept optional from and to query parameters:

GET /api/projects/{id}/usage?from=2026-05-01T00:00:00Z&to=2026-06-01T00:00:00Z
GET /api/usage?from=2026-05-01T00:00:00Z&to=2026-06-01T00:00:00Z
  • Both parameters are ISO-8601 UTC timestamps.
  • When omitted, the server defaults to the last 30 days ending at the time of the request.
  • The run and workflow-run endpoints do not accept time range parameters — they return all usage for that specific run scope.

MCP tools

get_run_usage

Returns token usage for a single run.

Source: apps/Agentweaver.Mcp/Tools/RunTools.cs.

ParameterTypeRequiredDescription
run_idstringYesThe run id to query

Returns a TokenUsageSummaryDto-shaped result with input_tokens, output_tokens, total_tokens, total_nano_aiu, and by_model.

get_project_usage

Returns token usage for a project, optionally time-ranged.

Source: apps/Agentweaver.Mcp/Tools/ProjectTools.cs.

ParameterTypeRequiredDescription
project_idstringYesThe project id to query
fromstringNoISO-8601 UTC start (default: 30 days ago)
tostringNoISO-8601 UTC end (default: now)

Returns a TokenUsageSummaryDto-shaped result.

See also