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:
- ‘error’: Throws AxMediaNotSupportedError
- ‘degrade’: Converts to text using fallback services or alt text
- ‘skip’: Omits the unsupported content
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
Parameter | Type | Description |
---|---|---|
content | any | The content to process (string, object, or array of content items) |
provider | AxAIService | The target AI service provider |
options | ProcessingOptions | Processing 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