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

axProcessContentForProvider

function axProcessContentForProvider(
   content: any, 
   provider: AxAIService, 
options: ProcessingOptions): Promise<ProcessedContent[]>;

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

Processes content for a specific AI provider, handling unsupported media types.

This function takes mixed content (text, images, audio, files, URLs) and transforms it to formats supported by the target provider. Unsupported content types are handled according to the fallback behavior:

Example

const processed = await axProcessContentForProvider(
  [
    { type: 'text', text: 'Analyze this:' },
    { type: 'image', image: 'base64...', altText: 'Chart showing sales data' }
  ],
  textOnlyProvider,
  {
    fallbackBehavior: 'degrade',
    imageToText: async (data) => await visionService.describe(data)
  }
);
// Result: [{ type: 'text', text: 'Analyze this:' }, { type: 'text', text: 'Chart showing sales data' }]

Parameters

ParameterTypeDescription
contentanyThe content to process (string, object, or array of content items)
providerAxAIServiceThe target AI service provider
optionsProcessingOptionsProcessing options including fallback behavior and conversion services

Returns

Promise<ProcessedContent[]>

Promise resolving to array of processed content items (all converted to text)

Throws

AxMediaNotSupportedError when fallbackBehavior is ‘error’ and content is unsupported

Throws

AxContentProcessingError when a conversion service fails