Adopt a model/provider-aware configuration standard: before sending requests to LLM APIs, validate that every model-specific parameter (reasoning effort, thinking features, temperature constraints, system support) is supported for that exact model/provider, and apply overrides safely without accidentally changing unrelated limits.
Apply these rules: 1) Validate model capability before passing parameters
reasoning_effort values; whether thinking/extended thinking requires temperature=1; whether system is ignored or unsupported).2) Distinguish input-token vs output-token limits
max_tokens passed to LiteLLM/OpenAI-style APIs as OUTPUT-only, and use the correct separate config for INPUT limits.3) When overriding, cap instead of overwriting
max_tokens), do not overwrite an already-computed/earlier value; cap it (min(existing, override)) so other logic remains intact.4) Use real token measurement—avoid heuristic clipping
5) Don’t introduce model/provider IDs without authoritative references
Example pattern (safe reasoning_effort + capability validation):
supported = {
# model_prefix: allowed_values (or None to omit)
"gpt-5": {"minimal","low","medium","high"},
"gpt-5.1": {"none","low","medium","high"},
"gpt-5.2": {"none","minimal","low","medium","high","xhigh"},
}
def choose_reasoning_effort(model: str, requested: str | None) -> str | None:
# pick the best match (implementation depends on your naming scheme)
allowed = None
for prefix, vals in supported.items():
if model.startswith(prefix):
allowed = vals
break
if not allowed:
return requested # or None (omit) if you don’t know
if requested in allowed:
return requested
return "medium" # or omit parameter so API defaults apply
Once this standard is in place, you’ll prevent common production failures: API errors from unsupported parameter combinations, truncated outputs from incorrect token caps, and accidental behavior changes from overwritten limits.