Skip to main content

Promptantic

Fill Pydantic models interactively in the terminal. promptantic walks a model's fields and shows a type-aware prompt-toolkit prompt for each one, with completion, validation and retry.

PyPI License Package status Monthly downloads Distribution format Wheel availability Python version Implementation Releases Github Contributors Github Forks Github Issues Github Issues Github Watchers Github Stars Github Repository size Github last commit Github release date Github language count Github commits this month Package status

Read the documentation!

Features

  • Forms from any JSON Schema (2020-12: $ref with $defs, pointers, $anchor and $id, allOf, anyOf / oneOf, enum / const, type lists, prefixItems, additionalProperties, formats, numeric and length constraints), or from a Python type: pydantic models, dataclasses, TypedDicts, list[...], ...
  • A Textual form (all fields at once, folding sections, live checks, errors at their fields) that renders below the prompt, or embeds into any Textual app
  • A one-prompt-per-field fallback (prompt-toolkit) for terminals without a full TUI
  • One UI-independent core (promptantic.form) both renderers share; validation with jsonschema for schemas and pydantic for types (which also gives you an instance)

Installation

pip install promptantic            # core + one-prompt-per-field
pip install "promptantic[textual]" # + the Textual form

Quick Start

from pydantic import BaseModel, Field
from promptantic import fill


class Order(BaseModel):
    customer: str = Field(min_length=1, description="Who ordered")
    quantity: int = Field(default=1, ge=1)
    express: bool = False


order = await fill(Order)  # an Order instance

# A JSON Schema gives a dict
answer = await fill({
    "type": "object",
    "properties": {"name": {"type": "string"}, "count": {"type": "integer", "default": 2}},
    "required": ["name"],
})

fill() uses the Textual form when it's installed and the terminal is interactive, else one prompt per field (ui="textual" / ui="sequential" to choose). It raises FormCancelledError when the user cancels.

In a Textual app

from promptantic.textual import FormScreen, FormView

# A modal that dismisses with the validated result (None when cancelled)
self.push_screen(FormScreen(Order, initial={"customer": "Ada"}), on_result)

# Or embed the form and handle FormView.Submitted / FormView.Cancelled yourself
yield FormView(target_for(schema))

The core

from promptantic.form import build_form, field_errors, target_for

target = target_for(Order)  # schema + validation (also for plain JSON Schemas)
root = build_form(target.schema)  # the form tree: ObjectNode, StringNode, UnionNode, ...
result = target.validate(value)  # FormValidationError lists every issue with its path

Nested parts of the tree are built on first access, so recursive schemas work. Generic JSON Schema helpers ($ref resolution, allOf merging, type and constant detection) live in schemez (schemez.jsonschema_utils).

Designing a model

ModelSpec describes a model as data (name, fields with type, default, description; nested objects), so it's filled with the same forms. The result becomes a JSON Schema or a class:

from promptantic import ModelCreator, ModelSpec, fill

spec = await fill(ModelSpec)  # name, description, fields...
Book = spec.model_class()  # a pydantic class (pydantic.create_model)
schema = spec.json_schema()

Book = await ModelCreator().acreate("Book")  # the same in one call

Skipping fields

Fields with json_schema_extra={promptantic.SKIP_PROMPT_KEY: True} (or readOnly in a JSON Schema) aren't asked; they keep their default.

Upgrading from 1.x

ModelGenerator().apopulate(Model) / .populate(Model) still work, as a thin wrapper around fill() (an instance as argument gives the starting values). The prompt-per-type implementation behind it is gone in 2.0, with its options (style, show_progress, ..., accepted and ignored) and custom type handlers: a field's JSON Schema (format, enum, constraints, x- keys) is what shapes its input now.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

Built with prompt-toolkit and Pydantic.

Metadata

Release files for promptantic 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for promptantic 2.0.1
File Size Uploaded Provenance Actions
promptantic-2.0.1.tar.gz 32.0 kB With provenance Details for promptantic-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for promptantic 2.0.1
File Interpreter ABI Platform Actions
promptantic-2.0.1-py3-none-any.whl Python 3 none any Details for promptantic-2.0.1-py3-none-any.whl

Total release size: 67.1 kB

Release files / promptantic-2.0.1.tar.gz

Download URL promptantic-2.0.1.tar.gz
Size 32.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8890fb5dbe1fb68cc39835417ab57d4c226348cdc91a4bcf54ec46875d5a18b1
BLAKE2b-256 checksum
How to use checksums
306316fd95fa1a8d629867988451885d7708d5a7051cb339c7d09742b48976a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Release files / promptantic-2.0.1-py3-none-any.whl

Download URL promptantic-2.0.1-py3-none-any.whl
Size 35.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9599cc5e55f7222b0f2410a0d0b05719ab3756e5a4910ddc2a3f1e312e487cce
BLAKE2b-256 checksum
How to use checksums
608bc63d985b803cf2d207296a2edf960262b68940b20f0b5a307fdf6eb3da50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

Security for promptantic 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for promptantic-2.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page