2noise/ChatTTS · error · ValueError

Either prompts or prompt_token_ids must be provided.

Error message

Either prompts or prompt_token_ids must be provided.

What it means

LLM.generate() requires input: either prompts (string or list of strings) or prompt_token_ids (list of token-id lists). Passing both as None (e.g. generate() with no arguments, or a variable that evaluated to None) raises immediately. The two arguments exist so you can skip tokenization by supplying pre-tokenized ids.

Source

Thrown at ChatTTS/model/velocity/llm.py:148

        NOTE: This class automatically batches the given prompts, considering
        the memory constraint. For the best performance, put all of your prompts
        into a single list and pass it to this method.

        Args:
            prompts: A list of prompts to generate completions for.
            sampling_params: The sampling parameters for text generation. If
                None, we use the default sampling parameters.
            prompt_token_ids: A list of token IDs for the prompts. If None, we
                use the tokenizer to convert the prompts to token IDs.
            use_tqdm: Whether to use tqdm to display the progress bar.

        Returns:
            A list of `RequestOutput` objects containing the generated
            completions in the same order as the input prompts.
        """
        if prompts is None and prompt_token_ids is None:
            raise ValueError("Either prompts or prompt_token_ids must be " "provided.")
        if isinstance(prompts, str):
            # Convert a single prompt to a list.
            prompts = [prompts]
        if (
            prompts is not None
            and prompt_token_ids is not None
            and len(prompts) != len(prompt_token_ids)
        ):
            raise ValueError(
                "The lengths of prompts and prompt_token_ids " "must be the same."
            )
        if sampling_params is None:
            # Use default sampling params.
            sampling_params = SamplingParams()

        # Add requests to the engine.
        num_requests = len(prompts) if prompts is not None else len(prompt_token_ids)
        for i in range(num_requests):

View on GitHub (pinned to 77b89ee281)

Solutions

  1. Pass prompts: llm.generate(['Hello']) or prompt_token_ids: llm.generate(prompt_token_ids=[[1,2,3]]).
  2. If your prompt comes from a pipeline, assert it is non-None before calling generate to fail with a clearer message.

Example fix

# before
out = llm.generate(prompts, sampling_params)  # prompts is None

# after
assert prompts, 'prompt extraction failed'
out = llm.generate(prompts, sampling_params)
Defensive patterns

Strategy: validation

Validate before calling

def validated_generate(llm, prompts=None, prompt_token_ids=None, sampling_params=None):
    if prompts is None and prompt_token_ids is None:
        raise ValueError('no prompt: upstream extraction produced nothing')
    if isinstance(prompts, str):
        prompts = [prompts]
    return llm.generate(prompts, prompt_token_ids, sampling_params)

Try / catch

try:
    out = llm.generate(prompts, sampling_params=sampling_params)
except ValueError as e:
    if 'must be provided' in str(e):
        raise RuntimeError('prompt pipeline produced no input') from e
    raise

Prevention

When it happens

Trigger: llm.generate() with no arguments; llm.generate(prompts=None, prompt_token_ids=None); passing a variable that is None because an upstream tokenizer/extraction step failed silently.

Common situations: Default-argument misuse after refactoring; prompt list built from an empty filter that produced None; confusion with APIs where the prompt is optional.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of 2noise/ChatTTS@77b89ee281 (2026-08-26). Data as JSON: /api/errors/935d9113b020c176. Report an issue: GitHub.