Usage & Billing

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

What to Check

QuestionWhere to look
Which model was usedX-DAOE-Used-Model or metadata.model
Which provider served itX-DAOE-Used-Provider
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

1{
2 "metadata": {
3 "model": "GLM-5",
4 "tier": "standard",
5 "billing": {
6 "credits_used": "0.2288",
7 "input_tokens": 54,
8 "output_tokens": 545
9 }
10 }
11}

Streaming responses append a metadata event before [DONE].

Usage Attribution

Use one API key per environment and workflow:

WorkflowRecommended key
Local developmentdev-chat-api
Production chat APIprod-chat-api
Codex / IDEcodex-dev
Background jobworker-summary

Cost Control

GoalSetup
Avoid test overspendSmall budget for development keys
Control agent costSeparate key and budget for Agent / IDE
Lower default costmodel: "auto" + tier: "economy"
Stable production costPinned model or fixed tier
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 a pinned model fails, test with model: "auto".
  5. If premium is too expensive, try standard or economy.