Reasoning-Effort Routing in an AI API Gateway: Control Thinking Tokens, Latency, and Cost Across Providers
Reasoning-capable models expose different controls for thinking depth, token budgets, billing, and latency. Treat reasoning effort as a governed runtime policy in the gateway, not as a loose model setting inside each application.
Reasoning depth is no longer a simple model option. Some providers expose enum-style effort levels. Others expose token budgets, dynamic thinking, or model families where thinking cannot be fully disabled. The visible answer may be short while hidden reasoning consumes billable output tokens. If every application team sets these controls directly, cost, latency, and quality become difficult to explain.
The practical answer is to move reasoning-effort control into the API gateway. The gateway should classify the workload, map it to a provider-specific reasoning control, enforce tenant budgets, record actual reasoning usage, and make downgrade decisions visible in analytics. Model ID, service tier, maximum output, and reasoning depth should be separate policy dimensions.
Reader Problem: Simple Requests Are Paying for Deep Reasoning
Teams adopting reasoning-capable models usually start with a reasonable goal: improve quality on hard tasks. The problem appears later, when the same defaults are reused for extraction, short summaries, formatting, and classification. Those requests do not need expensive test-time compute, but they may still trigger it.
This creates three operational failures:
- Cost opacity: the user sees a short answer, but the ledger contains hidden reasoning tokens or provider-specific equivalents.
- Latency drift: a workflow that looked interactive becomes slow because reasoning effort increased behind the same model alias.
- Policy fragmentation: each product team learns different provider parameters and applies different caps.
A gateway-level reasoning policy solves the control problem before it becomes a billing problem.
Facts: Provider Reasoning Controls Are Not Equivalent
The following are implementation facts, not recommendations.
- OpenAI reasoning-capable APIs expose a
reasoningobject for supported models, including effort values such asnone,minimal,low,medium,high, andxhigh. Lower effort can reduce reasoning tokens and improve response speed. - OpenAI documentation states that
max_output_tokenscan limit total generated tokens, including both reasoning and final output tokens. - Anthropic extended thinking can be enabled with a
budget_tokensvalue. Thinking tokens are billed as output tokens and count towardmax_tokensalongside visible response text. - Anthropic documentation also notes that billed output token count may not match visible response token count, because internal thinking tokens can be billed even when not fully visible.
- Gemini thinking documentation states that response pricing can include both output tokens and thinking tokens, with usage fields that separate thought tokens and output tokens.
- Gemini 2.5-style controls include
thinkingBudget, with dynamic thinking on supported models and zero-budget disabling on some model families. Some models cannot disable thinking. - Newer Gemini guidance recommends
thinking_levelvalues such asminimal,low,medium, andhighfor Gemini 3.x-style models instead of raw numeric budgets.
The core architecture implication is simple: do not expose provider-native reasoning controls as the only contract. They are not stable enough, portable enough, or comparable enough for multi-provider governance.
Recommendation: Create Provider-Neutral Reasoning Profiles
Define a small internal vocabulary that product teams can understand without reading every provider API reference. For most gateways, five profiles are enough:
| Internal profile | Purpose | Typical use | Policy posture |
|---|---|---|---|
none | Disable or minimize hidden reasoning where supported | Formatting, extraction, tagging, routing | Default for high-volume simple endpoints |
low | Light reasoning for modest ambiguity | Short support replies, simple comparisons, rewrite tasks | Allowed broadly |
standard | Balanced reasoning for routine knowledge work | Planning, code review, policy analysis, longer synthesis | Default for mixed workloads |
deep | Higher effort for difficult tasks | Debugging, math, security review, agent planning | Restricted by tenant, key, workflow, and budget |
capped-deep | High reasoning with a hard ceiling | Premium tasks where runaway cost is unacceptable | Requires explicit cap and analytics |
The profile is the application-facing contract. Provider parameters become adapter details. This keeps client code portable and lets platform owners update mappings as provider APIs change.
Map Workload Classes Before Mapping Providers
Reasoning effort should be chosen from workload intent, not from personal preference or model popularity. Add a gateway field such as workload_class, either supplied by the client or inferred from an approved route configuration.
Example Workload Policy
{
"workload_policies": {
"extract_invoice_fields": {
"default_reasoning_profile": "none",
"max_reasoning_profile": "low",
"max_output_tokens": 800
},
"classify_support_ticket": {
"default_reasoning_profile": "none",
"max_reasoning_profile": "low",
"max_output_tokens": 300
},
"draft_customer_reply": {
"default_reasoning_profile": "low",
"max_reasoning_profile": "standard",
"max_output_tokens": 1200
},
"code_review": {
"default_reasoning_profile": "standard",
"max_reasoning_profile": "deep",
"max_output_tokens": 4000
},
"security_review": {
"default_reasoning_profile": "deep",
"max_reasoning_profile": "capped-deep",
"max_output_tokens": 6000
},
"agent_plan": {
"default_reasoning_profile": "standard",
"max_reasoning_profile": "deep",
"max_output_tokens": 5000
}
}
}
This policy does two useful things. First, it prevents simple endpoints from inheriting costly defaults. Second, it gives administrators a concrete review surface: which workflows are allowed to request deep reasoning, and under what caps?
Build a Compatibility Matrix
The gateway adapter should maintain a matrix for every provider and model family. At minimum, store whether the model supports disabling reasoning, enum effort, numeric budget, dynamic thinking, maximum supported budget, and usage fields for reasoning tokens.
Example Matrix Shape
{
"providers": {
"provider_a": {
"model_family_x": {
"supports_reasoning": true,
"control_type": "effort_enum",
"allowed_values": ["none", "minimal", "low", "medium", "high", "xhigh"],
"can_disable": true,
"reports_reasoning_tokens": true
}
},
"provider_b": {
"model_family_y": {
"supports_reasoning": true,
"control_type": "budget_tokens",
"min_budget_tokens": 1024,
"max_budget_tokens": 32000,
"can_disable": false,
"reports_reasoning_tokens": true
}
},
"provider_c": {
"model_family_z": {
"supports_reasoning": true,
"control_type": "thinking_level",
"allowed_values": ["minimal", "low", "medium", "high"],
"can_disable": false,
"reports_reasoning_tokens": true
}
}
}
}
A compatibility matrix is not documentation for humans only. It should be executable policy. The request router should use it before dispatch, and the billing ledger should use it during settlement.
Translate Internal Profiles to Provider Parameters
Provider mappings should be explicit and versioned. Do not rely on a vague phrase such as “use smarter reasoning.” The gateway should know exactly which provider parameter was sent.
Example Mapping
{
"reasoning_profile_mappings": {
"none": {
"effort_enum": "none",
"budget_tokens": 0,
"thinking_level": "minimal"
},
"low": {
"effort_enum": "low",
"budget_tokens": 2048,
"thinking_level": "low"
},
"standard": {
"effort_enum": "medium",
"budget_tokens": 8192,
"thinking_level": "medium"
},
"deep": {
"effort_enum": "high",
"budget_tokens": 20000,
"thinking_level": "high"
},
"capped-deep": {
"effort_enum": "high",
"budget_tokens": 12000,
"thinking_level": "high"
}
}
}
These numbers are examples, not universal defaults. The right budgets depend on model family, pricing, latency requirements, and evaluation results. The important implementation detail is that the gateway owns the mapping and records the resolved provider parameter for every request.
Fail Closed When a Mapping Is Unsafe
Unsupported reasoning controls should not silently become provider defaults. Defaults can be expensive, and they may change over time.
Use one of three outcomes when a requested profile cannot be mapped safely:
- Allow: the provider/model supports the requested profile and the tenant policy permits it.
- Downgrade: the requested profile is above policy, so the gateway applies the highest approved profile and records the downgrade.
- Reject: the profile cannot be represented safely, the tenant requires strict behavior, or downgrade would violate product expectations.
Example Decision Record
{
"request_id": "req_123",
"tenant_id": "tenant_42",
"api_key_id": "key_abc",
"workflow": "code_review",
"requested_reasoning_profile": "deep",
"applied_reasoning_profile": "standard",
"decision": "downgraded",
"decision_reason": "tenant_monthly_deep_reasoning_budget_exceeded",
"served_provider": "provider_a",
"served_model": "model_family_x",
"provider_reasoning_param": {
"effort": "medium"
}
}
This decision record is valuable during support, billing disputes, and quality investigations. It also prevents invisible quality regressions during budget pressure.
Budget Controls Need More Than Max Output Tokens
A maximum output token limit is necessary, but it is not sufficient. For reasoning-capable models, the model can spend a large share of the limit reasoning and leave too little room for the final answer. The user may then pay for an unusable truncated response.
Use layered ceilings:
max_reasoning_profileper tenant, API key, and workflow.max_thinking_budgetor equivalent per provider/model pair.max_output_tokensfor total generated tokens where the provider counts reasoning and visible output together.daily_deep_reasoning_spendper tenant or reseller customer.deep_reasoning_requests_per_hourfor high-volume endpoints.reasoning_token_ratio_thresholdfor anomaly alerts.
The budget check should happen before dispatch. The settlement step should then reconcile actual usage after the provider response arrives. If the provider reports thinking tokens separately, store them separately. If it reports only total output tokens, store the best available normalized fields and mark the confidence level.
Ledger Fields for Reasoning Usage
Analytics must show the difference between visible answer length and paid reasoning effort. A useful ledger row should include:
tenant_id,api_key_id,end_user_id, andworkflow.requested_model,served_model, provider, and model alias.requested_reasoning_profileandapplied_reasoning_profile.provider_reasoning_param, stored as structured JSON.input_tokens,visible_output_tokens,reasoning_tokens_or_equivalent,cached_tokens, andtotal_billable_tokens.max_output_tokensand any provider-specific thinking budget.latency_to_first_token_ms,total_latency_ms, and stream completion status.estimated_cost_before_dispatch,reserved_budget,settled_cost, andreconciliation_status.policy_decision, such as allowed, downgraded, rejected, or fallback.
Do not log raw chain-of-thought by default. For most governance and FinOps work, counts and policy decisions are enough. Storing sensitive reasoning text can create avoidable privacy, compliance, and retention problems.
Implementation Flow
A production gateway can implement reasoning-effort routing as a deterministic request pipeline.
- Authenticate the request. Resolve tenant, API key, user, team, and workflow.
- Classify the workload. Use an explicit client field where possible. For known endpoints, bind workload class at route configuration.
- Load policy. Merge global, tenant, key, and workflow constraints.
- Select model candidates. Use the existing model alias or model-selection policy before resolving reasoning controls.
- Resolve reasoning profile. Start from the requested profile, then apply workflow defaults and maximums.
- Check compatibility. Confirm the provider/model pair supports the selected profile safely.
- Estimate cost and reserve budget. Include likely reasoning usage, not only visible output.
- Dispatch with provider-native parameters. Send enum effort, budget tokens, thinking level, or no reasoning control according to the adapter.
- Normalize usage on response. Separate input, visible output, reasoning, cached, tool, and total tokens where possible.
- Settle and alert. Reconcile reserved and actual cost, update quotas, and emit anomaly signals.
This pipeline keeps reasoning control auditable. It also gives platform teams a single place to change defaults when provider APIs evolve.
Evaluation Before Changing Defaults
Do not promote higher reasoning effort based only on a few impressive examples. Run evaluations before changing defaults for a workload class.
Measure at least four outcomes:
- Task quality: accuracy, reviewer acceptance, schema validity, or tool-call success.
- Latency: time to first token and total completion time.
- Cost: cost per request and cost per accepted answer.
- Failure modes: truncation, refusal, malformed output, excessive tool calls, or timeout.
The key metric is not “tokens per request.” A lower-token answer that fails validation may be more expensive after retries. A higher-reasoning answer may be justified for security review but wasteful for tagging tickets. Evaluate by workflow.
Trade-Offs
Reasoning governance adds control, but it is not free.
- Portability versus provider features: internal profiles keep application code portable, but advanced teams may need an approved escape hatch for provider-specific controls.
- Budget certainty versus quality: hard caps protect tenants from runaway spend, but overly tight caps can truncate useful answers after reasoning tokens are already spent.
- Dynamic thinking versus predictability: dynamic provider controls can improve convenience, but they weaken pre-dispatch cost estimates unless the gateway records actual usage and enforces settlement limits.
- Downgrade availability versus consistency: downgrading reasoning during budget pressure preserves availability, but the response should be labeled in telemetry and included in quality evaluation.
- Analytics versus privacy: reasoning-token metrics are useful, but raw reasoning traces should not be stored unless there is a deliberate, approved retention policy.
Prediction: Reasoning Policy Will Become a Standard Gateway Control
This is a prediction, not a verified fact: reasoning effort will become a normal production control alongside model routing, rate limits, service tiers, and token budgets. As providers continue to expose different thinking controls, application teams will have less appetite for hard-coding those differences into product code.
Gateways that treat reasoning as a governed runtime dimension will have clearer tenant billing, cleaner portability, and better control over latency. Gateways that treat it as an incidental model parameter will struggle to explain why short answers sometimes cost more than long ones.
Actionable Checklist
- Define internal profiles:
none,low,standard,deep, andcapped-deep. - Assign default and maximum profiles to each workload class.
- Build a provider/model compatibility matrix for reasoning controls.
- Translate profiles to provider-native parameters in the adapter layer.
- Fail closed when a requested profile cannot be mapped safely.
- Reserve budget before dispatch using reasoning-aware estimates.
- Record requested profile, applied profile, provider parameter, reasoning usage, visible output, latency, and cost.
- Add anomaly alerts for high reasoning-token ratios and deep reasoning in high-volume simple workflows.
- Run workflow-level evaluations before changing default effort.
- Avoid logging raw reasoning text by default; store counts and policy decisions instead.
Conclusion
Reasoning-capable models are useful because they can spend more compute on hard problems. That same capability becomes expensive when it is applied indiscriminately. The gateway should decide when deeper reasoning is allowed, how it maps to each provider, how much budget it can consume, and how the result is measured.
The durable pattern is to separate reasoning effort from model ID. Route by workload, cap by tenant policy, adapt per provider, and settle actual usage into the ledger. That turns reasoning from a hidden cost variable into an explicit control surface for AI API cost control.