Usage & Billing

JoyToken records tokens, Credits, model, tier, and API key attribution after successful model calls.

What to Check

QuestionWhere to look
Which model setting was usedmetadata.model
How many Credits were usedmetadata.billing.credits_used
Input / output tokensmetadata.billing.input_tokens / metadata.billing.output_tokens
Which key created usageJoyToken Console logs and usage
Which tier was usedmetadata.tier

Billing Fields

metadata is always an array. A single-model response has one entry; an orchestration response has one entry per task. Sum billing.credits_used across all entries for the total cost.

{
"metadata": [
{
"model": "auto",
"tier": "standard",
"billing": {
"credits_used": "0.2288",
"input_tokens": 54,
"output_tokens": 545
}
}
]
}

Streaming appends standalone metadata events before [DONE]: a single-model response emits one event whose value is a single-element array, while an orchestration response emits one event per task whose value is a single object.

Usage Attribution

Use one API key per environment and workflow:

WorkflowRecommended key
Local developmentdev-chat-api
Integration APIintegration-api
OpenClaw / Hermes / IDEagent-key
Background jobworker-summary

Cost Control

GoalSetup
Avoid test overspendSmall budget for test keys
Control agent costSeparate key and budget for Agent / IDE
Lower default costmodel: "auto" + tier: "economy"
Stable experiment costFixed tier or key budget
Debug one requestSend X-Request-ID on server requests

Balance and Budget

402 insufficient_quota usually comes from wallet balance, key budget, or tier balance. Check in this order:

  1. Personal or organization wallet balance.
  2. Balance for the requested tier.
  3. Daily / weekly budget on the API key.
  4. If routing returns no candidate, check tier, policy, wallet, and key budget.
  5. If premium is too expensive, try standard or economy.