{"record":{"id":"8c76eb0e5b07d8e3","repo":"HKUDS/DeepTutor","slug":"no-endpoint-url-configured-for-image-generation","errorCode":null,"errorMessage":"No endpoint URL configured for image generation.","messagePattern":"No endpoint URL configured for image generation\\.","errorType":"error_code","errorClass":"GenerationProviderError","httpStatus":null,"severity":"error","filePath":"deeptutor/services/imagegen/adapters/chat_completions.py","lineNumber":42,"sourceCode":"    GenerationProviderError,\n    build_auth_headers,\n    join_api_path,\n    raise_for_provider,\n)\nfrom deeptutor.services.imagegen.base import BaseImagegenAdapter\nfrom deeptutor.services.imagegen.config import ImagegenConfig\n\nlogger = logging.getLogger(__name__)\n\n\nclass ChatCompletionsImagegenAdapter(BaseImagegenAdapter):\n    \"\"\"POST ``{base}/chat/completions`` with image modalities; collect image bytes.\"\"\"\n\n    async def generate(\n        self, prompt: str, config: ImagegenConfig, *, n: int = 1\n    ) -> list[tuple[bytes, str]]:\n        if not config.base_url:\n            raise GenerationProviderError(\"No endpoint URL configured for image generation.\")\n        url = join_api_path(config.base_url, \"chat/completions\")\n        headers = {\n            \"Content-Type\": \"application/json\",\n            **build_auth_headers(config.auth_style, config.api_key),\n            **(config.extra_headers or {}),\n        }\n        payload: dict[str, Any] = {\n            \"model\": config.model,\n            \"messages\": [{\"role\": \"user\", \"content\": prompt}],\n            \"modalities\": [\"image\", \"text\"],\n        }\n\n        logger.debug(\"imagegen(chat) url=%s model=%s\", url, config.model)\n        try:\n            async with httpx.AsyncClient(timeout=config.request_timeout) as client:\n                resp = await client.post(url, headers=headers, json=payload)\n                raise_for_provider(resp, \"Image generation\")\n                images = [","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/imagegen/adapters/chat_completions.py#L24-L60","documentation":"Raised by ChatCompletionsImagegenAdapter.generate when ImagegenConfig.base_url is empty. The adapter builds the request URL as join_api_path(config.base_url, 'chat/completions'), so without a base URL there is no endpoint to POST the image-generation chat request to.","triggerScenarios":"Calling generate() with an ImagegenConfig whose base_url is None or '' — e.g. the provider config was loaded from settings/env and the base URL key was omitted or named incorrectly, or a generic OpenAI-compatible imagegen provider was selected without specifying its API host.","commonSituations":"Missing IMAGEGEN_BASE_URL-style env var, typo in the provider settings JSON (data/user/settings/*.json), assuming the LLM chat provider's base URL is reused for imagegen when it is a separate config field.","solutions":["Set base_url on the ImagegenConfig passed to generate() (e.g. https://api.openai.com/v1 or your OpenAI-compatible host)","Check the imagegen provider entry in data/user/settings/*.json or the relevant env var for a missing/misspelled base URL key","If the provider has no chat-completions image endpoint, switch to a provider type that uses /images/generations (OpenAICompatImagegenAdapter)"],"exampleFix":"// before\nconfig = ImagegenConfig(base_url=None, api_key=key)\n// after\nconfig = ImagegenConfig(base_url=\"https://api.openai.com/v1\", api_key=key)","handlingStrategy":"validation","validationCode":"def validate_imagegen_config(config):\n    if not config.base_url:\n        raise ValueError(\"ImagegenConfig.base_url is required before generate()\")\n    if not config.api_key:\n        raise ValueError(\"ImagegenConfig.api_key is required\")","typeGuard":"def has_base_url(config) -> bool:\n    return isinstance(getattr(config, \"base_url\", None), str) and config.base_url.strip() != \"\"","tryCatchPattern":null,"preventionTips":["Validate base_url/api_key at config load time, not at request time","Fail fast on startup with a clear message when the imagegen provider entry lacks a base URL"],"tags":["imagegen","configuration","missing-base-url"],"backgroundTag":"missing-endpoint-url","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}