Skip to content

GEPAConfig

gepa.optimize_anything.GEPAConfig(engine: EngineConfig = EngineConfig(), reflection: ReflectionConfig = ReflectionConfig(), tracking: TrackingConfig = TrackingConfig(), merge: MergeConfig | None = None, refiner: RefinerConfig | None = None, stop_callbacks: StopperProtocol | Sequence[StopperProtocol] | None = None) dataclass

Top-level configuration for :func:optimize_anything.

Groups all settings into nested component configs. Sensible defaults are provided — most users only need to set engine.max_metric_calls and optionally reflection.reflection_lm.

Example::

config = GEPAConfig(
    engine=EngineConfig(max_metric_calls=200, parallel=True, max_workers=16),
    reflection=ReflectionConfig(reflection_lm="openai/gpt-5.1"),
    refiner=RefinerConfig(max_refinements=2),
)

Attributes

engine: EngineConfig = field(default_factory=EngineConfig) class-attribute instance-attribute

reflection: ReflectionConfig = field(default_factory=ReflectionConfig) class-attribute instance-attribute

tracking: TrackingConfig = field(default_factory=TrackingConfig) class-attribute instance-attribute

merge: MergeConfig | None = None class-attribute instance-attribute

refiner: RefinerConfig | None = None class-attribute instance-attribute

stop_callbacks: StopperProtocol | Sequence[StopperProtocol] | None = None class-attribute instance-attribute

Functions

__post_init__()

Handle dicts passed in (e.g., from a JSON/YAML file).

Source code in gepa/optimize_anything.py
def __post_init__(self):
    """Handle dicts passed in (e.g., from a JSON/YAML file)."""
    if isinstance(self.engine, dict):
        self.engine = EngineConfig(**self.engine)
    if isinstance(self.reflection, dict):
        self.reflection = ReflectionConfig(**self.reflection)
    if isinstance(self.tracking, dict):
        self.tracking = TrackingConfig(**self.tracking)
    if isinstance(self.merge, dict):
        self.merge = MergeConfig(**self.merge)
    if isinstance(self.refiner, dict):
        self.refiner = RefinerConfig(**self.refiner)

to_dict() -> dict[str, Any]

Convert config to dictionary representation.

Source code in gepa/optimize_anything.py
def to_dict(self) -> dict[str, Any]:
    """Convert config to dictionary representation."""
    return asdict(self)

from_dict(d: dict[str, Any]) -> GEPAConfig staticmethod

Create config from dictionary representation.

Source code in gepa/optimize_anything.py
@staticmethod
def from_dict(d: dict[str, Any]) -> "GEPAConfig":
    """Create config from dictionary representation."""
    return GEPAConfig(**d)