| 93 | |
| 94 | |
| 95 | def model_served_quality( |
| 96 | model_id: str, |
| 97 | lane: CapabilityLane, |
| 98 | capabilities: ModelCapabilities | None = None, |
| 99 | ) -> ServedQuality: |
| 100 | provider, core = _provider_and_core(model_id) |
| 101 | caps = capabilities or ModelCapabilities() |
| 102 | explicitly_non_reasoning = _contains_any(core, _REASONING_NEGATIVE_MARKERS) |
| 103 | |
| 104 | if lane is CapabilityLane.ANTHROPIC_TOOL_SAFE: |
| 105 | if provider == "anthropic": |
| 106 | if "opus" in core: |
| 107 | return ServedQuality.PREMIUM |
| 108 | if "sonnet" in core: |
| 109 | return ServedQuality.BALANCED |
| 110 | return ServedQuality.ECONOMY |
| 111 | if provider == "minimax": |
| 112 | if "m2.7" in core: |
| 113 | return ServedQuality.PREMIUM |
| 114 | if "m2.5" in core: |
| 115 | return ServedQuality.BALANCED |
| 116 | return ServedQuality.ECONOMY |
| 117 | |
| 118 | if lane is CapabilityLane.REASONING: |
| 119 | if explicitly_non_reasoning: |
| 120 | return ServedQuality.ECONOMY |
| 121 | if provider == "anthropic" and "opus" in core: |
| 122 | return ServedQuality.PREMIUM |
| 123 | if provider == "deepseek" and "r1" in core: |
| 124 | return ServedQuality.PREMIUM |
| 125 | if provider in {"xai", "x-ai"} and "reason" in core and not explicitly_non_reasoning: |
| 126 | return ServedQuality.PREMIUM |
| 127 | if ("thinking" in core or "reason" in core) and not explicitly_non_reasoning: |
| 128 | return ServedQuality.PREMIUM |
| 129 | if provider == "openai" and _contains_any(core, ("pro", "o3", "gpt-5.4", "gpt-5.2", "gpt-5")): |
| 130 | if "nano" in core: |
| 131 | return ServedQuality.ECONOMY |
| 132 | if "mini" in core: |
| 133 | return ServedQuality.BALANCED |
| 134 | return ServedQuality.PREMIUM |
| 135 | if provider == "google" and "pro" in core: |
| 136 | return ServedQuality.PREMIUM |
| 137 | if caps.reasoning and not explicitly_non_reasoning: |
| 138 | return ServedQuality.BALANCED |
| 139 | |
| 140 | if lane is CapabilityLane.VISION: |
| 141 | if provider == "anthropic" and "opus" in core: |
| 142 | return ServedQuality.PREMIUM |
| 143 | if provider == "google" and "pro" in core: |
| 144 | return ServedQuality.PREMIUM |
| 145 | if provider == "openai" and "pro" in core: |
| 146 | return ServedQuality.PREMIUM |
| 147 | if provider == "qwen" and "vl" in core: |
| 148 | return ServedQuality.BALANCED |
| 149 | if provider in {"anthropic", "google", "openai"}: |
| 150 | return ServedQuality.BALANCED |
| 151 | |
| 152 | if provider == "anthropic": |