INTEGRITY Cloudflare Docs

Conversion Options

By default, the toMarkdown service extracts text content from your files. To further extend the capabilities of the conversion process, you can pass options to the service to control how specific file types are converted.

Options are organized by file type and are all optional.

Available options

Output

{
  output?: {
    format?: 'markdown' | 'text';
  }
}

When format is text, the format field of the ConversionResult is also set to text.

Images

{
  image?: {
    descriptionLanguage?: 'en' | 'it' | 'de' | 'es' | 'fr' | 'pt';
  }
}

HTML

{
  html?: {
    hostname?: string;
    cssSelector?: string;
  }
}

PDF

{
  pdf?: {
    metadata?: boolean;
  }
}

Examples

Binding

To configure custom options, pass a conversionOptions object inside the second argument of the binding call, like this:

await env.AI.toMarkdown(..., {
  conversionOptions: {
    html: { ... },
    pdf: { ... },
    ...
   }
})

REST API

Since the REST API uses file uploads, the request's Content-Type will be multipart/form-data. As such, include a new form field with your stringified object as a value:

curl https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/tomarkdown \
  -X POST \
  -H 'Authorization: Bearer {API_TOKEN}' \
  ...
  -F 'conversionOptions={ "html": { ... }, ... }'