Infer model capabilities from its name and pricing. Heuristic accuracy ~85%. The bandit/feedback system corrects errors over time via runtime observations.
(
model_id: str,
pricing: ModelPricing,
*,
has_explicit_pricing: bool = True,
)
| 236 | |
| 237 | |
| 238 | def infer_capabilities( |
| 239 | model_id: str, |
| 240 | pricing: ModelPricing, |
| 241 | *, |
| 242 | has_explicit_pricing: bool = True, |
| 243 | ) -> ModelCapabilities: |
| 244 | """Infer model capabilities from its name and pricing. |
| 245 | |
| 246 | Heuristic accuracy ~85%. The bandit/feedback system corrects errors |
| 247 | over time via runtime observations. |
| 248 | """ |
| 249 | name = model_id.lower() |
| 250 | core = name.split("/", 1)[-1] if "/" in name else name |
| 251 | provider = name.split("/", 1)[0] if "/" in name else "" |
| 252 | |
| 253 | reasoning = False |
| 254 | if any(p in core for p in _REASONING_POSITIVE): |
| 255 | if not any(p in core for p in _REASONING_NEGATIVE): |
| 256 | reasoning = True |
| 257 | if provider == "anthropic" and "opus" in core: |
| 258 | reasoning = True |
| 259 | |
| 260 | image_generation = not is_routable_chat_model(model_id) and "image" in core |
| 261 | |
| 262 | vision = False |
| 263 | if any(p in core for p in ("-vl", "vision", "image")): |
| 264 | vision = True |
| 265 | if provider in ("anthropic", "google"): |
| 266 | vision = True |
| 267 | if provider == "openai" and any(p in core for p in ("4o", "gpt-5", "gpt-4")): |
| 268 | vision = True |
| 269 | |
| 270 | tool_calling = not image_generation |
| 271 | |
| 272 | free = ( |
| 273 | has_explicit_pricing |
| 274 | and pricing.input_price <= 0.0 |
| 275 | and pricing.output_price <= 0.0 |
| 276 | ) |
| 277 | |
| 278 | return ModelCapabilities( |
| 279 | tool_calling=tool_calling, |
| 280 | vision=vision, |
| 281 | reasoning=reasoning, |
| 282 | free=free, |
| 283 | ) |
| 284 | |
| 285 | |
| 286 | # --------------------------------------------------------------------------- |