nexu-io/open-design · error · RuntimeError

xAI selected but XAI_API_KEY is not configured.

Error message

xAI selected but XAI_API_KEY is not configured.

What it means

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.

Source

Thrown at design-templates/last30days/scripts/lib/providers.py:315

    if provider_name == "openai":
        if not openai_token or config.get("OPENAI_AUTH_STATUS") != env.AUTH_STATUS_OK:
            raise RuntimeError("OpenAI selected but no valid OpenAI auth is configured.")
        runtime = schema.ProviderRuntime(
            reasoning_provider="openai",
            planner_model=planner_model,
            rerank_model=rerank_model,

            x_search_backend=_resolve_x_backend(config),
        )
        return runtime, OpenAIClient(
            openai_token,
            config.get("OPENAI_AUTH_SOURCE") or env.AUTH_SOURCE_API_KEY,
            config.get("OPENAI_CHATGPT_ACCOUNT_ID"),
        )

    if provider_name == "xai":
        if not xai_key:
            raise RuntimeError("xAI selected but XAI_API_KEY is not configured.")
        runtime = schema.ProviderRuntime(
            reasoning_provider="xai",
            planner_model=planner_model,
            rerank_model=rerank_model,

            x_search_backend=_resolve_x_backend(config),
        )
        return runtime, XAIClient(xai_key)

    if provider_name == "openrouter":
        openrouter_key = config.get("OPENROUTER_API_KEY")
        if not openrouter_key:
            raise RuntimeError("OpenRouter selected but OPENROUTER_API_KEY is not configured.")
        runtime = schema.ProviderRuntime(
            reasoning_provider="openrouter",
            planner_model=planner_model,
            rerank_model=rerank_model,
            x_search_backend=_resolve_x_backend(config),

View on GitHub (pinned to 5be4028344)

Solutions

  1. Set XAI_API_KEY to a valid xAI console key.
  2. If you do not have an xAI key, switch provider to one whose credentials you have, or to 'auto'.
  3. Double-check the env-var name: it must be exactly XAI_API_KEY (not XAI_KEY or XAI_TOKEN).

Example fix

# before
LAST30DAYS_REASONING_PROVIDER=xai
# no key

# after
LAST30DAYS_REASONING_PROVIDER=xai
XAI_API_KEY=xai-xxxxxxxx
Defensive patterns

Strategy: validation

Validate before calling

def ensure_xai_key(config):
    key = config.get("XAI_API_KEY")
    if not key:
        raise RuntimeError("xAI provider requires XAI_API_KEY (exact name).")
    return key

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of nexu-io/open-design@5be4028344 (2026-08-12). Data as JSON: /api/errors/d4008e30bcb72f05. Report an issue: GitHub.