API Reference

prompt_toolkit

A library for building powerful interactive command lines in Python with completion and key bindings.

Official Documentation ↗
CompatibilityThis documentation covers version v3.0. Check the official docs for the latest API surface.

Installation

pippip install prompt_toolkit

Methods

prompt_toolkit builds rich prompts with syntax highlighting, completion, and history.

Key Features

  • Completion and history integration
  • Custom key bindings
  • Multiline and validation support

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

FAQ

How do I add autocompletion?
Pass a Completer to PromptSession; WordCompleter covers the common case of completing from a word list.
Does it conflict with readline?
It replaces readline features with its own implementation; mixing both in one process can cause inconsistent editing behavior.
How do I validate input?
Provide a validator that returns a ValidationResult, and the prompt rejects invalid input before returning.