https://api.getnadir.com/v1/bucketClassify a prompt into a complexity tier and return the execution plan that follows from it. No configuration, no LLM call.
Tip
Authentication
Optional. Send X-API-Key to get your account's rate limits and have the decision recorded in your analytics. Without it the call runs on the anonymous tier and the response carries an extra anon object.
Request body
promptstringRaw prompt text to classify. Supply this or messages.
messagesobject[]OpenAI-style message list, used when prompt is omitted.
sourcestringChannel tag for aggregate stats. Recognized values are claude-skill, site-demo, and direct. Anything else is recorded as other.
contextobjectCaller-session context. Every field is optional. Supplying it turns plan from a tier and effort rule into a costed delegate versus inline comparison. See below.
cacheobjectCache state for this request on the current model: include the exact model and measured cached_tokens. Zero means confirmed cold; omit the whole block when unknown. An omitted token count inside a cache block makes the API assume the whole input is cached. Supply current_input_tokens, ttl (5m or 1h), and seconds_since_last_request when known. Optional expected_remaining_turns controls the comparison horizon (default 3).
rolestringWhich part of a coding agent is asking: main, subagent, or utility. Any string is accepted, it is only a key into agent_policy. Sending it, or requested_model, turns on role_resolution.
requested_modelstringThe model the agent would have called without Nadir.
agent_policyobjectRole to model map, for example {"subagent": "claude-haiku-4-5"}. A value is a model id, passthrough to leave requested_model alone, or auto to let the router decide. Wins over the policy stored on the account. Keyless callers must send it.
struggleobjectContent-free counters for this thread: {err, run, rep, tot} integers for error tool results, longest consecutive error run, most errors on one tool, and total tool results, plus an optional ast for the assistant turns in the same window. Counted on your side. Escalation reads the four tool error counters and nothing else, so ast is recorded rather than interpreted and an unknown key is ignored. A struggling non-main thread has its policy downgrade suspended.
ladderobjectYour tier-to-model mapping. The entry for the decided tier becomes selected_model. An explicit ladder entry wins over a menu-derived entry.
menustring[]Up to 100 model ids your harness can run, from any vendor. Nadir ranks only this catalog, returns the full ordering in ranking, and returns the executable winner in selected_model.
axesstring[]Optional capability requirements: coding, math, and agentic.
Response
bucketstringrequiredsimple, medium, or complex.
bucket_indexintegerrequired1 for simple, 2 for medium, 3 for complex.
confidencenumberClassifier confidence in the range 0 to 1.
complexity_scorenumberScalar complexity in the range 0 to 1.
probabilitiesobjectrequiredFull tier distribution across simple, medium, and complex.
decodestringrequiredHow the returned bucket relates to the argmax of probabilities. See the note below.
prompt_tokensintegerrequiredApproximate input tokens, counted at roughly 4 characters per token.
encoder_tokensinteger | nullFull input length measured by the classifier tokenizer. Null means coverage could not be verified.
input_truncatedboolean | nullWhether the classifier saw only a prefix. Automatic model changes require false and a positive integer encoder token count.
analyzer_hashstringrequiredOpaque fingerprint of the classifier that decided. Useful for correlating decisions across a model rollout.
request_idstringrequiredCorrelates with the logged analytics row.
latency_msintegerrequiredDecision latency in milliseconds.
routing_tierstringrequiredThe authoritative model-agnostic level after deterministic tier adjustments. Map this in your own catalog when no model was selected.
selected_modelstring | nullThe authoritative executable model after catalog selection, role policy, governance, inline reuse, and request policy. Null when the request supplied no actionable model context.
selected_effortstring | nullEffort for selected_model. Null means omit the provider parameter.
cache_adviceobject | nullSeparate model-switch advice when cache state was supplied. A stay_warm decision means keep the original model. This endpoint does not apply it to selected_model for you.
planobjectrequiredDeterministic execution and cost detail. Its legacy model and effort fields are retained for compatibility; new integrations bind to the top-level selected fields.
anonobjectPresent only on anonymous calls. Null when a key was sent.
role_resolutionobjectWhich model an agent role should run on under your own policy. Null unless the request carried role or requested_model. Purely additive: plan never changes meaning when it is present. See below.
Warning
bucket and its probabilities are what the classifier predicted. Everything inside plan is a rule applied on top of that prediction, with one exception: on coding-agent calls (an agent integration as source, and a role other than subagent), effort starts from a trained effort head that predicts how much work the turn will take, and basis says effort_head. Your baseline, your ceiling and the model's own limits still apply. plan.basis lists which rules and inputs produced the plan, so you can report the prediction and the policy separately.Info
/v1/bucket always returns the level in routing_tier. It returns a model only when your request or stored policy provides actionable model context. Without a menu, ladder, requested model, warm model, or fixed role policy, both selected_model and selected_effort are null.Info
cache_advice.decision is stay_warm. Use selected_model only if your client can run it; a present null means keep the original. Do not replace it with plan.model or a fresh tier mapping. Preserve explicit effort settings and check that the selected model supports them. A decision is a recommendation; report actual execution and cost only from the completed request.Reading decode
The final bucket is not always the argmax of the distribution. A separate gate can promote a prompt to complex, and decode tells you when that happened rather than leaving you to infer it from a low confidence and a mismatched argmax.
argmax: the bucket and the argmax agree.complex_gate: the gate promoted this to complex over a lower-tier argmax. The probabilities shown are the pre-gate distribution andconfidenceis the gate's probability of complex.below_gate: the gate held the prompt below complex despite a complex argmax.
{
"bucket": "complex",
"bucket_index": 3,
"confidence": 0.19188758559529426,
"complexity_score": 0.6798222959041595,
"probabilities": {
"simple": 0.060963574796915054,
"medium": 0.5184282660484314,
"complex": 0.42060816287994385
},
"decode": "complex_gate",
"prompt_tokens": 42,
"analyzer_hash": "83d427b13dc6",
"request_id": "3df61f2a-b294-4bfe-b817-930723ea7abb",
"latency_ms": 145,
"plan": {
"execute": "delegate",
"model": "claude-opus-4-6",
"effort": "high",
"tier": "complex",
"reason": "no warm model declared, so there is no inline alternative to price",
"basis": ["bucket", "effort_policy_map", "no_warm_model"],
"inline_cost_usd": null,
"delegate_cost_usd": null,
"delta_usd": null,
"turns": null,
"break_even_turns": null,
"warnings": []
}
}Costing delegate against inline
If you are deciding whether to hand a task to a fresh sub-agent or run it on the model already warm in your session, send context. The plan then prices both sides instead of defaulting to delegate.
context.warm_modelstringThe model holding a warm prompt cache in your session, meaning the model that would run this task if you did not delegate it. Without it there is no inline alternative to price.
subagent_typestringYour harness's own name for the kind of agent being spawned. Claude Code's Agent tool passes one: Explore, general-purpose, or any agent the user has defined. Recorded, not interpreted. It is the grouping key that makes turns-per-kind-of-agent measurable from your own traffic, which is the input the horizon below is otherwise guessing at.
context.expected_turnsintegerHow many turns this task will take. The field that decides execute: an agent task is a loop, and every turn after the first re-reads the whole context on whichever model is running it, so the break-even is a turn count rather than a prompt size. The same number applies to both branches. When omitted, the plan is priced over an assumed 2, the floor for a tool-using agent, and break_even_turns comes back so you can see where the answer would change.
context.warm_prefix_tokensintegerSize of the prefix already cached on warm_model. From turn two onward this is the largest single term on the inline side. When omitted it is assumed equal to delegate_prefix_tokens as a floor; an explicit 0 is honoured as zero.
context.delegate_prefix_tokensintegerFixed prefix a freshly spawned agent pays before it reads the task, meaning its system prompt plus tool schemas. The most load-bearing input here. Measure it once and send it. When omitted, a placeholder is used and plan.basis reports default_delegate_prefix.
context.delegation_prompt_tokensintegerTokens spent writing the delegation prompt. These are output tokens on the warm model, so they are frequently the largest single term on the delegate side. Defaults to 250.
curl https://api.getnadir.com/v1/bucket \
-H "Content-Type: application/json" \
-d '{
"prompt": "Rename the variable foo to bar in utils.py",
"context": {
"warm_model": "claude-opus-4-6",
"warm_prefix_tokens": 18000,
"delegate_prefix_tokens": 12000
}
}'{
"bucket": "simple",
"bucket_index": 1,
"confidence": 0.9300831864622364,
"complexity_score": 0.07632201549131423,
"probabilities": {
"simple": 0.848347008228302,
"medium": 0.1506618708372116,
"complex": 0.000991080072708428
},
"decode": "argmax",
"prompt_tokens": 10,
"analyzer_hash": "83d427b13dc6",
"request_id": "c0c5a1c9-c365-4794-90dd-1fedfaa52d37",
"latency_ms": 446,
"plan": {
"execute": "inline",
"model": "claude-haiku-4-5",
"effort": null,
"tier": "simple",
"reason": "claude-haiku-4-5 does not accept an effort parameter; omit it; over 2 turn(s) the task does not amortize a cold claude-haiku-4-5 context (~12000 tok prefix); running inline on the warm claude-opus-4-6 is $0.003656 cheaper (delegating wins from 3 turns)",
"basis": [
"bucket",
"effort_policy_map",
"measured_delegate_prefix",
"assumed_turns",
"second_turn_reread",
"cache_arithmetic"
],
"inline_cost_usd": 0.034055,
"delegate_cost_usd": 0.037711,
"delta_usd": 0.003656,
"turns": 2,
"break_even_turns": 3,
"warnings": []
}
}The tier is still simple, but the plan says run it inline. A 12,000 token cold prefix costs more than this task saves over the two turns it was priced across, so delegating would have been the more expensive choice. Note break_even_turns: the same task run for three turns or more flips the answer, because every extra turn re-reads the whole context on whichever model is doing the work. The horizon here was assumed, not declared, which basis reports as assumed_turns.
Effort is a policy, not a prediction
Bind to selected_effort. It is null when no model was selected, when the selected model does not accept the parameter, or when Nadir has not explicitly modeled that provider's effort enum. Sending a guessed value can produce a provider 400, so omit the field when it is null.
Resolving a role to a model
Coding agents ask the same endpoint a second question: not just how hard is this task, but which model should this role run on. Send role or requested_model and the response gains a role_resolution object beside plan. It shows your role policy applied to the model the agent already asked for. New clients execute the top-level selected_model, which composes that result with governance, inline reuse, and request policy.
role_resolution.rolestringThe role the resolution was made for. Defaults to subagent when only requested_model was sent.
role_resolution.requested_modelstringThe model you asked for, echoed back.
role_resolution.modelstringThe model to run this role on. Advisory: nothing is called on your behalf.
role_resolution.policy_appliedbooleanTrue when agent_policy moved the model off requested_model.
role_resolution.decided_bystringWhat produced the model. policy is a fixed mapping. router means the mapping was auto, so this is the per-task tier decision expressed in the caller's available catalog. passthrough means no mapping applied, or one was lifted by an escalation. ladder means nothing was requested and nothing mapped, so this is plan.model.
role_resolution.escalationstringStruggle advisory: tool_churn or error_loop, prefixed suspended: when the struggle lifted a policy downgrade. Null when the thread is fine.
curl https://api.getnadir.com/v1/bucket \
-H "Content-Type: application/json" \
-d '{
"prompt": "Rename the variable foo to bar in utils.py",
"role": "subagent",
"requested_model": "claude-opus-4-6",
"agent_policy": { "subagent": "claude-haiku-4-5" }
}'"role_resolution": {
"role": "subagent",
"requested_model": "claude-opus-4-6",
"model": "claude-haiku-4-5",
"policy_applied": true,
"decided_by": "policy",
"escalation": null
}A policy value of auto hands the role to the router instead of pinning it: the model becomes the per-task tier decision in your catalog, and decided_by reads router. Use it for a role that should be right-sized task by task. passthrough, or no entry for the role at all, leaves requested_model untouched.
Warning
struggle and a thread churning on tool errors gets its downgrade lifted: the model returns to requested_model, policy_applied goes back to false, decided_by becomes passthrough, and escalation reads suspended:tool_churn or suspended:error_loop. An unprefixed value means the thread looks stuck but there was no downgrade to lift, either because no policy applied or because the role is main, which is never suspended this way. While a suspended: value is set, stop downgrading that thread.Errors
429rate_limitedToo many anonymous requests in a short window. This is a burst throttle, not a quota. Back off for Retry-After seconds, or send an API key for higher limits.
403anonymous_disabledThe anonymous tier is turned off on this deployment. Use a free API key.