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

AxAI

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L133

Type Parameters

Type ParameterDefault type
TModelKeystring

Implements

Constructors

Constructor

new AxAI<TModelKey>(options: Readonly<AxAIArgs<TModelKey>>): AxAI<TModelKey>;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L161

Deprecated

Use AxAI.create() or ai() function instead for better type safety. This constructor will be removed in v15.0.0.

Migration timeline:

Example

// Instead of: new AxAI({ name: 'openai', apiKey: '...' })
// Use: AxAI.create({ name: 'openai', apiKey: '...' })
// Or: ai({ name: 'openai', apiKey: '...' })

Parameters

ParameterType
optionsReadonly<AxAIArgs<TModelKey>>

Returns

AxAI<TModelKey>

Methods

chat()

chat(req: Readonly<AxChatRequest<TModelKey>>, options?: Readonly<AxAIServiceOptions>): Promise<
  | AxChatResponse
| ReadableStream<AxChatResponse>>;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L245

Parameters

ParameterType
reqReadonly<AxChatRequest<TModelKey>>
options?Readonly<AxAIServiceOptions>

Returns

Promise< | AxChatResponse | ReadableStream<AxChatResponse>>

Implementation of

AxAIService.chat


embed()

embed(req: Readonly<AxEmbedRequest<TModelKey>>, options?: Readonly<AxAIServiceOptions>): Promise<AxEmbedResponse>;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L252

Parameters

ParameterType
reqReadonly<AxEmbedRequest<TModelKey>>
options?Readonly<AxAIServiceOptions>

Returns

Promise<AxEmbedResponse>

Implementation of

AxAIService.embed


getFeatures()

getFeatures(model?: string): AxAIFeatures;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L221

Parameters

ParameterType
model?string

Returns

AxAIFeatures

Implementation of

AxAIService.getFeatures


getId()

getId(): string;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L217

Returns

string

Implementation of

AxAIService.getId


getLastUsedChatModel()

getLastUsedChatModel(): any;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L229

Returns

any

Implementation of

AxAIService.getLastUsedChatModel


getLastUsedEmbedModel()

getLastUsedEmbedModel(): any;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L233

Returns

any

Implementation of

AxAIService.getLastUsedEmbedModel


getLastUsedModelConfig()

getLastUsedModelConfig(): undefined | AxModelConfig;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L237

Returns

undefined | AxModelConfig

Implementation of

AxAIService.getLastUsedModelConfig


getLogger()

getLogger(): AxLoggerFunction;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L267

Returns

AxLoggerFunction

Implementation of

AxAIService.getLogger


getMetrics()

getMetrics(): AxAIServiceMetrics;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L241

Returns

AxAIServiceMetrics

Implementation of

AxAIService.getMetrics


getModelList()

getModelList(): 
  | undefined
| AxAIModelList<TModelKey>;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L225

Returns

| undefined | AxAIModelList<TModelKey>

Implementation of

AxAIService.getModelList


getName()

getName(): string;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L213

Returns

string

Implementation of

AxAIService.getName


getOptions()

getOptions(): Readonly<AxAIServiceOptions>;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L263

Returns

Readonly<AxAIServiceOptions>

Implementation of

AxAIService.getOptions


setOptions()

setOptions(options: Readonly<AxAIServiceOptions>): void;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L259

Parameters

ParameterType
optionsReadonly<AxAIServiceOptions>

Returns

void

Implementation of

AxAIService.setOptions


create()

static create<T>(options: T): AxAI<InferTModelKey<T>>;

Defined in: https://github.com/ax-llm/ax/blob/9a5a7060a48f9eef46efc680b0cdf6b42bff5df2/src/ax/ai/wrap.ts#L139

Type Parameters

Type Parameter
T extends AxAIArgs<any>

Parameters

ParameterType
optionsT

Returns

AxAI<InferTModelKey<T>>