Routing

JoyToken selects the model and provider for every request. Send model: "auto" and control the eligible routing range with tier and API key policy.

Common Requests

GoalRequest
Automatic routingmodel: "auto"
Select a tiermodel: "auto" + `tier: “economy"
Restrict eligible modelsSet a model blacklist in API key policy

Tiers

TierUse
economyCost-first, batch, low-risk tasks
standardBalanced default
premiumQuality-first or critical evaluation tasks

Wallet Fallback

When the request uses model: "auto" and the current tier lacks balance, JoyToken may try another tier allowed by policy.

Current tierFallback order
premiumstandard -> economy
standardpremium -> economy
economystandard -> premium

Concrete model IDs are not accepted in requests. If policy, balance, or budget filtering leaves no eligible candidate, the request returns an error.

Orchestration (Multi-task Planning)

For complex prompts, JoyToken may handle a single model: "auto" request in orchestration mode: it first builds a task plan, runs each task with a selected sub-model, then aggregates a final answer. You do not opt in explicitly; the gateway decides based on the request.

How to detect it

SignalMeaning
plan (top level)Ordered task list, present only in orchestration mode
choices[].message.contentA JSON-encoded array of per-task outputs (content + title) instead of a single string
metadata (array)One entry per task, including reserved __planner__ and __final__ tasks
streaming planning eventA leading chunk whose orchestration.phase is planning carries the ordered plan, followed by the __planner__ metadata event
streaming task chunkEach task’s content chunk carries an orchestration field (task_id, task_seq, task_status, title)
streaming metadata eventOne standalone metadata event per task (a single object, not an array), emitted right after that task’s content

Task lifecycle

FieldMeaning
task_idTask identifier; __planner__ and __final__ are reserved
task_seqExecution order; 0 is the planner
task_statusTask status, e.g. DONE
tagTask role, e.g. orchestration, search, reasoning, writing, aggregation
titleHuman-readable task title

In orchestration mode each task is billed separately (one metadata/billing entry per task) and may use a different sub-model. Parse choices[].message.content as JSON before rendering, and sum billing.credits_used across all task metadata entries.

Confirm Routing

SignalMeaning
metadata.modelFinal JoyToken model
metadata.tierBilling and routing tier
metadata.billingCredits and token usage

Troubleshooting

SymptomCheck first
tier not allowedAPI key policy allows the tier
no eligible modeltier, blacklist, wallet, and key budget
IP not allowedserver egress IP is allowlisted
auto failspolicy, tier, and balance still leave candidate models
concrete model ID rejectedreplace it with auto