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 gepaVerified import paths — ran on the pinned version, not inferred.
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.
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.
Ensure your Python environment meets the requirement of `>=3.10, <3.15`. Use tools like `pyenv` or `conda` to manage Python versions if needed.
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.
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.