optimize() GEPA Tune programs with the top-level GEPA helper. go subsystems subsystems/optimize website/content-src/templates/subsystem-optimize.md subsystems optimize() GEPA

AxGEPA GEPA

Use the generated AxGEPA optimizer surface for portable GEPA tuning. TypeScript also exposes the convenience optimize() helper; generated packages currently keep the optimizer explicit.

Go
engine := axllm.NewAxGEPA(reflectionClient, nil)
result := engine.Optimize(request, evaluator)

The optimizer runs a program against examples, scores predictions, searches for better instructions/demos/component settings, and returns an artifact that can be applied immediately or serialized.

What It Does

GEPA explores changes and keeps tradeoffs visible through Pareto-aware results. The TypeScript helper also runs bootstrap demos for small starter sets before GEPA, which gives the optimizer concrete examples to work with.

flowchart LR
  A["Program"] --> D["GEPA"]
  B["Train examples"] --> D
  C["Metric or judge"] --> D
  D --> E["Reflective mutation"]
  E --> F["Pareto evaluation"]
  F -->|explore| E
  F --> G["Optimized artifact"]
  G --> H["Save / load / apply"]

Core Call Shape

text
result = optimize(program, examples, metric, options)
program.applyOptimization(result.optimizedProgram)

Generated language packages expose the optimizer surface available in their AxIR API, usually as an AxGEPA engine.

Common Patterns

  • Start with no-key deterministic examples for the metric.
  • Keep maxMetricCalls explicit.
  • Use scalar metrics for one clear objective.
  • Use multi-objective metrics for tradeoffs such as accuracy/cost or quality/brevity.
  • Keep validation examples separate when the optimizer surface supports them.
  • Save artifacts with enough metadata to explain the examples and metric that produced them.

AxGen

IllustrativeGenerated-package equivalent. Prefer checked-in package examples for copy/paste runnable code.
Go
gepa := ax.NewAxGEPA(map[string]ax.Value{"maxMetricCalls": 40})
artifact, err := gepa.Optimize(request, evaluator)

Flow

IllustrativeGenerated-package equivalent. Prefer checked-in package examples for copy/paste runnable code.
Go
gepa := ax.NewAxGEPA(map[string]ax.Value{"maxMetricCalls": 40})
artifact, err := gepa.Optimize(request, evaluator)

Agent

IllustrativeGenerated-package equivalent. Prefer checked-in package examples for copy/paste runnable code.
Go
gepa := ax.NewAxGEPA(map[string]ax.Value{"maxMetricCalls": 40})
artifact, err := gepa.Optimize(request, evaluator)

Artifact

IllustrativeGenerated-package equivalent. Prefer checked-in package examples for copy/paste runnable code.
Go
gepa := ax.NewAxGEPA(map[string]ax.Value{"maxMetricCalls": 40})
artifact, err := gepa.Optimize(request, evaluator)

Production Notes

Optimization is a build-time or evaluation-time workflow, not something to hide in every request path. Track score history, cost, token usage, selected Pareto point, and the final artifact version.

See optimize() API.

Docs