gepa
A framework for optimizing textual system components (AI prompts, code snippets, etc.) using LLM-based reflection and Pareto-efficient evolutionary search.
What it is and what it does
GEPA is a framework for automatically improving textual system components by treating optimization as a search problem guided by LLM reflection. Rather than collapsing execution outcomes into a single scalar reward, it reads full execution traces—error messages, profiling data, reasoning logs—to diagnose why a candidate failed and propose targeted improvements. The system uses Pareto-efficient evolutionary search to evolve high-performing variants with minimal evaluations, supporting optimization of prompts, code, agent architectures, scheduling policies, and other text-based artifacts.
The framework integrates with major AI platforms including DSPy, MLflow, Comet ML Opik, and Pydantic, offering both a standalone API and adapters for specialized tasks like RAG optimization, MCP tool descriptions, and LangChain pipelines. It requires Python 3.10+ and access to LLM APIs for reflection; the base package has no runtime dependencies, making installation straightforward.
Use it for:
- Optimize system prompts for classification or reasoning tasks to improve accuracy without manual prompt engineering.
- Evolve entire DSPy programs including signatures and control flow to discover better architectures automatically.
- Improve RAG retrieval and generation by optimizing prompts across vector store backends like ChromaDB or Weaviate.
- Discover cloud scheduling policies or other configuration parameters that beat expert heuristics on your workload.
- Tune agent tool descriptions and system prompts for tool-using agents in LangChain or MCP environments.
- Automatically learn and refine coding agent skills to improve task resolution rates on specialized domains.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
GEPA optimizes textual system components—prompts, code, agent architectures, configurations—using LLM-based reflection and Pareto-efficient evolutionary search to improve performance against any measurable metric.
Yes. GEPA is actively maintained, has no runtime dependencies, and offers a permissive MIT license. It solves a real problem—systematic optimization of textual system components—with a novel LLM-reflection approach that avoids the evaluation overhead of traditional RL methods. Integrations with DSPy, MLflow, and other major frameworks lower adoption friction. Primary constraint is the need for external LLM API access; evaluate whether your use case justifies the API costs.
Install
gepa on PyPI
pip
pip install gepauv
uv add gepapoetry
poetry add gepaInstalling gepa
Before you install
Low friction installation with no runtime dependencies. Active maintenance—last commit 2026-08-14, released 2025-08-11, 6117 GitHub stars. Supports Python 3.10+.
License in practice
MIT license permits commercial and private use with minimal restrictions, making it suitable for production deployment in most contexts.
Quickstart
pip install gepa
import gepa
result = gepa.optimize(
seed_candidate={"system_prompt": "You are a helpful assistant."},
trainset=trainset,
valset=valset,
task_lm="openai/gpt-4.1-mini",
max_metric_calls=150,
reflection_lm="openai/gpt-5",
)
print(result.best_candidate['system_prompt'])
Requires Python 3.10 or later; LLM API access (e.g., OpenAI) needed for reflection and task evaluation.
Verify before relying
- Whether the package requires external LLM API credentials to be pre-configured or if it handles credential management internally.
- Performance characteristics and typical optimization time for different problem scales.
- Whether adapters like ConfidenceAdapter and LangChain require separate installation steps beyond the base package.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<3.15,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 30 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,628,234/month — #1,880 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: gepa-0.1.4-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
deapDEAP is an evolutionary computation framework…
copyleft · top 15,000 on PyPI
ell-aiell-ai is a functional prompt engineering…
permissive · top 15,000 on PyPI
llama-index-question-gen-openaiGenerates follow-up questions from documents or…
permissive · top 5,000 on PyPI
headroom-aiCompresses LLM prompts and agent outputs before…
permissive · top 15,000 on PyPI
agentlightningAgent Lightning optimizes AI agents using…
unclear · top 15,000 on PyPI
llmLLM is a CLI tool and Python library for…
permissive · top 15,000 on PyPI
codeflashCodeflash is a CLI tool that uses LLMs to…
unclear · top 15,000 on PyPI
cugaCUGA is an enterprise-grade generalist agent…
permissive · top 15,000 on PyPI
dspyDSPy is a framework for building and optimizing…
permissive · top 5,000 on PyPI
dspy-aiDSPy is a framework for building and optimizing…
permissive · top 5,000 on PyPI