{"record":{"id":"d4008e30bcb72f05","repo":"nexu-io/open-design","slug":"xai-selected-but-xai-api-key-is-not-configured","errorCode":null,"errorMessage":"xAI selected but XAI_API_KEY is not configured.","messagePattern":"xAI selected but XAI_API_KEY is not configured\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"design-templates/last30days/scripts/lib/providers.py","lineNumber":315,"sourceCode":"    if provider_name == \"openai\":\n        if not openai_token or config.get(\"OPENAI_AUTH_STATUS\") != env.AUTH_STATUS_OK:\n            raise RuntimeError(\"OpenAI selected but no valid OpenAI auth is configured.\")\n        runtime = schema.ProviderRuntime(\n            reasoning_provider=\"openai\",\n            planner_model=planner_model,\n            rerank_model=rerank_model,\n\n            x_search_backend=_resolve_x_backend(config),\n        )\n        return runtime, OpenAIClient(\n            openai_token,\n            config.get(\"OPENAI_AUTH_SOURCE\") or env.AUTH_SOURCE_API_KEY,\n            config.get(\"OPENAI_CHATGPT_ACCOUNT_ID\"),\n        )\n\n    if provider_name == \"xai\":\n        if not xai_key:\n            raise RuntimeError(\"xAI selected but XAI_API_KEY is not configured.\")\n        runtime = schema.ProviderRuntime(\n            reasoning_provider=\"xai\",\n            planner_model=planner_model,\n            rerank_model=rerank_model,\n\n            x_search_backend=_resolve_x_backend(config),\n        )\n        return runtime, XAIClient(xai_key)\n\n    if provider_name == \"openrouter\":\n        openrouter_key = config.get(\"OPENROUTER_API_KEY\")\n        if not openrouter_key:\n            raise RuntimeError(\"OpenRouter selected but OPENROUTER_API_KEY is not configured.\")\n        runtime = schema.ProviderRuntime(\n            reasoning_provider=\"openrouter\",\n            planner_model=planner_model,\n            rerank_model=rerank_model,\n            x_search_backend=_resolve_x_backend(config),","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/design-templates/last30days/scripts/lib/providers.py#L297-L333","documentation":"Raised in resolve_runtime when provider_name is 'xai' but the XAI_API_KEY config value is falsy. xAI has no auth-status handshake like OpenAI; the key alone is the gate, so an empty key is a hard failure.","triggerScenarios":"LAST30DAYS_REASONING_PROVIDER=xai without XAI_API_KEY set. Auto-resolution selected xai because google/openai/openrouter were all absent, but XAI_API_KEY was also missing (note: auto only selects xai when xai_key is truthy, so this path implies explicit selection).","commonSituations":"Explicitly pinning provider=xai in config while the key is in a different env (e.g. XAI_KEY vs XAI_API_KEY typo). Key redacted in CI secrets map.","solutions":["Set XAI_API_KEY to a valid xAI console key.","If you do not have an xAI key, switch provider to one whose credentials you have, or to 'auto'.","Double-check the env-var name: it must be exactly XAI_API_KEY (not XAI_KEY or XAI_TOKEN)."],"exampleFix":"# before\nLAST30DAYS_REASONING_PROVIDER=xai\n# no key\n\n# after\nLAST30DAYS_REASONING_PROVIDER=xai\nXAI_API_KEY=xai-xxxxxxxx","handlingStrategy":"validation","validationCode":"def ensure_xai_key(config):\n    key = config.get(\"XAI_API_KEY\")\n    if not key:\n        raise RuntimeError(\"xAI provider requires XAI_API_KEY (exact name).\")\n    return key","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Use the exact env-var name XAI_API_KEY; document common typos (XAI_KEY, XAI_TOKEN) as invalid.","Validate xAI presence in the same pre-flight pass as other provider keys.","Fall back to 'auto' if xAI is not strictly required."],"tags":["config","credentials","xai","provider"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}