Export For AI

The Export For AI function creates an HTML representation of the input file, optimized for sending to AI as context.

When to Use this Option

When you send plain text from Filter to an AI as context, the results might be reasonable, but it misses some things that might enable the AI to better interpret the input. For example, it might not provide enough information on:

  • Tabular data. Filter provides the text from tables, but not the structure.

  • Images, including their location in the text.

  • The way footnotes and comments are linked to the main body of text.

  • Headings.

On the other hand, providing the output of HTML Export to AI would include a lot of styling and display information that is not relevant to the AI, which might result in worse responses and higher token usage.

Export for AI attempts to provide a balance, by providing semantic context with minimal tokens, rather than styling output for a Web browser. It provides more context than the plain text filter output, but less style content that is not relevant to the AI.

NOTE: Export For AI must be enabled in your license. If you want to use only Export For AI and the Extract API, you do not need a Filter license.

Output

The Export For AI function provides a single HTML file that contains a representation of the document content.

The HTML might also include references to images, which are output as separate files. You can handle these images in different ways, depending on your use case. For example, you might want to: 

  • Ignore the images.

  • Send the images to a multi-modal LLM.

  • Send the images back to the Export For AI function to perform OCR.

Workflow

When planning your workflow with Export For AI, you might want to consider the following factors.

  • Splitting documents. When you send output to an AI, consider whether to send the whole output, or to provide only relevant fragments. When available, you might be able to split documents by using HTML elements such as headings and paragraphs, to provide more coherent fragments than splitting on a particular byte count.

  • Subfiles. Export for AI includes embedded images, but not subfiles. You might want to use the Extract API to extract additional subfiles for processing.

    TIP: If you extract subfiles, you might want to disable Extract Images, because the Export for AI action extracts them.

  • Images. When your license allows OCR, if you perform Export For AI on a raster image, the function runs OCR on the images and returns the text in an overlay, in the same way as the Export Files to HTML function.

Security Considerations

In addition to standard security best practices, the following additional security considerations apply when using Export for AI.

  • Consider using an empty directory to contain the output HTML from Export For AI. This precaution makes it simple to avoid mistaking images that were part of a previous export as being part of this export.

  • If source documents are not from trusted sources, you must take precautions to avoid the following risks: 

    • Prompt Injection. In prompt injection, the source document contains instructions to your AI that you might not want it to follow.

    • Malicious hyperlinks. If your AI tooling can follow hyperlinks, you must take precautions against malicious hyperlinks that might be in your input documents.

    • Malicious input file names. To mitigate the risks of malicious input file names, OpenText recommends that you treat file names as metadata, rather than using them as actual file or folder names on disk.

For more information about security best practices, see Security Best Practices.

Use Export For AI

The following guide provides an example of how to run Export for AI.

To export a file to HTML for AI

  • In the .NET API, call the method ExportForAi on your document object. For example:

    Copy
    using (Session session = new Session(bin_path, license))
    {
        using (Document myDoc = session.Open("input.docx"))
        {
            myDoc.ExportForAi("output.html");
        }
    }