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.
Features
- Forms from any JSON Schema (2020-12:
$refwith$defs, pointers,$anchorand$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 withjsonschemafor 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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| promptantic-2.0.0.tar.gz | 31.0 kB | With provenance | Details for promptantic-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| promptantic-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for promptantic-2.0.0-py3-none-any.whl |
Total release size: 65.3 kB
Release files / promptantic-2.0.0.tar.gz
| Download URL | promptantic-2.0.0.tar.gz |
|---|---|
| Size | 31.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ad4a810dcdb9262df877b3475473db8bbd62ddca7853eab18354639e4cc5694
|
|
BLAKE2b-256 checksum How to use checksums |
7e630f7c7949bd805bec95f506038bcd0cbcfb87bea6656ccab6e39582ea6e1d
|
| 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 23, 2026.
Transparency logRelease files / promptantic-2.0.0-py3-none-any.whl
| Download URL | promptantic-2.0.0-py3-none-any.whl |
|---|---|
| Size | 34.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a75548ab31399b9ec8803ce131eecb4490f2fa1e919bd602d2ccb9095c10f6cc
|
|
BLAKE2b-256 checksum How to use checksums |
627572ce7df4b20a4a20d0b9bd81d6901d5b0ac680b7c303b6c7da9f055c6575
|
| 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 23, 2026.
Transparency logSecurity for promptantic 2.0.0
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.
Attestation for promptantic-2.0.0.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 23, 2026.
Transparency logA 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.