ATH-MaaS/Pixelle-Video · critical · RuntimeError
DashScope VLM API key is not configured.
Error message
DashScope VLM API key is not configured.
What it means
query raises RuntimeError when self.dashscope_client is None, meaning the DashScope SDK client was never constructed because DASHSCOPE_API_KEY was not configured at initialization time. No chat request can be made without it.
Source
Thrown at pixelle_video/services/api_services/vlm_client.py:58
print(f"Prompt: {prompt}")
if image_paths:
print(f"Images: {len(image_paths)}")
for p in image_paths:
if p.startswith("data:"):
print(f" - [Base64图片]")
else:
print(f" - {p}")
if video_paths:
print(f"Videos: {len(video_paths)}")
for p in video_paths:
print(f" - {p}")
print(f"Model: {selected_model}")
if session_id:
print(f"Session ID: {session_id}")
print("-" * 30)
if self.dashscope_client is None:
raise RuntimeError("DashScope VLM API key is not configured.")
image_urls = [self._to_dashscope_file_url(path, allow_data_url=True) for path in image_paths or []]
video_urls = [self._to_dashscope_file_url(path, allow_data_url=False) for path in video_paths or []]
return self.dashscope_client.chat(
text=prompt,
images=image_urls,
videos=video_urls,
model=selected_model,
stream=False,
)
def _to_dashscope_file_url(self, path: str, allow_data_url: bool) -> str:
if path.startswith("data:"):
if not allow_data_url:
raise ValueError("DashScope video input does not support data URLs in this adapter.")
import base64 as b64
import tempfileView on GitHub (pinned to 848b054e4f)
Solutions
- Set DASHSCOPE_API_KEY in the environment before creating VlmClient
- Ensure load_dotenv()/secret loading runs before client construction, not after
- Re-instantiate VlmClient after fixing configuration — it does not hot-reload credentials
- Verify with: python -c "import os; print(bool(os.environ.get('DASHSCOPE_API_KEY')))"
Example fix
// before client = VlmClient() # key not loaded yet load_dotenv() // after load_dotenv() client = VlmClient()
Defensive patterns
Strategy: validation
Validate before calling
import os
if not os.environ.get("DASHSCOPE_API_KEY"):
raise SystemExit("Set DASHSCOPE_API_KEY before initializing VlmClient") Try / catch
try:
answer = vlm.query(prompt=p, model="qwen-vl-max")
except RuntimeError as e:
if "API key is not configured" in str(e):
logging.critical("DASHSCOPE_API_KEY missing; re-create VlmClient after loading secrets")
else:
raise Prevention
- Call load_dotenv()/secret loading before constructing VlmClient
- Check client.dashscope_client is not None right after construction
- Add the key to deployment env templates and CI secrets
When it happens
Trigger: Constructing VlmClient without a DashScope API key (client stays None) and then calling query() with a valid model.
Common situations: DASHSCOPE_API_KEY missing from environment/.env; key loaded after VlmClient was instantiated (load_dotenv called too late); different process/container lacking the secret; SDK init silently skipped on import error.
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.
- str(e)
- Image edit failed: {response.code}, {response.message}, stat
- DASHSCOPE_API_KEY 未设置,无法使用图片上传服务
- Failed to get upload policy: {response.text}
AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30).
Data as JSON: /api/errors/67ecd3a2c74cb401.
Report an issue: GitHub.