axProcessContentForProvider Generated TypeScript API reference. typescript api api/reference build/apidocs/Function.axProcessContentForProvider.md function axProcessContentForProvider

axProcessContentForProvider

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

Defined in: https://github.com/ax-llm/ax/blob/5b28f9093bb70863b59459bb6df5062d005bce41/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:

  • ’error’: Throws AxMediaNotSupportedError
  • ‘degrade’: Converts to text using fallback services or alt text
  • ‘skip’: Omits the unsupported content

Example

TypeScript
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

Docs