router.compare(input, options) sends one document to multiple providers at the same time and returns a single CompareResult containing each provider’s output. This is the fastest way to evaluate which provider performs best on your document type before committing to one in production. Both FileRouter (BYOK) and FileRouterClient (hosted) expose the same compare() signature.
How compare() resolves the input
FileRouter resolves the input document once before dispatching to providers. If you pass aReadableStream, it is consumed a single time and converted to replayable bytes so every provider receives identical data. This also means you can safely pass a File or Blob without worrying about the stream being exhausted.
CompareOptions
The IDs of the providers you want to compare (e.g.
['llamaparse', 'mistral-ocr']). When omitted, the router runs all configured providers concurrently.The output types to request from each provider. Available values match
ParseOptions: 'chunks', 'html', 'images', 'json', 'markdown', 'metadata', 'pages', 'tables', 'text'. A provider that does not support a requested output will appear in the result with status: 'unsupported' rather than failing the whole comparison.One-based page numbers to process. When omitted, all pages are processed. The router translates these into each provider’s native representation.
Namespaced provider-specific options. Only the options matching a given provider’s key are forwarded to that provider — settings for one provider are never sent to another.
Set to
true to include each provider’s complete native response in its ParseResult.raw field.Maximum time in milliseconds to wait for all providers to complete. Defaults to 10 minutes.
An
AbortSignal for cancelling the operation.CompareResult
The result contains top-level metadata about the comparison and aproviders array with one entry per provider.
An array of per-provider results, one entry per provider that was run.
The output types that were requested for this comparison run.
A description of the input document (e.g. the filename or URL).
Timing information for the overall comparison with
startedAt, completedAt (ISO 8601 strings), and durationMs.Complete example
The example below compares LlamaParse and Mistral OCR on the same PDF and prints the Markdown output from each provider that succeeded.compare-providers.ts
Iterating over the result
iterate-compare-result.ts