Overview
GEPAConfig is the main configuration class for optimize_anything(). It groups all settings into nested component configs, providing a clean interface for controlling optimization behavior.
Most users only need to set engine.max_metric_calls and optionally reflection.reflection_lm.
Class Definition
Parameters
Controls the optimization run loop: budget, parallelism, caching, and stopping conditions.
See EngineConfig for details.
Controls how the LLM proposes improved candidates each iteration.Key parameters:
reflection_lm: The model used for reflection (default:"openai/gpt-5.1")reflection_minibatch_size: Number of examples shown per reflection stepreflection_prompt_template: Custom prompt template for reflection
Experiment tracking and logging configuration (W&B, MLflow, or custom logger).Key parameters:
use_wandb: Enable Weights & Biases trackingwandb_api_key: W&B API keyuse_mlflow: Enable MLflow trackinglogger: Custom logger instance
Enables cross-pollination between candidates on the Pareto frontier.When set, GEPA periodically attempts to merge strengths of two candidates that each excel on different subsets of the validation set.Key parameters:
max_merge_invocations: Maximum number of merge operationsmerge_val_overlap_floor: Minimum validation overlap required for merging
Automatic per-evaluation candidate refinement via LLM.When enabled, after each evaluation GEPA calls an LLM to propose a refined version based on feedback. The better of (original, refined) is kept.Key parameters:
refiner_lm: Language model for refinement (defaults to reflection_lm)max_refinements: Maximum refinement iterations per evaluation
None to disable refinement.Custom stopping conditions beyond the basic ones in
EngineConfig.Can be a single stopper or a list of stoppers. See Stop Conditions for available options.Methods
to_dict()
Convert config to dictionary representation.dict[str, Any] - Dictionary representation of the config
from_dict()
Create config from dictionary representation.d(dict[str, Any]): Dictionary containing config parameters
GEPAConfig - New config instance
Usage Examples
Basic Configuration
Advanced Configuration
With Custom Stop Conditions
Configuration from Dictionary
Related
- EngineConfig - Engine and stopping configuration
- Stop Conditions - Available stopping conditions
- optimize_anything() - Main entry point using this config