axProcessContentForProvider
function axProcessContentForProvider(
content: any,
provider: AxAIService,
options: ProcessingOptions): Promise<ProcessedContent[]>;Defined in: https://github.com/ax-llm/ax/blob/781623e58befc00a555cf73ccbac598a72bb700c/src/ax/ai/processor.ts#L87
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 for a text-only provider: [{ 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 processed text and supported native media items
Throws
AxMediaNotSupportedError when fallbackBehavior is ’error’ and content is unsupported
Throws
AxContentProcessingError when a conversion service fails