ATH-MaaS/Pixelle-Video · error · RuntimeError
OPENAI_API_KEY not set. Configure OpenAI only when using GPT
Error message
OPENAI_API_KEY not set. Configure OpenAI only when using GPT image models.
What it means
The GPT image client (ImageGPT) is created lazily via the gpt_client property and requires OPENAI_API_KEY. If the key is missing when a GPT/OpenAI image model is used, a RuntimeError is raised rather than calling the API unauthenticated.
Source
Thrown at pixelle_video/services/api_services/image_client.py:84
@property
def seedream_client(self):
"""Create Seedream client only when a Seedream/ARK model is selected."""
if not self._ark_api_key:
raise RuntimeError("ARK_API_KEY not set. Configure ARK only when using Seedream image models.")
if self._seedream_client is None:
self._seedream_client = SeedreamClient(
api_key=self._ark_api_key,
base_url=self._ark_base_url,
local_proxy=self._ark_local_proxy,
)
return self._seedream_client
@property
def gpt_client(self):
"""Create OpenAI image client only when a GPT/OpenAI image model is selected."""
if not self._gpt_api_key:
raise RuntimeError("OPENAI_API_KEY not set. Configure OpenAI only when using GPT image models.")
if self._gpt_client is None:
self._gpt_client = ImageGPT(
api_key=self._gpt_api_key,
base_url=self._gpt_base_url,
local_proxy=self._gpt_local_proxy,
)
return self._gpt_client
def generate_image(self,
prompt: str,
image_paths: Optional[List[str]] = None,
model: str = "wan2.7-image",
save_dir: Optional[str] = None,
session_id: Optional[str] = None,
video_ratio: Optional[str] = "16:9",
resolution: Optional[str] = "2K") -> List[str]:
"""
Generate images based on prompt and optional reference images.View on GitHub (pinned to 848b054e4f)
Solutions
- Set OPENAI_API_KEY in the environment before generation
- Confirm the .env/secret is actually loaded into the process
- Check the config layer reads OPENAI_API_KEY into _gpt_api_key
Example fix
// before export ARK_API_KEY=... // after export ARK_API_KEY=... export OPENAI_API_KEY=sk-...
Defensive patterns
Strategy: validation
Validate before calling
import os
if not os.environ.get("OPENAI_API_KEY"):
raise SystemExit("Set OPENAI_API_KEY before using GPT image models") Try / catch
try:
paths = gen.generate_image(prompt=p)
except RuntimeError as e:
if "OPENAI_API_KEY not set" in str(e):
raise SystemExit("Configure OPENAI_API_KEY in your environment") from e Prevention
- Fail fast at boot if required keys are missing
- Mount secrets in CI/containers explicitly
- Distinguish which provider key each model family needs
When it happens
Trigger: Selecting a GPT image model without OPENAI_API_KEY set; key defined in a different env var; config not reloaded after adding the key.
Common situations: Fresh CI/container without secrets mounted; .env not loaded; typos in the variable name; key revoked and removed from environment.
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. Configure ARK only when using Seedream
- Template not found: {template}
- API VLM analysis requires an explicitly selected VLM model.
- DASHSCOPE_API_KEY 未设置,无法使用图片上传服务
- ARK_API_KEY not set.
AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30).
Data as JSON: /api/errors/3a33a2309e6a6110.
Report an issue: GitHub.