Documentation

Build LLM-powered agents
with production-ready TypeScript

DSPy for TypeScript. Working with LLMs is complex—they don't always do what you want. DSPy makes it easier to build amazing things with LLMs. Just define your inputs and outputs (signature) and an efficient prompt is auto-generated and used. Connect together various signatures to build complex systems and workflows using LLMs.

15+ LLM Providers
End-to-end Streaming
Auto Prompt Tuning

AxStepContext

Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/types.ts#L45

Mutable context object that flows through the generation loop. Accessible to functions and step hooks, enabling per-step control over model, options, functions, and loop flow.

Uses a pending mutations pattern: changes are collected during a step and applied at the top of the next iteration.

Properties

PropertyModifierType
functionsExecutedreadonlyReadonlySet<string>
isFirstStepreadonlyboolean
lastFunctionCallsreadonlyreadonly AxFunctionCallRecord[]
maxStepsreadonlynumber
statereadonlyMap<string, unknown>
stepIndexreadonlynumber
usagereadonlyReadonly<AxStepUsage>

Methods

addFunctions()

addFunctions(functions: AxInputFunctionType): void;

Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/types.ts#L67

Parameters

ParameterType
functionsAxInputFunctionType

Returns

void


removeFunctions()

removeFunctions(...names: string[]): void;

Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/types.ts#L68

Parameters

ParameterType
namesstring[]

Returns

void


setMaxTokens()

setMaxTokens(maxTokens: number): void;

Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/types.ts#L61

Parameters

ParameterType
maxTokensnumber

Returns

void


setModel()

setModel(model: string): void;

Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/types.ts#L58

Parameters

ParameterType
modelstring

Returns

void


setOptions()

setOptions(options: Partial<AxAIServiceOptions & object>): void;

Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/types.ts#L62

Parameters

ParameterType
optionsPartial<AxAIServiceOptions & object>

Returns

void


setTemperature()

setTemperature(temperature: number): void;

Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/types.ts#L60

Parameters

ParameterType
temperaturenumber

Returns

void


setThinkingBudget()

setThinkingBudget(budget: undefined | "high" | "low" | "minimal" | "medium" | "highest" | "none"): void;

Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/types.ts#L59

Parameters

ParameterType
budgetundefined | "high" | "low" | "minimal" | "medium" | "highest" | "none"

Returns

void


stop()

stop(resultValues?: Record<string, unknown>): void;

Defined in: https://github.com/ax-llm/ax/blob/71ea5064d766efdc031d375243a8e525911833e7/src/ax/dsp/types.ts#L69

Parameters

ParameterType
resultValues?Record<string, unknown>

Returns

void