Registry / llm-agents / gepa
library0.1.4pypypi✓ verified 25d ago

GEPA (Genetic-Pareto) is a Python framework for optimizing textual system components like AI prompts, code snippets, and agent architectures. It employs LLM-based reflection and Pareto-efficient evolutionary search to improve performance against any evaluation metric. The library, currently at version 0.1.1, has an active development cadence with frequent releases, with recent focus on a universal API for optimizing any text parameter and enhanced visualization tools.

pip install gepa
INSTALL
IMPORT
SIG · GEPA
G
gepa
llm-agentspythonv0.1.4
Install
26.5s avg
Import
231ms
Disk
18MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
1/2 runs
✓ 28.55s
py 3.11
1/2 runs
✓ 27.85s
py 3.12
1/2 runs
✓ 24.7s
py 3.13
1/2 runs
✓ 24.85s
py 3.9
✕ build_error
✕ build_error
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GEPAAdapter
from gepa import GEPAAdapter
import gepa
GEPAResult
from gepa import GEPAResult
import gepa
EvaluationBatch
from gepa import EvaluationBatch
import gepa

This quickstart optimizes a system prompt for math problems using GEPA's built-in AIME dataset. It demonstrates how to initialize a seed prompt and run the `gepa.optimize` function, which leverages LLM-based reflection to iteratively improve the prompt. Ensure relevant LLM API keys are set as environment variables (e.g., `OPENAI_API_KEY`) as GEPA uses LiteLLM.

import gepa import os # Set your LLM API key as an environment variable (e.g., in your shell or .env file) # export OPENAI_API_KEY='your_openai_key_here' # GEPA uses LiteLLM, supporting many providers. Adjust 'task_lm' and 'reflection_lm' accordingly. # Load the AIME math dataset (built-in example) trainset, valset, _ = gepa.examples.aime.init_dataset() # Start with a basic prompt seed_prompt = { "system_prompt": "You are a helpful assistant. Answer the question. " "Put your final answer in the format '### <answer>'" } # Optimize the prompt # Ensure OPENAI_API_KEY or relevant API key is set in environment result = gepa.optimize( seed_candidate=seed_prompt, trainset=trainset, valset=valset, task_lm=os.environ.get('GEPA_TASK_LM', 'openai/gpt-4o-mini'), # Model being optimized reflection_lm=os.environ.get('GEPA_REFLECTION_LM', 'openai/gpt-4o-mini'), # Model that generates improvements max_metric_calls=10 # Reduced for quick demo ) print("\nOptimized prompt:", result.best_candidate['system_prompt']) # Expected result shows improved accuracy (e.g., 46.6% -> 56.6% on AIME 2025 with GPT-4.1 Mini in full runs)
Debug
Known issues
breakingVersion 0.1.0 introduced `optimize_anything` as a new, universal API for optimizing any text-representable artifact, including code and agent architectures. While `gepa.optimize` remains a valid entry point for prompt optimization, users migrating from pre-0.1.0 versions or seeking more general text optimization should consult the `optimize_anything` documentation.
fix
For new projects or general text optimization, consider using `from gepa.optimize_anything import optimize_anything`. For prompt optimization, `gepa.optimize` is still directly available and commonly used in examples.
affects: <0.1.0
gotchaGEPA requires Python versions 3.10 or later, but strictly less than 3.15. Using incompatible Python versions will lead to installation or runtime errors.
fix
Ensure your Python environment meets the requirement of `>=3.10, <3.15`. Use tools like `pyenv` or `conda` to manage Python versions if needed.
affects: All versions
gotchaGEPA relies on LiteLLM for LLM interactions. You must set appropriate API keys for your chosen LLM provider (e.g., `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`) as environment variables before running optimizations.
fix
Set your LLM provider's API key as an environment variable (e.g., `export OPENAI_API_KEY='your_key_here'`). Refer to LiteLLM documentation for a complete list of supported providers and their respective environment variables.
affects: All versions
gotchaOptimization runs, especially with large `max_metric_calls` or slower LLMs, can be time and resource-intensive. For initial experiments, reduce `max_metric_calls` (e.g., to 50), use faster task models, or reduce the training set size (e.g., to 20-30 examples).
fix
Start with `max_metric_calls=50` or lower. Use faster, cheaper LLMs for `task_lm` and `reflection_lm` during development. Consider reducing the size of your `trainset` for quick iteration.
affects: All versions
Upgrade
Version history
0.1.4latest on PyPI · released Jul 15, 2026
Audit
Dependencies
pythonrequiredRequired Python version range.
litellmoptionalHandles LLM API calls to 100+ providers. Included with `gepa[full]` or can be installed separately.
datasetsoptionalDataset loading utilities. Included with `gepa[full]`.
mlflowoptionalExperiment tracking. Included with `gepa[full]`.
wandboptionalWeights & Biases integration. Included with `gepa[full]`.
tqdmoptionalProgress bars. Included with `gepa[full]`.
Agent activity
25 hits · last 30 days
node
18
Amazon
1
OpenAI (training)
1
Resources
gepa — pip install gepa · libregistry