LLM Budget and Latency Constrained Routing: Per-Request Cost and Time Caps (2026)
A support-ticket classifier does not need the same latency or price envelope as a multi-file code refactor. When every call in an app points at one hard-coded model, you either overpay on trivial turns or blow past user-facing timeouts on slow providers.
On https://api.sentiogate.dev/v1, passing max_cost_usd and max_latency_ms alongside model: "auto" lets you declare per-request budget and latency targets directly in the JSON payload. SentioGate evaluates your enabled BYOK providers against those caps and routes to a qualifying model automatically.
As of 2026-10-31 (rechecked 2026-11-21).
Request parameters at a glance
| Field | Type | Applies to | Behavior |
|---|---|---|---|
max_cost_usd | number | model: "auto" (BYOK) | Filters enabled Vault candidates to models within your per-request cost target |
max_latency_ms | number | model: "auto" (BYOK) | Prioritizes providers meeting your latency target based on live telemetry |
strict_cost | boolean | model: "auto" (BYOK) | Selects the lowest-price qualifying model (same as route_preference: "strict_cost") |
router_metadata | boolean | All /v1/chat/completions | Includes router.model and router.provider in the JSON response |
If no enabled model satisfies both max_cost_usd and max_latency_ms simultaneously, SentioGate falls back to the closest available candidate so your request still completes rather than failing mid-flow.
Request and response example
curl https://api.sentiogate.dev/v1/chat/completions \
-H "Authorization: Bearer sg_live_your_gateway_key" \
-H "Content-Type: application/json" \
-d '{
"model": "auto",
"max_cost_usd": 0.002,
"max_latency_ms": 1800,
"router_metadata": true,
"messages": [
{"role": "user", "content": "Classify this ticket as billing, bug, or feature: Invoice PDF is blank."}
]
}'
When router_metadata: true is set, the returned payload reports which route handled the request:
{
"id": "chatcmpl_...",
"choices": [{ "message": { "role": "assistant", "content": "billing" } }],
"router": {
"model": "groq/llama-3.3-70b-versatile",
"provider": "groq"
}
}
When to use strict_cost instead of balanced routing
Balanced model: "auto" avoids picking an underpowered model on complex prompts. For offline batch classification, extraction, or synthetic data generation where unit price dominates, pass "strict_cost": true to force lowest-cost selection across your enabled Vault keys.
When per-request caps are not enough
- Hard-fail SLA enforcement: Because SentioGate falls back gracefully to the closest available model when no enabled candidate meets both caps, apps that require an immediate HTTP error instead of a best-effort answer should enforce that check in their own caller.
- Single-provider workloads: If every request in your service uses one pinned model on one provider, calling that provider directly removes an extra hop. See SentioGate vs OpenRouter and BYOK LLM gateway for when a router makes sense.
FAQ
How does SentioGate pick a model when max_cost_usd is set?
SentioGate evaluates your enabled Vault providers against your budget cap and selects a qualifying model automatically before dispatching the request.
What happens if no model satisfies both max_cost_usd and max_latency_ms?
Instead of dropping the request, SentioGate selects the closest available enabled candidate and records the chosen model in router metadata.
Does strict_cost work with the free community pool?
No. The free community pool routes model: "auto" to a single shared model for evaluation. max_cost_usd, max_latency_ms, and strict_cost apply when routing across your own Vault keys.
Can I inspect which model answered each request?
Yes. Pass router_metadata: true on /v1/chat/completions, or use the free developer calculators and LLM workload replay guide to audit routing behavior.