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 useFileRouter (not FileRouterClient). Import it from @file_router/sdk alongside the provider adapter factories from their respective sub-paths.
router.ts
Constructor options
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
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
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.