Merge pull request #40902 from BerriAI/litellm_openai_reasoning_fallback_rule

feat(registry): add openai reasoning-family fallback generalization
This commit is contained in:
kerry-berri 2026-09-12 16:27:16 -07:00 committed by GitHub
commit d565031b9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 61 additions and 0 deletions

View file

@ -57496,6 +57496,14 @@
"model_info": {
"supports_reasoning": true
}
},
{
"name": "openai-reasoning-family-baseline",
"pattern": "^(?!.*search-api)(?:[a-z0-9_.-]+/)*(?:ft:)?(?:o[1-9]\\d*(?![a-z0-9])|gpt-[5-9](?:\\.\\d+)?(?![0-9.])|(?:gpt-\\d+(?:\\.\\d+)?(?:-[a-z0-9]+)*-)?(?:codex|deep-research|chat-latest)(?![a-z0-9]))",
"description": "OpenAI reasoning families by id shape, under any provider namespace and with an optional ft: prefix: the o-series (o1, o3-pro, o4-mini), gpt-5 through gpt-9 majors including dotted minors and suffixed variants (gpt-5.5-cyber, gpt-6-astra), and the codex, deep-research and chat-latest lines when standalone or on a gpt base. gpt-5-search-api is excluded because it is a search-only surface. Every model here is a reasoning model, and the Responses API drops the caller's reasoning param for any mapped OpenAI model whose info lacks supports_reasoning, so an id the registry has not named yet keeps its reasoning settings instead of silently losing them. Rules lose to exact entries. Carries no mode and no pricing, so cost stays on the standard unpriced behavior.",
"model_info": {
"supports_reasoning": true
}
}
]
},

View file

@ -57496,6 +57496,14 @@
"model_info": {
"supports_reasoning": true
}
},
{
"name": "openai-reasoning-family-baseline",
"pattern": "^(?!.*search-api)(?:[a-z0-9_.-]+/)*(?:ft:)?(?:o[1-9]\\d*(?![a-z0-9])|gpt-[5-9](?:\\.\\d+)?(?![0-9.])|(?:gpt-\\d+(?:\\.\\d+)?(?:-[a-z0-9]+)*-)?(?:codex|deep-research|chat-latest)(?![a-z0-9]))",
"description": "OpenAI reasoning families by id shape, under any provider namespace and with an optional ft: prefix: the o-series (o1, o3-pro, o4-mini), gpt-5 through gpt-9 majors including dotted minors and suffixed variants (gpt-5.5-cyber, gpt-6-astra), and the codex, deep-research and chat-latest lines when standalone or on a gpt base. gpt-5-search-api is excluded because it is a search-only surface. Every model here is a reasoning model, and the Responses API drops the caller's reasoning param for any mapped OpenAI model whose info lacks supports_reasoning, so an id the registry has not named yet keeps its reasoning settings instead of silently losing them. Rules lose to exact entries. Carries no mode and no pricing, so cost stays on the standard unpriced behavior.",
"model_info": {
"supports_reasoning": true
}
}
]
},

View file

@ -677,3 +677,48 @@ def test_deployment_model_info_beats_the_seeded_rule_defaults(shipped_cost_map):
assert litellm.model_cost[model]["supports_reasoning"] is False
assert litellm.supports_reasoning(model="some-org/NoThink-1", custom_llm_provider="wandb") is False
def test_shipped_rules_flag_unmapped_openai_reasoning_families(shipped_cost_map):
for model in (
"gpt-5.7-nova",
"openai/gpt-6",
"ft:gpt-5.1-2025-11-13:org::abc",
"o5-mini",
"gpt-5.6-codex-max",
"o4-mini-deep-research-2027-01-01",
"gpt-5.7-chat-latest",
"azure/gpt-5.7-cyber",
"openai/codex-mini-latest-2027",
):
assert model not in litellm.model_cost, model
assert match_capability_generalizations(model) == {"supports_reasoning": True}, model
info = litellm.get_model_info("gpt-5.7-nova", custom_llm_provider="openai")
assert info["litellm_provider"] == "openai"
assert info["supports_reasoning"] is True
assert info.get("mode") is None
assert not info.get("input_cost_per_token")
assert litellm.supports_reasoning(model="gpt-5.7-nova", custom_llm_provider="openai") is True
def test_shipped_openai_reasoning_rule_skips_non_reasoning_gpt_ids(shipped_cost_map):
for model in (
"gpt-4o",
"gpt-4.1-nano-new",
"gpt-oss-120b",
"gpt-realtime-2027",
"gpt-image-2",
"gpt-5-search-api-2027-01-01",
"omni-moderation-new",
"text-embedding-4",
"vendor/my-codex-embedding",
"some-codex-model",
"azure/gpt-35-turbo-0125-custom",
"github_copilot/gpt-41-copilot-new",
):
assert match_capability_generalizations(model) is None, model
def test_shipped_openai_reasoning_rule_loses_to_mapped_entries(shipped_cost_map):
assert "gpt-5-search-api" in litellm.model_cost
assert litellm.supports_reasoning(model="gpt-5-search-api", custom_llm_provider="openai") is False