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

AxAIServiceImpl

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/ai/types.ts#L493

Type Parameters

Type Parameter
TModel
TEmbedModel
TChatRequest
TEmbedRequest
TChatResponse
TChatResponseDelta
TEmbedResponse

Methods

createChatReq()

createChatReq(req: Readonly<AxInternalChatRequest<TModel>>, config?: Readonly<AxAIServiceOptions>): 
  | [AxAPI, TChatRequest]
| Promise<[AxAPI, TChatRequest]>;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/ai/types.ts#L502

Parameters

ParameterType
reqReadonly<AxInternalChatRequest<TModel>>
config?Readonly<AxAIServiceOptions>

Returns

| [AxAPI, TChatRequest] | Promise<[AxAPI, TChatRequest]>


createChatResp()

createChatResp(resp: Readonly<TChatResponse>): AxChatResponse;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/ai/types.ts#L507

Parameters

ParameterType
respReadonly<TChatResponse>

Returns

AxChatResponse


createChatStreamResp()?

optional createChatStreamResp(resp: Readonly<TChatResponseDelta>, state: object): AxChatResponse;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/ai/types.ts#L509

Parameters

ParameterType
respReadonly<TChatResponseDelta>
stateobject

Returns

AxChatResponse


createEmbedReq()?

optional createEmbedReq(req: Readonly<AxInternalEmbedRequest<TEmbedModel>>): 
  | [AxAPI, TEmbedRequest]
| Promise<[AxAPI, TEmbedRequest]>;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/ai/types.ts#L514

Parameters

ParameterType
reqReadonly<AxInternalEmbedRequest<TEmbedModel>>

Returns

| [AxAPI, TEmbedRequest] | Promise<[AxAPI, TEmbedRequest]>


createEmbedResp()?

optional createEmbedResp(resp: Readonly<TEmbedResponse>): AxEmbedResponse;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/ai/types.ts#L518

Parameters

ParameterType
respReadonly<TEmbedResponse>

Returns

AxEmbedResponse


getModelConfig()

getModelConfig(): AxModelConfig;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/ai/types.ts#L520

Returns

AxModelConfig


getTokenUsage()

getTokenUsage(): undefined | AxTokenUsage;

Defined in: https://github.com/ax-llm/ax/blob/8dfd0ce02b8cb386fb2c93fa280a2ec0da2d6011/src/ax/ai/types.ts#L522

Returns

undefined | AxTokenUsage