{"record":{"id":"422bf90ed84ed46d","repo":"NousResearch/hermes-agent","slug":"provider-explicit-is-set-in-config-yaml-but-n","errorCode":null,"errorMessage":"Provider '{_explicit}' is set in config.yaml but no API key was found. Set the {_env_hint} environment variable, or switch to a different provider with `hermes model`.","messagePattern":"Provider '(.+?)' is set in config\\.yaml but no API key was found\\. Set the (.+?) environment variable, or switch to a different provider with `hermes model`\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"agent/agent_init.py","lineNumber":1352,"sourceCode":"                            agent.model = _fb_model or _fb[\"model\"]\n                            agent._fallback_activated = True\n                            client_kwargs = {\n                                \"api_key\": _fb_client.api_key,\n                                \"base_url\": str(_fb_client.base_url),\n                            }\n                            if _provider_timeout is not None:\n                                client_kwargs[\"timeout\"] = _provider_timeout\n                            _fb_headers = getattr(_fb_client, \"_custom_headers\", None)\n                            if not _fb_headers:\n                                _fb_headers = getattr(_fb_client, \"default_headers\", None)\n                            if not _fb_headers:\n                                _fb_headers = getattr(_fb_client, \"_default_headers\", None)\n                            if _fb_headers:\n                                client_kwargs[\"default_headers\"] = dict(_fb_headers)\n                            _fb_resolved = True\n                            break\n                    if not _fb_resolved:\n                        raise RuntimeError(\n                            f\"Provider '{_explicit}' is set in config.yaml but no API key \"\n                            f\"was found. Set the {_env_hint} environment \"\n                            f\"variable, or switch to a different provider with `hermes model`.\"\n                        )\n                if not getattr(agent, \"_fallback_activated\", False):\n                    # No provider configured — reject with a clear message.\n                    raise RuntimeError(\n                        \"No LLM provider configured. Run `hermes model` to \"\n                        \"select a provider, or run `hermes setup` for first-time \"\n                        \"configuration.\"\n                    )\n        \n        agent._client_kwargs = client_kwargs  # stored for rebuilding after interrupt\n\n        # Enable fine-grained tool streaming for Claude on OpenRouter.\n        # Without this, Anthropic buffers the entire tool call and goes\n        # silent for minutes while thinking — OpenRouter's upstream proxy\n        # times out during the silence.  The beta header makes Anthropic","sourceCodeStart":1334,"sourceCodeEnd":1370,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/agent/agent_init.py#L1334-L1370","documentation":"Raised during AIAgent init when config.yaml names an explicit provider (the `_explicit` value) but no API key for it could be resolved anywhere: the provider-fallback resolution loop finished with _fb_resolved still False. This is a pure configuration error — the provider is selected, its credential is not.","triggerScenarios":"config.yaml sets model.provider while the matching env var (named by `_env_hint`) is absent from .env/environment, no credential-pool entry supplies a key, and no auxiliary fallback resolves, so every iteration of the fallback-resolution loop fails to build a client.","commonSituations":"Fresh install where `hermes model` picked a provider but the key was never entered; key deleted from ~/.hermes/.env; provider name typo so the expected env var is never consulted; hermetic CI with credential env vars unset.","solutions":["Set the provider's API key in ~/.hermes/.env using the exact variable named in the error's env hint","Run `hermes model` and switch to a provider whose key you have","Run `hermes setup` for guided first-time configuration","Verify the key lives in the active profile's HERMES_HOME/.env and the provider name in config.yaml is spelled exactly"],"exampleFix":"# ~/.hermes/.env — before\n# (no OPENAI_API_KEY line)\n\n# after\nOPENAI_API_KEY=sk-...","handlingStrategy":"validation","validationCode":"import os\n\ndef provider_key_present(provider: str) -> bool:\n    var = f\"{provider.upper().replace('-', '_')}_API_KEY\"\n    return bool(os.environ.get(var))\n\nassert provider_key_present(configured_provider), (\n    f\"Set {configured_provider.upper()}_API_KEY before starting hermes\"\n)","typeGuard":null,"tryCatchPattern":"try:\n    agent = AIAgent(...)\nexcept RuntimeError as e:\n    if \"no API key was found\" in str(e):\n        prompt_user_for_key(str(e))  # surface env hint from the message\n    else:\n        raise","preventionTips":["Provision the provider's API key in ~/.hermes/.env before selecting that provider in `hermes model`","In CI, fail fast on missing credential env vars in a pre-flight check rather than at agent init","Keep provider names in config.yaml exact — a typo bypasses the correct env var lookup"],"tags":["config","provider","api-key","initialization"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}