diff --git a/hermes_cli/doctor.py b/hermes_cli/doctor.py index 9cd0a8a9ea0..33900b7cc2d 100644 --- a/hermes_cli/doctor.py +++ b/hermes_cli/doctor.py @@ -570,6 +570,7 @@ def run_doctor(args): # MiniMax APIs don't support /models endpoint — https://github.com/NousResearch/hermes-agent/issues/811 ("MiniMax", ("MINIMAX_API_KEY",), None, "MINIMAX_BASE_URL", False), ("MiniMax (China)", ("MINIMAX_CN_API_KEY",), None, "MINIMAX_CN_BASE_URL", False), + ("AI Gateway", ("AI_GATEWAY_API_KEY",), "https://ai-gateway.vercel.sh/v1/models", "AI_GATEWAY_BASE_URL", True), ] for _pname, _env_vars, _default_url, _base_env, _supports_health_check in _apikey_providers: _key = "" diff --git a/hermes_cli/setup.py b/hermes_cli/setup.py index e751811a183..c567dc70076 100644 --- a/hermes_cli/setup.py +++ b/hermes_cli/setup.py @@ -59,6 +59,7 @@ _DEFAULT_PROVIDER_MODELS = { "kimi-coding": ["kimi-k2.5", "kimi-k2-thinking", "kimi-k2-turbo-preview"], "minimax": ["MiniMax-M2.5", "MiniMax-M2.5-highspeed", "MiniMax-M2.1"], "minimax-cn": ["MiniMax-M2.5", "MiniMax-M2.5-highspeed", "MiniMax-M2.1"], + "ai-gateway": ["anthropic/claude-opus-4.6", "anthropic/claude-sonnet-4.6", "openai/gpt-5", "google/gemini-3-flash"], } @@ -724,6 +725,7 @@ def setup_model_provider(config: dict): "MiniMax (global endpoint)", "MiniMax China (mainland China endpoint)", "Anthropic (Claude models — API key or Claude Code subscription)", + "AI Gateway (Vercel — 200+ models, pay-per-use)", ] if keep_label: provider_choices.append(keep_label) @@ -1232,7 +1234,39 @@ def setup_model_provider(config: dict): _set_model_provider(config, "anthropic") selected_base_url = "" - # else: provider_idx == 9 (Keep current) — only shown when a provider already exists + elif provider_idx == 9: # AI Gateway + selected_provider = "ai-gateway" + print() + print_header("AI Gateway API Key") + pconfig = PROVIDER_REGISTRY["ai-gateway"] + print_info(f"Provider: {pconfig.name}") + print_info("Get your API key at: https://vercel.com/docs/ai-gateway") + print() + + existing_key = get_env_value("AI_GATEWAY_API_KEY") + if existing_key: + print_info(f"Current: {existing_key[:8]}... (configured)") + if prompt_yes_no("Update API key?", False): + api_key = prompt(" AI Gateway API key", password=True) + if api_key: + save_env_value("AI_GATEWAY_API_KEY", api_key) + print_success("AI Gateway API key updated") + else: + api_key = prompt(" AI Gateway API key", password=True) + if api_key: + save_env_value("AI_GATEWAY_API_KEY", api_key) + print_success("AI Gateway API key saved") + else: + print_warning("Skipped - agent won't work without an API key") + + # Clear custom endpoint vars if switching + if existing_custom: + save_env_value("OPENAI_BASE_URL", "") + save_env_value("OPENAI_API_KEY", "") + _update_config_for_provider("ai-gateway", pconfig.inference_base_url, default_model="anthropic/claude-opus-4.6") + _set_model_provider(config, "ai-gateway", pconfig.inference_base_url) + + # else: provider_idx == 10 (Keep current) — only shown when a provider already exists # Normalize "keep current" to an explicit provider so downstream logic # doesn't fall back to the generic OpenRouter/static-model path. if selected_provider is None: @@ -1269,6 +1303,7 @@ def setup_model_provider(config: dict): "minimax": "MiniMax", "minimax-cn": "MiniMax CN", "anthropic": "Anthropic", + "ai-gateway": "AI Gateway", "custom": "your custom endpoint", } _prov_display = _prov_names.get(selected_provider, selected_provider or "your provider") @@ -1402,7 +1437,7 @@ def setup_model_provider(config: dict): _set_default_model(config, custom) _update_config_for_provider("openai-codex", DEFAULT_CODEX_BASE_URL) _set_model_provider(config, "openai-codex", DEFAULT_CODEX_BASE_URL) - elif selected_provider in ("zai", "kimi-coding", "minimax", "minimax-cn"): + elif selected_provider in ("zai", "kimi-coding", "minimax", "minimax-cn", "ai-gateway"): _setup_provider_model_selection( config, selected_provider, current_model, prompt_choice, prompt, diff --git a/website/docs/user-guide/features/fallback-providers.md b/website/docs/user-guide/features/fallback-providers.md index f94e380d430..5df658e8e52 100644 --- a/website/docs/user-guide/features/fallback-providers.md +++ b/website/docs/user-guide/features/fallback-providers.md @@ -34,6 +34,7 @@ Both `provider` and `model` are **required**. If either is missing, the fallback | Provider | Value | Requirements | |----------|-------|-------------| +| AI Gateway | `ai-gateway` | `AI_GATEWAY_API_KEY` | | OpenRouter | `openrouter` | `OPENROUTER_API_KEY` | | Nous Portal | `nous` | `hermes login` (OAuth) | | OpenAI Codex | `openai-codex` | `hermes model` (ChatGPT OAuth) |