ATH-MaaS/Pixelle-Video · error · RuntimeError

ARK_API_KEY not set. Configure ARK only when using Seedream

Error message

ARK_API_KEY not set. Configure ARK only when using Seedream image models.

What it means

The Seedream image client is created lazily via the seedream_client property, which requires the ARK_API_KEY configuration. If the key is absent when a Seedream/ARK image model is selected, a RuntimeError is raised instead of constructing a client with no credentials.

Source

Thrown at pixelle_video/services/api_services/image_client.py:71

        # Default save directory
        self.base_save_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "code", "result", "image_client")

    @property
    def dashscope_client(self):
        """Create DashScope client only when a DashScope model is selected."""
        if self._dashscope_client is None:
            self._dashscope_client = DashScopeClient(
                api_key=self._dashscope_api_key,
                base_url=self._dashscope_base_url,
                local_proxy=self._dashscope_local_proxy,
            )
        return self._dashscope_client

    @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,

View on GitHub (pinned to 848b054e4f)

Solutions

  1. Set the ARK_API_KEY environment variable before running
  2. Load your .env file (e.g. dotenv) so the key reaches the config
  3. Verify config wiring maps ARK_API_KEY into _ark_api_key

Example fix

// before
export OPENAI_API_KEY=sk-...
// after
export ARK_API_KEY=your-ark-key
export OPENAI_API_KEY=sk-...
Defensive patterns

Strategy: validation

Validate before calling

import os
if not os.environ.get("ARK_API_KEY"):
    raise SystemExit("Set ARK_API_KEY before using Seedream models")

Try / catch

try:
    paths = gen.generate_image(prompt=p)
except RuntimeError as e:
    if "ARK_API_KEY not set" in str(e):
        raise SystemExit("Configure ARK_API_KEY in your environment") from e

Prevention

When it happens

Trigger: Selecting a Seedream image model without ARK_API_KEY set in the environment/config; key set under a different variable name; key loaded after client instantiation.

Common situations: Deploying to a new environment and forgetting the ARK credential; .env file not loaded; misconfigured secret manager; assuming OpenAI key covers Seedream.

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


AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30). Data as JSON: /api/errors/fa8c5de35a88f230. Report an issue: GitHub.