Skip to main content
Direct BYOK (Bring Your Own Key) mode lets you call LlamaParse, Mistral OCR, and Datalab without routing documents or API keys through the FileRouter hosted service. You instantiate FileRouter directly with your chosen provider adapters, and every request goes straight from your runtime to the provider. This is ideal for environments with strict data residency requirements or when you already have provider accounts you want to use.

The FileRouter class

In BYOK mode you use FileRouter (not FileRouterClient). Import it from @file_router/sdk alongside the provider adapter factories from their respective sub-paths.
router.ts

Constructor options

providers
ProviderMap
required
An object mapping provider IDs to provider adapter instances. Use the adapter factory functions (llamaparse(), mistralOcr(), datalab()) to create adapters. At least one provider is required.

Provider adapters

Each adapter factory reads its standard environment variable automatically so you don’t need to hard-code credentials.

llamaparse() — LlamaParse

Import from @file_router/sdk/llamaparse. Requires the @llamaindex/llama-cloud peer dependency.
llamaparse.ts

mistralOcr() — Mistral OCR

Import from @file_router/sdk/mistral. Requires the @mistralai/mistralai peer dependency.
mistral.ts

datalab() — Datalab

Import from @file_router/sdk/datalab. No additional peer dependency required.
datalab.ts

All providers at once with builtInProviders()

If you want to configure all three built-in providers in one call, use builtInProviders() from @file_router/sdk/catalog. It creates llamaparse, mistral-ocr, and datalab adapters, reading each provider’s standard environment variable automatically.
catalog.ts
You can also pass explicit keys for any or all providers:
catalog-with-keys.ts

Complete example

The example below creates a router with LlamaParse and Mistral OCR, then parses a local file with LlamaParse.
byok-parse.ts
BYOK mode uses each provider’s native file size limits. These differ by provider and may be lower or higher than the 100 MB ceiling enforced by the hosted service. Check each provider’s documentation for their current limits.
Provider-specific options are namespaced under providerOptions, so they are never forwarded to the wrong provider during a compare() call. See parse() for the full providerOptions reference.