jamiepine/voicebox · error · HTTPException

Model ${model_size} is not downloaded yet. Use /generate to

Error message

Model ${model_size} is not downloaded yet. Use /generate to trigger a download.

What it means

Raised as an HTTPException(status_code=400) by ensure_model_cached_or_raise() when a streaming endpoint is called for a qwen / qwen_custom_voice / tada engine whose requested model_size is not on disk. These engines support multiple model sizes, so _is_model_cached(model_size) is called with the specific size. The detail tells the client to use /generate first, which triggers the download.

Source

Thrown at backend/backends/__init__.py:552

        await backend.load_model(model_size)
    else:
        await backend.load_model()


async def ensure_model_cached_or_raise(engine: str, model_size: str = "default") -> None:
    """Check if a model is cached, raise HTTPException if not. Used by streaming endpoint."""
    from fastapi import HTTPException

    backend = get_tts_backend_for_engine(engine)
    cfg = None
    for c in get_tts_model_configs():
        if c.engine == engine and c.model_size == model_size:
            cfg = c
            break

    if engine in ("qwen", "qwen_custom_voice", "tada"):
        if not backend._is_model_cached(model_size):
            raise HTTPException(
                status_code=400,
                detail=f"Model {model_size} is not downloaded yet. Use /generate to trigger a download.",
            )
    else:
        if not backend._is_model_cached():
            display = cfg.display_name if cfg else engine
            raise HTTPException(
                status_code=400,
                detail=f"{display} model is not downloaded yet. Use /generate to trigger a download.",
            )


def unload_model_by_config(config: ModelConfig) -> bool:
    """Unload a model given its config. Returns True if it was loaded, False otherwise."""
    from . import get_tts_backend_for_engine
    from ..services import tts, transcribe, llm as llm_service

    if config.engine == "whisper":

View on GitHub (pinned to 51f49dea19)

Solutions

  1. Call /generate (non-streaming) once for the target engine+model_size to trigger the download before streaming.
  2. Pre-download required model sizes during setup/onboarding via the model-management UI.
  3. Verify the models cache directory exists and is writable, and that _is_model_cached correctly detects files.
  4. Return the available model sizes in the error detail so the client can pick one already cached.

Example fix

# before
raise HTTPException(status_code=400, detail=f"Model {model_size} is not downloaded yet. Use /generate to trigger a download.")
# after
available = backend.list_cached_sizes() if hasattr(backend, 'list_cached_sizes') else []
raise HTTPException(
    status_code=400,
    detail=f"Model {model_size} is not downloaded yet. Use /generate to trigger a download. Cached: {available}",
)
Defensive patterns

Strategy: validation

Validate before calling

from backend.backends import get_tts_backend_for_engine

def assert_model_ready(engine: str, model_size: str = 'default') -> None:
    backend = get_tts_backend_for_engine(engine)
    if engine in ('qwen', 'qwen_custom_voice', 'tada'):
        ready = backend._is_model_cached(model_size)
    else:
        ready = backend._is_model_cached()
    if not ready:
        raise RuntimeError(f'{engine}/{model_size} not cached; call /generate first')

Try / catch

from fastapi import HTTPException
try:
    await ensure_model_cached_or_raise(engine, model_size)
except HTTPException as e:
    if e.status_code == 400:
        # Trigger a download, or return a helpful 409 to the client.
        await load_engine_model(engine, model_size)
    else:
        raise

Prevention

When it happens

Trigger: The streaming TTS endpoint receives engine in {qwen, qwen_custom_voice, tada} with a model_size that was never downloaded. _is_model_cached(model_size) returns False, raising 400.

Common situations: Fresh install where only the default model was pre-fetched. A client requests a non-default size (e.g. 0.6B vs 1.7B) that the user never downloaded via /generate. Models directory was cleared/moved after install.

Related errors


AI-assisted analysis of jamiepine/voicebox@51f49dea19 (2026-08-12). Data as JSON: /api/errors/af8c09a6a0e56523. Report an issue: GitHub.