optimize() API GEPA optimizer, Pareto, artifact, and evaluation APIs. typescript api api/optimize build/apidocs api optimize() API

optimize() API

GEPA, Pareto, artifact, and optimizer APIs.

Most Used

AxBootstrapFewShot

Abstract base class for optimizers that provides common functionality and standardized handling of AxOptimizerArgs

FieldValue
Kindclass
FormAxBootstrapFewShot
Sourcesource

Call Shape

TypeScript
new AxBootstrapFewShot(args: Readonly<AxOptimizerArgs & object>): AxBootstrapFewShot;

Full reference

AxGEPA

Single-module GEPA (reflective prompt evolution with Pareto sampling)

FieldValue
Kindclass
FormAxGEPA
Sourcesource

Call Shape

TypeScript
new AxGEPA(args: Readonly<AxOptimizerArgs>): AxGEPA;

Full reference

AxOptimizedProgram

TypeScript interface exported by @ax-llm/ax. See the fields and full reference below.

FieldValue
Kindinterface
FormAxOptimizedProgram
Sourcesource

Call Shape

TypeScript
applyTo<IN, T>(program: AxGen<IN, T>): void;

Full reference

optimize

TypeScript function exported by @ax-llm/ax. See the call shape, arguments, and full reference below.

FieldValue
Kindfunction
Formoptimize
ReturnsPromise<AxParetoResult<OUT>>
Sourcesource

Call Shape

TypeScript
function optimize<IN, OUT>(
   program: Readonly<AxProgrammable<IN, OUT>>, 
   examples: readonly AxTypedExample<IN>[], 
   metricFn: 
  | AxMetricFn
  | AxMultiMetricFn, 
options: Readonly<AxOptimizeOptions>): Promise<AxParetoResult<OUT>>;

Arguments And Options

NameTypeDescription
programReadonly<AxProgrammable<IN, OUT>>
examplesreadonly AxTypedExample<IN>[]
metricFn\| AxMetricFn \| AxMultiMetricFn
optionsReadonly<AxOptimizeOptions>

Full reference

Advanced / internals / full reference

AxAgentDemos

Demo traces for AxAgent’s split architecture. Actor demos use the runtime code field (javascriptCode for JavaScript, <language>Code for other runtimes such as pythonCode). Responder demos use the agent’s output type + optional input fields.

FieldValue
Kindtypealias
FormAxAgentDemos
Sourcesource

Call Shape

TypeScript
type AxAgentDemos<IN, OUT, PREFIX> = 
  | {
  programId: `${PREFIX}.actor`;
  traces: Record<string, AxFieldValue>[];
}
  | {
  programId: `${PREFIX}.responder`;
  traces: OUT & Partial<IN>[];
};

Full reference

AxAgentOptimizationTargetDescriptor

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxAgentOptimizationTargetDescriptor
Sourcesource

Call Shape

TypeScript
type AxAgentOptimizationTargetDescriptor = object;

Full reference

AxAgentOptimizeOptions

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxAgentOptimizeOptions
Sourcesource

Call Shape

TypeScript
type AxAgentOptimizeOptions<_IN, _OUT> = object & Pick<AxOptimizerArgs, 
  | "numTrials"
  | "minibatch"
  | "minibatchSize"
  | "earlyStoppingTrials"
  | "minImprovementThreshold"
  | "sampleCount"
| "seed">;

Full reference

AxAgentOptimizeResult

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxAgentOptimizeResult
Sourcesource

Call Shape

TypeScript
type AxAgentOptimizeResult<OUT> = AxParetoResult<OUT>;

Full reference

AxAgentOptimizeTarget

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxAgentOptimizeTarget
Sourcesource

Call Shape

TypeScript
type AxAgentOptimizeTarget = "actor" | "responder" | "all" | readonly string[];

Full reference

AxBaseOptimizer

Abstract base class for optimizers that provides common functionality and standardized handling of AxOptimizerArgs

FieldValue
Kindclass
FormAxBaseOptimizer
Sourcesource

Call Shape

TypeScript
new AxBaseOptimizer(args: Readonly<AxOptimizerArgs>): AxBaseOptimizer;

Full reference

AxBootstrapOptimizerOptions

TypeScript interface exported by @ax-llm/ax. See the fields and full reference below.

FieldValue
Kindinterface
FormAxBootstrapOptimizerOptions
Sourcesource

Full reference

axCreateDefaultOptimizerColorLogger

Factory function to create a default optimizer logger with color formatting

FieldValue
Kindfunction
FormaxCreateDefaultOptimizerColorLogger
ReturnsAxOptimizerLoggerFunction
Sourcesource

Call Shape

TypeScript
function axCreateDefaultOptimizerColorLogger(output: (message: string) => void): AxOptimizerLoggerFunction;

Arguments And Options

NameTypeDescription
output(message: string) => void

Full reference

axCreateDefaultOptimizerTextLogger

Factory function to create a text-only optimizer logger (no colors)

FieldValue
Kindfunction
FormaxCreateDefaultOptimizerTextLogger
ReturnsAxOptimizerLoggerFunction
Sourcesource

Call Shape

TypeScript
function axCreateDefaultOptimizerTextLogger(output: (message: string) => void): AxOptimizerLoggerFunction;

Arguments And Options

NameTypeDescription
output(message: string) => void

Full reference

axDefaultOptimizerLogger

Default optimizer logger instance with color formatting

FieldValue
Kindvariable
FormaxDefaultOptimizerLogger
Sourcesource

Call Shape

TypeScript
const axDefaultOptimizerLogger: AxOptimizerLoggerFunction;

Full reference

axDefaultOptimizerMetricsConfig

TypeScript variable exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindvariable
FormaxDefaultOptimizerMetricsConfig
Sourcesource

Call Shape

TypeScript
const axDefaultOptimizerMetricsConfig: AxOptimizerMetricsConfig;

Full reference

axDeserializeOptimizedProgram

TypeScript function exported by @ax-llm/ax. See the call shape, arguments, and full reference below.

FieldValue
Kindfunction
FormaxDeserializeOptimizedProgram
ReturnsAxOptimizedProgramImpl<OUT>
Sourcesource

Call Shape

TypeScript
function axDeserializeOptimizedProgram<OUT>(serialized: Readonly<AxSerializedOptimizedProgram<OUT>>): AxOptimizedProgramImpl<OUT>;

Arguments And Options

NameTypeDescription
serializedReadonly<AxSerializedOptimizedProgram<OUT>>

Full reference

AxGEPAAdapter

TypeScript interface exported by @ax-llm/ax. See the fields and full reference below.

FieldValue
Kindinterface
FormAxGEPAAdapter
Sourcesource

Call Shape

TypeScript
evaluate(
   batch: readonly Datum[], 
   candidate: Readonly<Record<string, string>>, 
   captureTraces?: boolean): 
  | AxGEPAEvaluationBatch<Traj, Out>
| Promise<AxGEPAEvaluationBatch<Traj, Out>>;

Full reference

AxGEPABatchEvaluation

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxGEPABatchEvaluation
Sourcesource

Call Shape

TypeScript
type AxGEPABatchEvaluation = object;

Full reference

AxGEPABatchRow

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxGEPABatchRow
Sourcesource

Call Shape

TypeScript
type AxGEPABatchRow = object;

Full reference

AxGEPABootstrapOptions

TypeScript interface exported by @ax-llm/ax. See the fields and full reference below.

FieldValue
Kindinterface
FormAxGEPABootstrapOptions
Sourcesource

Full reference

AxGEPAComponentBanditState

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxGEPAComponentBanditState
Sourcesource

Call Shape

TypeScript
type AxGEPAComponentBanditState = object;

Full reference

AxGEPAComponentSelector

TypeScript class exported by @ax-llm/ax. See the constructor, methods, and full reference below.

FieldValue
Kindclass
FormAxGEPAComponentSelector
Sourcesource

Call Shape

TypeScript
new AxGEPAComponentSelector(targets: readonly AxGEPAComponentTarget[], initialState?: Readonly<Record<string, AxGEPAComponentBanditState>>): AxGEPAComponentSelector;

Full reference

AxGEPAComponentTarget

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxGEPAComponentTarget
Sourcesource

Call Shape

TypeScript
type AxGEPAComponentTarget = object;

Full reference

AxGEPAEvaluationBatch

TypeScript interface exported by @ax-llm/ax. See the fields and full reference below.

FieldValue
Kindinterface
FormAxGEPAEvaluationBatch
Sourcesource

Full reference

AxGEPAEvaluationState

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxGEPAEvaluationState
Sourcesource

Call Shape

TypeScript
type AxGEPAEvaluationState = object;

Full reference

AxGEPAOptimizationReport

Structured optimization report

FieldValue
Kindinterface
FormAxGEPAOptimizationReport
Sourcesource

Full reference

AxGEPAReflectiveTuple

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxGEPAReflectiveTuple
Sourcesource

Call Shape

TypeScript
type AxGEPAReflectiveTuple = object;

Full reference

AxGEPATraceSummary

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxGEPATraceSummary
Sourcesource

Call Shape

TypeScript
type AxGEPATraceSummary = object;

Full reference

AxGEPATraceSummaryCall

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxGEPATraceSummaryCall
Sourcesource

Call Shape

TypeScript
type AxGEPATraceSummaryCall = object;

Full reference

axGetOptimizerMetricsConfig

TypeScript function exported by @ax-llm/ax. See the call shape, arguments, and full reference below.

FieldValue
Kindfunction
FormaxGetOptimizerMetricsConfig
ReturnsAxOptimizerMetricsConfig
Sourcesource

Call Shape

TypeScript
function axGetOptimizerMetricsConfig(): AxOptimizerMetricsConfig;

Full reference

AxOptimizationCheckpoint

TypeScript interface exported by @ax-llm/ax. See the fields and full reference below.

FieldValue
Kindinterface
FormAxOptimizationCheckpoint
Sourcesource

Full reference

AxOptimizationProgress

TypeScript interface exported by @ax-llm/ax. See the fields and full reference below.

FieldValue
Kindinterface
FormAxOptimizationProgress
Sourcesource

Full reference

AxOptimizationStats

TypeScript interface exported by @ax-llm/ax. See the fields and full reference below.

FieldValue
Kindinterface
FormAxOptimizationStats
Sourcesource

Full reference

AxOptimizedProgramImpl

TypeScript class exported by @ax-llm/ax. See the constructor, methods, and full reference below.

FieldValue
Kindclass
FormAxOptimizedProgramImpl
Sourcesource

Call Shape

TypeScript
new AxOptimizedProgramImpl<OUT>(config: object): AxOptimizedProgramImpl<OUT>;

Full reference

AxOptimizeOptions

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxOptimizeOptions
Sourcesource

Call Shape

TypeScript
type AxOptimizeOptions = AxOptimizerArgs & Omit<AxCompileOptions, "bootstrap"> & object;

Full reference

AxOptimizer

Interface for optimizing AI programs through automated prompt tuning.

FieldValue
Kindinterface
FormAxOptimizer
Sourcesource

Call Shape

TypeScript
const optimizer = new AxBootstrapFewShot({ maxDemos: 4 });

const result = await optimizer.compile(
  program,
  trainingExamples,
  ({ prediction, example }) => prediction.answer === example.expectedAnswer ? 1 : 0
);

// Apply optimized demos to program
program.setDemos(result.demos);

Full reference

AxOptimizerArgs

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxOptimizerArgs
Sourcesource

Call Shape

TypeScript
type AxOptimizerArgs = object;

Full reference

AxOptimizerLoggerData

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxOptimizerLoggerData
Sourcesource

Call Shape

TypeScript
type AxOptimizerLoggerData = 
  | {
  name: "OptimizationStart";
  value: {
     config: Record<string, unknown>;
     exampleCount: number;
     optimizerType: string;
     validationCount: number;
  };
}
  | {
  name: "RoundProgress";
  value: {
     bestScore: number;
     configuration: Record<string, unknown>;
     currentScore: number;
     round: number;
     totalRounds: number;
  };
}
  | {
  name: "EarlyStopping";
  value: {
     finalScore: number;
     reason: string;
     round: number;
  };
}
  | {
  name: "OptimizationComplete";
  value: {
     bestConfiguration: Record<string, unknown>;
     bestScore: number;
     explanation?: string;
     optimizerType?: string;
     performanceAssessment?: string;
     recommendations?: string[];
     stats: AxOptimizationStats;
     successRate?: string;
     totalCalls?: number;
  };
}
  | {
  name: "ConfigurationProposal";
  value: {
     count: number;
     proposals: string[] | Record<string, unknown>[];
     type: "instructions" | "demos" | "general";
  };
}
  | {
  name: "BootstrappedDemos";
  value: {
     count: number;
     demos: unknown[];
  };
}
  | {
  name: "BestConfigFound";
  value: {
     config: Record<string, unknown>;
     score: number;
  };
};

Full reference

AxOptimizerLoggerFunction

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxOptimizerLoggerFunction
Returnsvoid
Sourcesource

Call Shape

TypeScript
type AxOptimizerLoggerFunction = (data: AxOptimizerLoggerData) => void;

Arguments And Options

NameTypeDescription
dataAxOptimizerLoggerData

Full reference

AxOptimizerMetricsConfig

TypeScript interface exported by @ax-llm/ax. See the fields and full reference below.

FieldValue
Kindinterface
FormAxOptimizerMetricsConfig
Sourcesource

Full reference

AxOptimizerMetricsInstruments

TypeScript interface exported by @ax-llm/ax. See the fields and full reference below.

FieldValue
Kindinterface
FormAxOptimizerMetricsInstruments
Sourcesource

Full reference

AxOptimizerResult

TypeScript interface exported by @ax-llm/ax. See the fields and full reference below.

FieldValue
Kindinterface
FormAxOptimizerResult
Sourcesource

Full reference

AxParetoResult

TypeScript interface exported by @ax-llm/ax. See the fields and full reference below.

FieldValue
Kindinterface
FormAxParetoResult
Sourcesource

Full reference

AxProgramDemos

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxProgramDemos
Sourcesource

Call Shape

TypeScript
type AxProgramDemos<IN, OUT, ID> = object;

Full reference

AxSerializedOptimizedProgram

TypeScript typealias exported by @ax-llm/ax. See the full reference for complete details.

FieldValue
Kindtypealias
FormAxSerializedOptimizedProgram
Sourcesource

Call Shape

TypeScript
type AxSerializedOptimizedProgram<OUT> = Omit<AxOptimizedProgram<OUT>, "applyTo">;

Full reference

axSerializeOptimizedProgram

TypeScript function exported by @ax-llm/ax. See the call shape, arguments, and full reference below.

FieldValue
Kindfunction
FormaxSerializeOptimizedProgram
ReturnsAxSerializedOptimizedProgram<OUT>
Sourcesource

Call Shape

TypeScript
function axSerializeOptimizedProgram<OUT>(optimizedProgram: Readonly<AxOptimizedProgram<OUT>>): AxSerializedOptimizedProgram<OUT>;

Arguments And Options

NameTypeDescription
optimizedProgramReadonly<AxOptimizedProgram<OUT>>

Full reference

axUpdateOptimizerMetricsConfig

TypeScript function exported by @ax-llm/ax. See the call shape, arguments, and full reference below.

FieldValue
Kindfunction
FormaxUpdateOptimizerMetricsConfig
Returnsvoid
Sourcesource

Call Shape

TypeScript
function axUpdateOptimizerMetricsConfig(config: Readonly<Partial<AxOptimizerMetricsConfig>>): void;

Arguments And Options

NameTypeDescription
configReadonly<Partial<AxOptimizerMetricsConfig>>

Full reference

Full Reference

Open the full TypeScript reference. This page highlights the optimize symbols most relevant to everyday use.

Docs