ATH-MaaS/Pixelle-Video · error · RuntimeError
ARK_API_KEY not set.
Error message
ARK_API_KEY not set.
What it means
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.
Source
Thrown at pixelle_video/services/api_services/image_seedream.py:102
image_paths: Optional[List[str]] = None,
**kwargs
) -> List[str]:
"""
生成图片
Args:
prompt: 提示词
session_id: 任务或会话ID,用于构建存储路径
model: 模型名称
size: 生成图片的分辨率,如 "1920*1080", "1024*1024"
image_paths: 参考图路径或URL列表 (图生图)
**kwargs: 其他生成参数
Returns:
生成的图片路径列表
"""
if not self.api_key:
raise RuntimeError("ARK_API_KEY not set.")
# 规范化模型名称(旧名称 -> 新名称)
model = normalize_model_name(model)
# 处理分辨率 (Seedream 要求至少 3686400 像素)
# 常用 2K/4K 分辨率
size_map = {
# 16:9
"1920*1080": (1920, 1080),
"2048*1080": (2048, 1080), # 2K 电影
"2560*1440": (2560, 1440), # 2K QHD
"3840*2160": (3840, 2160), # 4K UHD
"4096*2160": (4096, 2160), # 4K 电影
# 9:16
"1080*1920": (1080, 1920),
"1080*2048": (1080, 2048),
"1440*2560": (1440, 2560),
"2160*3840": (2160, 3840),View on GitHub (pinned to 848b054e4f)
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
Example fix
// before
client = ImageSeedream()
client.generate_image('doubao-seedream', 'a cat') # RuntimeError: ARK_API_KEY not set.
// after
export ARK_API_KEY=ark-...
client = ImageSeedream(api_key=os.environ['ARK_API_KEY'])
client.generate_image('doubao-seedream', 'a cat') Defensive patterns
Strategy: validation
Validate before calling
import os
if not os.environ.get('ARK_API_KEY'):
raise SystemExit('ARK_API_KEY not set — export it before calling generate_image') Type guard
def has_ark_key(client) -> bool:
key = getattr(client, 'api_key', None)
return isinstance(key, str) and bool(key.strip()) Try / catch
try:
paths = client.generate_image(model, prompt)
except RuntimeError as e:
if 'ARK_API_KEY' in str(e):
logging.error('Set ARK_API_KEY in the environment and retry')
raise Prevention
- 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
When it happens
Trigger: Calling generate_image(model, prompt, ...) when ARK_API_KEY is not present in the environment or was not supplied to the client constructor.
Common situations: 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.
Understand the failure class
Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.
Related errors
- ARK_API_KEY not set.
- Template not found: {template}
- str(e)
- API VLM analysis requires an explicitly selected VLM model.
- ARK_API_KEY not set. Configure ARK only when using Seedream
AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30).
Data as JSON: /api/errors/a2f50039a3b92390.
Report an issue: GitHub.