pydantic-gepa
pydantic-gepa provides a typed optimization runtime over GEPA, Pydantic AI,
and internally managed Pydantic Evals execution.
Full documentation: https://vcoderun.github.io/pydantic-gepa/
from pydantic_gepa import AgentInstructionsInjection, Component, Example, optimize
instructions = Component(name="instructions", initial_text="Answer precisely.")
result = optimize(
train=training_examples,
validation=validation_examples,
task=run_subject,
score=score_subject,
components=[instructions],
injections=[
AgentInstructionsInjection(agent=agent, candidate_component=instructions)
],
reflection="openai:gpt-5-mini",
budget=50,
)
The package starts with a Python API:
- typed GEPA candidate wrappers
- typed candidate component catalogs with include/exclude selection
- raw-text candidate values by default, with explicit JSON-string codecs when required
- candidate injection helpers for Pydantic AI agents
- generic candidate context/value injections for runtime schema or config overrides
- high-level
optimize(...),Example, andOptimization.from_examples(...)APIs that keep Pydantic Evals as internal runtime plumbing for common optimization flows - synchronous or asynchronous task and score functions, plus built-in
model_field_accuracy(...)helpers, with custom Pydantic Evals evaluators still available as an advanced escape hatch - Pydantic Evals harness normalization
- score extraction from named evaluator scores
MetricResult(score, feedback, side_info)for richer reflection signals- reflective dataset construction for GEPA side information, case metadata, expected output, assertion failures, metric feedback, metric side info, success flags, and failure categories
- YAML-first candidate save/load helpers
- Pydantic-AI-compatible tool/output schema description component extraction
- Pydantic model field-description component extraction for structured outputs
- optional recorder hooks for higher-level systems and GEPA callback bridging
- deterministic sequential/grouped plans, typed events, Rich progress, and compatibility-checked checkpoint/resume
- a Click CLI over typed Python targets, without a second optimization DSL
Install with uv:
uv add pydantic-gepa
Or with pip:
pip install pydantic-gepa
Development setup:
uv sync --extra dev --extra integrations
make prod
Build the documentation with:
make docs
Serve it locally with:
make docs-serve
Run a configured Python target from the CLI:
pydantic-gepa my_app.optimization:pipeline inspect target
pydantic-gepa my_app.optimization:pipeline run --run-dir runs/demo
Acknowledgements
pydantic-gepa builds on GEPA, Pydantic AI, and Pydantic Evals, and its design
has benefited from studying other open-source optimization integrations. See
Acknowledgements And Design Influences for explicit
credits, project relationships, and licensing boundaries.
Metadata
Release files for pydantic-gepa 0.1.1
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 |
|---|---|---|---|---|
| pydantic_gepa-0.1.1.tar.gz | 217.7 kB | Without provenance | Details for pydantic_gepa-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pydantic_gepa-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for pydantic_gepa-0.1.1-py3-none-any.whl |
Total release size: 330.7 kB
Release files / pydantic_gepa-0.1.1.tar.gz
| Download URL | pydantic_gepa-0.1.1.tar.gz |
|---|---|
| Size | 217.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b5760aa1bc123b679df5e53fe57adff365056c2293ec10a8a3c9168f2942ec4a
|
|
BLAKE2b-256 checksum How to use checksums |
abc24b2fef833e762682f1ae1329f32545602ec79ed9019bbcc4235fc74b120f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / pydantic_gepa-0.1.1-py3-none-any.whl
| Download URL | pydantic_gepa-0.1.1-py3-none-any.whl |
|---|---|
| Size | 113.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1e38e3ec29ce27b74b29d3ea43c69936d2a58ab00c154774e9e67cbf30306633
|
|
BLAKE2b-256 checksum How to use checksums |
6bb616e18528e18452e1abbb526d8bc6c9a944f0cbe840a2a9e83229bcd515af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for pydantic-gepa 0.1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.