HKUDS/nanobot · error · ImageGenerationError

{missing_key_message}

Error message

{missing_key_message}

What it means

Credential guard in OpenRouterImageProvider.generate: no API key is configured for the OpenRouter image provider, so the request would certainly fail with 401. Raised via the class-level missing_key_message before any HTTP call is made.

Solutions

  1. Set providers.openrouter.apiKey in the nanobot config
  2. Confirm the config provider name is 'openrouter' so the key is picked up
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nanobot/providers/image_generation.py:382 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26). Data as JSON: /api/errors/a3ae18e42aa9c031. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/providers/image_generation.py:382

    model_options = ("openai/gpt-5.4-image-2",)
    missing_key_message = (
        "OpenRouter API key is not configured. Set providers.openrouter.apiKey."
    )

    def _default_base_url(self) -> str:
        return "https://openrouter.ai/api/v1"

    async def generate(
        self,
        *,
        prompt: str,
        model: str,
        reference_images: list[str] | None = None,
        aspect_ratio: str | None = None,
        image_size: str | None = None,
    ) -> GeneratedImageResponse:
        if not self.api_key:
            raise ImageGenerationError(self.missing_key_message)

        content: str | list[dict[str, Any]]
        references = list(reference_images or [])
        if references:
            blocks: list[dict[str, Any]] = [{"type": "text", "text": prompt}]
            blocks.extend(
                {"type": "image_url", "image_url": {"url": image_path_to_data_url(path)}}
                for path in references
            )
            content = blocks
        else:
            content = prompt

        body: dict[str, Any] = {
            "model": model,
            "messages": [{"role": "user", "content": content}],
            "modalities": ["image", "text"],
            "stream": False,

View on GitHub (pinned to 42f37dc4c0)