ATH-MaaS/Pixelle-Video · error · RuntimeError
API media service is not initialized
Error message
API media service is not initialized
What it means
MediaService.__call__ routes any workflow starting with "api/" to a remote API media path via self.core.api_media. If the core object is missing or has no api_media attribute (the API media service was never initialized during setup), it raises RuntimeError instead of silently mis-dispatching.
Source
Thrown at pixelle_video/services/media.py:210
seed=42
)
# With absolute path
media = await pixelle_video.media(
prompt="a cat",
workflow="/path/to/custom.json"
)
# With custom ComfyUI server
media = await pixelle_video.media(
prompt="a cat",
comfyui_url="http://192.168.1.100:8188"
)
"""
selected_workflow = workflow or self.config.get("default_workflow")
if selected_workflow and selected_workflow.startswith("api/"):
if not self.core or not getattr(self.core, "api_media", None):
raise RuntimeError("API media service is not initialized")
return await self.core.api_media(
prompt=prompt,
workflow=selected_workflow,
media_type=media_type,
width=width,
height=height,
duration=duration,
output_path=output_path,
image_path=image_path,
negative_prompt=negative_prompt,
steps=steps,
seed=seed,
cfg=cfg,
sampler=sampler,
**params
)
# 1. Resolve workflow (returns structured info)View on GitHub (pinned to 848b054e4f)
Solutions
- Initialize the client with the API backend enabled so core.api_media is registered (provide API credentials/config at construction)
- Remove the 'api/' prefix from the workflow name if you intend to run the local/selfhost path
- Check the config/default_workflow value and change it to a local workflow file
- Log the initialization path and verify self.core is set and has api_media before dispatch
Example fix
// before
pv = PixelleVideo(config={...}) # API backend not configured
await pv.media(prompt="a cat", workflow="api/video.json") # RuntimeError
// after
pv = PixelleVideo(config={..., "api_enabled": True, "api_key": os.environ["PIXELLE_API_KEY"]})
assert pv.core and getattr(pv.core, "api_media", None), "API backend missing"
await pv.media(prompt="a cat", workflow="api/video.json") Defensive patterns
Strategy: validation
Validate before calling
def api_backend_ready(client) -> bool:
core = getattr(client, "core", None)
return core is not None and getattr(core, "api_media", None) is not None Type guard
def has_api_media(core) -> bool:
return core is not None and callable(getattr(core, "api_media", None)) Try / catch
try:
media = await pv.media(prompt=p, workflow=wf)
except RuntimeError as e:
if "not initialized" in str(e):
logger.error("API backend not configured; falling back to local workflow")
media = await pv.media(prompt=p, workflow="image_flux.json")
else:
raise Prevention
- Call api_backend_ready(client) at startup, before any media calls
- Keep backend selection (selfhost vs api) and workflow prefixes consistent in one config place
- Ensure required API env vars/keys are set before constructing the client
- Fail fast at boot with a clear message instead of deep in a request path
When it happens
Trigger: Calling pixelle_video.media(workflow='api/xxx.json', ...) (or a default_workflow config value beginning with 'api/') when the client was constructed without the API backend — e.g. initialized for selfhost ComfyUI only, so core or core.api_media is absent.
Common situations: Config file switched to api/ workflows but the client was built with selfhost-only initialization; environment variable selecting backend not set, so core.api_media never registered; reusing a partially constructed client after init failure.
Related errors
- dashscope package not installed. Run: pip install dashscope
- No default workflow configured for {self.service_name}. Plea
- HTML rendering failed: {type(e).__name__}: {e}
- Template not found: {template}
- Progress must be between 0.0 and 1.0, got {self.progress}
AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30).
Data as JSON: /api/errors/9109eb212438e321.
Report an issue: GitHub.