{"record":{"id":"a2f50039a3b92390","repo":"ATH-MaaS/Pixelle-Video","slug":"ark-api-key-not-set","errorCode":null,"errorMessage":"ARK_API_KEY not set.","messagePattern":"ARK_API_KEY not set\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"pixelle_video/services/api_services/image_seedream.py","lineNumber":102,"sourceCode":"        image_paths: Optional[List[str]] = None,\n        **kwargs\n    ) -> List[str]:\n        \"\"\"\n        生成图片\n\n        Args:\n            prompt: 提示词\n            session_id: 任务或会话ID，用于构建存储路径\n            model: 模型名称\n            size: 生成图片的分辨率，如 \"1920*1080\", \"1024*1024\"\n            image_paths: 参考图路径或URL列表 (图生图)\n            **kwargs: 其他生成参数\n\n        Returns:\n            生成的图片路径列表\n        \"\"\"\n        if not self.api_key:\n            raise RuntimeError(\"ARK_API_KEY not set.\")\n\n        # 规范化模型名称（旧名称 -> 新名称）\n        model = normalize_model_name(model)\n\n        # 处理分辨率 (Seedream 要求至少 3686400 像素)\n        # 常用 2K/4K 分辨率\n        size_map = {\n            # 16:9\n            \"1920*1080\": (1920, 1080),\n            \"2048*1080\": (2048, 1080),  # 2K 电影\n            \"2560*1440\": (2560, 1440),  # 2K QHD\n            \"3840*2160\": (3840, 2160),  # 4K UHD\n            \"4096*2160\": (4096, 2160),  # 4K 电影\n            # 9:16\n            \"1080*1920\": (1080, 1920),\n            \"1080*2048\": (1080, 2048),\n            \"1440*2560\": (1440, 2560),\n            \"2160*3840\": (2160, 3840),","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/api_services/image_seedream.py#L84-L120","documentation":"generate_image in the Seedream (Volcano Ark) client checks self.api_key before calling the ARK API and raises RuntimeError when it is unset. The library refuses to spend a network round-trip on a request that will certainly fail auth.","triggerScenarios":"Calling generate_image(model, prompt, ...) when ARK_API_KEY is not present in the environment or was not supplied to the client constructor.","commonSituations":"Deployed environment missing the ARK_API_KEY secret; renamed variable in .env; using DashScope key instead of the ARK/Volcano key; key loaded after module import.","solutions":["Set ARK_API_KEY in the environment (export ARK_API_KEY=...) or in .env and restart the process","Pass api_key=... explicitly when instantiating the Seedream client","Confirm you are using a valid Volcano Ark key (not a DashScope/OpenAI key)","Log os.environ.get('ARK_API_KEY') at startup to verify it is loaded"],"exampleFix":"// before\nclient = ImageSeedream()\nclient.generate_image('doubao-seedream', 'a cat')  # RuntimeError: ARK_API_KEY not set.\n// after\nexport ARK_API_KEY=ark-...\nclient = ImageSeedream(api_key=os.environ['ARK_API_KEY'])\nclient.generate_image('doubao-seedream', 'a cat')","handlingStrategy":"validation","validationCode":"import os\nif not os.environ.get('ARK_API_KEY'):\n    raise SystemExit('ARK_API_KEY not set — export it before calling generate_image')","typeGuard":"def has_ark_key(client) -> bool:\n    key = getattr(client, 'api_key', None)\n    return isinstance(key, str) and bool(key.strip())","tryCatchPattern":"try:\n    paths = client.generate_image(model, prompt)\nexcept RuntimeError as e:\n    if 'ARK_API_KEY' in str(e):\n        logging.error('Set ARK_API_KEY in the environment and retry')\n    raise","preventionTips":["Export ARK_API_KEY in your shell profile or deployment secrets","Validate required keys at application startup","Use the correct Volcano Ark key (not DashScope/OpenAI keys)","Restart services after changing secrets so the env is reloaded"],"tags":["configuration","api-key","env-var"],"backgroundTag":"missing-env-var","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}