IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).

Python class

PromptTooLongError

PromptTooLongError​

class max.pipelines.context.PromptTooLongError(num_tokens, max_length, *, limit_description='configured maximum context length')

source

Bases: InputError

Raised when a prompt exceeds the model’s maximum input length.

Exposes num_tokens and max_length as attributes so callers can handle the failure programmatically (e.g., truncate and retry) instead of parsing the message.

limit_description describes what is being limited, since the same failure mode means different things in different architectures (an LLM context window vs. a diffusion text encoder’s max sequence length).

Parameters:

  • num_tokens (int)
  • max_length (int)
  • limit_description (str)