Custom endpoint users (DashScope/Alibaba, Z.AI, Kimi, DeepSeek, etc.) get wrong context lengths because their provider resolves as "openrouter" or "custom", skipping the models.dev lookup entirely. For example, qwen3.5-plus on DashScope falls to the generic "qwen" hardcoded default (131K) instead of the correct 1M. Add _infer_provider_from_url() that maps known API hostnames to their models.dev provider IDs. When the explicit provider is generic (openrouter/custom/empty), infer from the base URL before the models.dev lookup. This resolves context lengths correctly for DashScope, Z.AI, Kimi, MiniMax, DeepSeek, and Nous endpoints without requiring users to manually set context_length in config. Also refactors _is_known_provider_base_url() to use the same URL mapping, removing the duplicated hostname list.
34 KiB
34 KiB