Generate reasoning/thinking configuration variants for a model. Returns a map of variant_name -> config options.
(model: &models::ModelInfo)
| 795 | /// Generate reasoning/thinking configuration variants for a model. |
| 796 | /// Returns a map of variant_name -> config options. |
| 797 | pub fn variants(model: &models::ModelInfo) -> HashMap<String, HashMap<String, serde_json::Value>> { |
| 798 | use serde_json::json; |
| 799 | |
| 800 | if !model.reasoning { |
| 801 | return HashMap::new(); |
| 802 | } |
| 803 | |
| 804 | let id = model.id.to_lowercase(); |
| 805 | |
| 806 | // Models that don't support configurable reasoning |
| 807 | if id.contains("deepseek") |
| 808 | || id.contains("minimax") |
| 809 | || id.contains("glm") |
| 810 | || id.contains("mistral") |
| 811 | || id.contains("kimi") |
| 812 | || id.contains("k2p5") |
| 813 | { |
| 814 | return HashMap::new(); |
| 815 | } |
| 816 | |
| 817 | // Grok special handling |
| 818 | if id.contains("grok") { |
| 819 | if id.contains("grok-3-mini") { |
| 820 | let npm = model.provider.as_ref().and_then(|p| p.npm.as_deref()); |
| 821 | if npm == Some("@openrouter/ai-sdk-provider") { |
| 822 | return [ |
| 823 | ( |
| 824 | "low".into(), |
| 825 | hashmap! {"reasoning" => json!({"effort": "low"})}, |
| 826 | ), |
| 827 | ( |
| 828 | "high".into(), |
| 829 | hashmap! {"reasoning" => json!({"effort": "high"})}, |
| 830 | ), |
| 831 | ] |
| 832 | .into_iter() |
| 833 | .collect(); |
| 834 | } |
| 835 | return [ |
| 836 | ("low".into(), hashmap! {"reasoningEffort" => json!("low")}), |
| 837 | ("high".into(), hashmap! {"reasoningEffort" => json!("high")}), |
| 838 | ] |
| 839 | .into_iter() |
| 840 | .collect(); |
| 841 | } |
| 842 | return HashMap::new(); |
| 843 | } |
| 844 | |
| 845 | let npm = model |
| 846 | .provider |
| 847 | .as_ref() |
| 848 | .and_then(|p| p.npm.as_deref()) |
| 849 | .unwrap_or(""); |
| 850 | let api_id = model |
| 851 | .provider |
| 852 | .as_ref() |
| 853 | .and_then(|p| p.api.as_deref()) |
| 854 | .unwrap_or(""); |