GEPAConfig
gepa.gepa_launcher.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, callbacks: list[GEPACallback] | 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::
text
config = GEPAConfig(
engine=EngineConfig(max_metric_calls=200),
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
callbacks: list[GEPACallback] | None = None class-attribute instance-attribute
Observation callbacks for monitoring optimization progress.
Receive events like on_optimization_start, on_iteration_end,
on_candidate_accepted, on_proposal_end, etc. See
:class:~gepa.core.callbacks.GEPACallback for the full protocol.
Example::
text
class MyCallback:
def on_candidate_accepted(self, event):
print(f"New candidate {event['new_candidate_idx']} accepted")
config = GEPAConfig(
callbacks=[MyCallback()],
engine=EngineConfig(max_metric_calls=100),
)Methods:
__post_init__()
Handle dicts passed in (e.g., from a JSON/YAML file).
Source code in gepa/gepa_launcher.py
text
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/gepa_launcher.py
text
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/gepa_launcher.py
text
@staticmethod
def from_dict(d: dict[str, Any]) -> "GEPAConfig":
"""Create config from dictionary representation."""
return GEPAConfig(**d)