{"_id":"@llamaindex/opendocrouter","name":"@llamaindex/opendocrouter","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@llamaindex/opendocrouter","version":"1.0.0","description":"The official TypeScript library for the Open Doc Router API","author":{"name":"Open Doc Router","email":"support@runllama.ai"},"types":"./index.d.ts","main":"./index.js","type":"commonjs","repository":{"type":"git","url":"git+https://github.com/run-llama/opendocrouter-ts.git"},"license":"MIT","private":false,"publishConfig":{"access":"public"},"dependencies":{},"overrides":{"minimatch":"^9.0.5"},"resolutions":{"minimatch":"^9.0.5"},"exports":{".":{"require":{"types":"./index.d.ts","default":"./index.js"},"types":"./index.d.mts","default":"./index.mjs"},"./api-promise":{"import":"./api-promise.mjs","require":"./api-promise.js"},"./api-promise.js":{"default":"./api-promise.js"},"./api-promise.mjs":{"default":"./api-promise.mjs"},"./client":{"import":"./client.mjs","require":"./client.js"},"./client.js":{"default":"./client.js"},"./client.mjs":{"default":"./client.mjs"},"./core/*.mjs":{"default":"./core/*.mjs"},"./core/*.js":{"default":"./core/*.js"},"./core/*":{"import":"./core/*.mjs","require":"./core/*.js"},"./error":{"import":"./error.mjs","require":"./error.js"},"./error.js":{"default":"./error.js"},"./error.mjs":{"default":"./error.mjs"},"./index":{"import":"./index.mjs","require":"./index.js"},"./index.js":{"default":"./index.js"},"./index.mjs":{"default":"./index.mjs"},"./resource":{"import":"./resource.mjs","require":"./resource.js"},"./resource.js":{"default":"./resource.js"},"./resource.mjs":{"default":"./resource.mjs"},"./resources/*.mjs":{"default":"./resources/*.mjs"},"./resources/*.js":{"default":"./resources/*.js"},"./resources/*":{"import":"./resources/*.mjs","require":"./resources/*.js"},"./resources":{"import":"./resources.mjs","require":"./resources.js"},"./resources.js":{"default":"./resources.js"},"./resources.mjs":{"default":"./resources.mjs"},"./uploads":{"import":"./uploads.mjs","require":"./uploads.js"},"./uploads.js":{"default":"./uploads.js"},"./uploads.mjs":{"default":"./uploads.mjs"},"./version":{"import":"./version.mjs","require":"./version.js"},"./version.js":{"default":"./version.js"},"./version.mjs":{"default":"./version.mjs"}},"scripts":{"test":"./scripts/test","build":"./scripts/build","format":"./scripts/format","tsn":"ts-node -r tsconfig-paths/register","lint":"./scripts/lint","fix":"./scripts/format"},"_id":"@llamaindex/opendocrouter@1.0.0","bugs":{"url":"https://github.com/run-llama/opendocrouter-ts/issues"},"homepage":"https://github.com/run-llama/opendocrouter-ts#readme","_integrity":"sha512-J72uV86FQBxNiZW0fDXwW6Pnpsd7xAl+WDctJ6mCVSSCV+MCOgnwr0aHD0lDtSJQy5hmFjGszXeTxwS7yus8IA==","_resolved":"/private/var/folders/lw/xwsz_3yj4ln1gvkxhyddbvvw0000gn/T/24313f83aa4c6f2700aab5d865dd2a1e/llamaindex-opendocrouter-1.0.0.tgz","_from":"file:llamaindex-opendocrouter-1.0.0.tgz","_nodeVersion":"22.23.3","_npmVersion":"10.9.9","dist":{"integrity":"sha512-J72uV86FQBxNiZW0fDXwW6Pnpsd7xAl+WDctJ6mCVSSCV+MCOgnwr0aHD0lDtSJQy5hmFjGszXeTxwS7yus8IA==","shasum":"aacd00006f827944f53b66d73b5a3b48007d2a68","tarball":"https://registry.npmjs.org/@llamaindex/opendocrouter/-/opendocrouter-1.0.0.tgz","fileCount":352,"unpackedSize":585069,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDJbPrEJrob13ATUQ7haXfJQ7oBCMSLtl1RIUYtJsPTMAiBeslrsU/BXR4oGFXYs/mwul3xqP7Ymo9STZVcRFYU7zQ=="}]},"_npmUser":{"name":"cheesyfishes","email":"logan@runllama.ai"},"directories":{},"maintainers":[{"name":"emanuelclferreira","email":"oi@manel.dev"},{"name":"preston-runllama","email":"preston@runllama.ai"},{"name":"yongpark","email":"ypark@protonmail.com"},{"name":"zhaotai","email":"zhaotai5541@gmail.com"},{"name":"cle-does-things","email":"astraberte9@gmail.com"},{"name":"cheesyfishes","email":"logan@runllama.ai"},{"name":"disiok","email":"simonsdsuo@gmail.com"},{"name":"adrianlyjak","email":"adrian.lyjak@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/opendocrouter_1.0.0_1791341637974_0.6696441618321611"},"_hasShrinkwrap":false}},"time":{"created":"2026-10-07T02:53:57.584Z","1.0.0":"2026-10-07T02:53:58.119Z","modified":"2026-10-07T02:53:58.259Z"},"maintainers":[{"name":"emanuelclferreira","email":"oi@manel.dev"},{"name":"preston-runllama","email":"preston@runllama.ai"},{"name":"yongpark","email":"ypark@protonmail.com"},{"name":"zhaotai","email":"zhaotai5541@gmail.com"},{"name":"cle-does-things","email":"astraberte9@gmail.com"},{"name":"cheesyfishes","email":"logan@runllama.ai"},{"name":"disiok","email":"simonsdsuo@gmail.com"},{"name":"adrianlyjak","email":"adrian.lyjak@gmail.com"}],"description":"The official TypeScript library for the Open Doc Router API","homepage":"https://github.com/run-llama/opendocrouter-ts#readme","repository":{"type":"git","url":"git+https://github.com/run-llama/opendocrouter-ts.git"},"author":{"name":"Open Doc Router","email":"support@runllama.ai"},"bugs":{"url":"https://github.com/run-llama/opendocrouter-ts/issues"},"license":"MIT","readme":"# OpenDocRouter TypeScript API Library\n\n[![NPM version](<https://img.shields.io/npm/v/@llamaindex/opendocrouter.svg?label=npm%20(stable)>)](https://npmjs.org/package/@llamaindex/opendocrouter) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@llamaindex/opendocrouter)\n\nThis library provides convenient access to the OpenDocRouter REST API from server-side TypeScript or JavaScript.\n\nThe REST API documentation can be found on [OpenDocRouter](https://www.opendocrouter.ai/docs). The full API of this library can be found in [api.md](api.md).\n\n## Installation\n\n```sh\nnpm install @llamaindex/opendocrouter\n```\n\n## Usage\n\nThe full API of this library can be found in [api.md](api.md).\n\n<!-- prettier-ignore -->\n```js\nimport OpenDocRouter from '@llamaindex/opendocrouter';\n\nconst client = new OpenDocRouter({\n  apiKey: process.env['OPEN_DOC_ROUTER_API_KEY'], // This is the default and can be omitted\n});\n\nconst parseRecord = await client.parse.create({\n  document: { url: 'https://arxiv.org/pdf/1706.03762' },\n  model: 'google/gemini-3-flash',\n});\n\nconsole.log(parseRecord.id);\n```\n\n### Request & Response types\n\nThis library includes TypeScript definitions for all request params and response fields. You may import and use them like so:\n\n<!-- prettier-ignore -->\n```ts\nimport OpenDocRouter from '@llamaindex/opendocrouter';\n\nconst client = new OpenDocRouter({\n  apiKey: process.env['OPEN_DOC_ROUTER_API_KEY'], // This is the default and can be omitted\n});\n\nconst parseRecord: OpenDocRouter.ParseRecord = await client.parse.get(\n  '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',\n);\n```\n\nDocumentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.\n\n## Handling errors\n\nWhen the library is unable to connect to the API,\nor if the API returns a non-success status code (i.e., 4xx or 5xx response),\na subclass of `APIError` will be thrown:\n\n<!-- prettier-ignore -->\n```ts\nconst parseRecord = await client.parse\n  .get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e')\n  .catch(async (err) => {\n    if (err instanceof OpenDocRouter.APIError) {\n      console.log(err.status); // 400\n      console.log(err.name); // BadRequestError\n      console.log(err.headers); // {server: 'nginx', ...}\n    } else {\n      throw err;\n    }\n  });\n```\n\nError codes are as follows:\n\n| Status Code | Error Type                 |\n| ----------- | -------------------------- |\n| 400         | `BadRequestError`          |\n| 401         | `AuthenticationError`      |\n| 403         | `PermissionDeniedError`    |\n| 404         | `NotFoundError`            |\n| 409         | `ConflictError`            |\n| 422         | `UnprocessableEntityError` |\n| 429         | `RateLimitError`           |\n| >=500       | `InternalServerError`      |\n| N/A         | `APIConnectionError`       |\n\n### Retries\n\nCertain errors will be automatically retried 2 times by default, with a short exponential backoff.\nConnection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,\n429 Rate Limit, and >=500 Internal errors will all be retried by default.\n\nYou can use the `maxRetries` option to configure or disable this:\n\n<!-- prettier-ignore -->\n```js\n// Configure the default for all requests:\nconst client = new OpenDocRouter({\n  maxRetries: 0, // default is 2\n});\n\n// Or, configure per-request:\nawait client.parse.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {\n  maxRetries: 5,\n});\n```\n\n### Timeouts\n\nRequests time out after 1 minute by default. You can configure this with a `timeout` option:\n\n<!-- prettier-ignore -->\n```ts\n// Configure the default for all requests:\nconst client = new OpenDocRouter({\n  timeout: 20 * 1000, // 20 seconds (default is 1 minute)\n});\n\n// Override per-request:\nawait client.parse.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {\n  timeout: 5 * 1000,\n});\n```\n\nOn timeout, an `APIConnectionTimeoutError` is thrown.\n\nNote that requests which time out will be [retried twice by default](#retries).\n\n## Advanced Usage\n\n### Accessing raw Response data (e.g., headers)\n\nThe \"raw\" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.\nThis method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.\n\nYou can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.\nUnlike `.asResponse()` this method consumes the body, returning once it is parsed.\n\n<!-- prettier-ignore -->\n```ts\nconst client = new OpenDocRouter();\n\nconst response = await client.parse.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e').asResponse();\nconsole.log(response.headers.get('X-My-Header'));\nconsole.log(response.statusText); // access the underlying Response object\n\nconst { data: parseRecord, response: raw } = await client.parse\n  .get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e')\n  .withResponse();\nconsole.log(raw.headers.get('X-My-Header'));\nconsole.log(parseRecord.id);\n```\n\n### Logging\n\n> [!IMPORTANT]\n> All log messages are intended for debugging only. The format and content of log messages\n> may change between releases.\n\n#### Log levels\n\nThe log level can be configured in two ways:\n\n1. Via the `OPEN_DOC_ROUTER_LOG` environment variable\n2. Using the `logLevel` client option (overrides the environment variable if set)\n\n```ts\nimport OpenDocRouter from '@llamaindex/opendocrouter';\n\nconst client = new OpenDocRouter({\n  logLevel: 'debug', // Show all log messages\n});\n```\n\nAvailable log levels, from most to least verbose:\n\n- `'debug'` - Show debug messages, info, warnings, and errors\n- `'info'` - Show info messages, warnings, and errors\n- `'warn'` - Show warnings and errors (default)\n- `'error'` - Show only errors\n- `'off'` - Disable all logging\n\nAt the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.\nSome authentication-related headers are redacted, but sensitive data in request and response bodies\nmay still be visible.\n\n#### Custom logger\n\nBy default, this library logs to `globalThis.console`. You can also provide a custom logger.\nMost logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.\n\nWhen providing a custom logger, the `logLevel` option still controls which messages are emitted, messages\nbelow the configured level will not be sent to your logger.\n\n```ts\nimport OpenDocRouter from '@llamaindex/opendocrouter';\nimport pino from 'pino';\n\nconst logger = pino();\n\nconst client = new OpenDocRouter({\n  logger: logger.child({ name: 'OpenDocRouter' }),\n  logLevel: 'debug', // Send all messages to pino, allowing it to filter\n});\n```\n\n### Fetch options\n\nIf you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)\n\n```ts\nimport OpenDocRouter from '@llamaindex/opendocrouter';\n\nconst client = new OpenDocRouter({\n  fetchOptions: {\n    // `RequestInit` options\n  },\n});\n```\n\n## Frequently Asked Questions\n\n## Semantic versioning\n\nThis package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:\n\n1. Changes that only affect static types, without breaking runtime behavior.\n2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_\n3. Changes that we do not expect to impact the vast majority of users in practice.\n\nWe take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.\n\nWe are keen for your feedback; please open an [issue](https://www.github.com/run-llama/opendocrouter-ts/issues) with questions, bugs, or suggestions.\n\n## Requirements\n\nTypeScript >= 4.9 is supported.\n\nThe following runtimes are supported:\n\n- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)\n- Node.js 20 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.\n- Deno v1.28.0 or higher.\n- Bun 1.0 or later.\n- Cloudflare Workers.\n- Vercel Edge Runtime.\n- Jest 28 or greater with the `\"node\"` environment (`\"jsdom\"` is not supported at this time).\n- Nitro v2.6 or greater.\n\nNote that React Native is not supported at this time.\n\nIf you are interested in other runtime environments, please open or upvote an issue on GitHub.\n\n## Contributing\n\nSee [the contributing documentation](./CONTRIBUTING.md).\n","readmeFilename":"README.md","_rev":"1-b752196598e81fb2c5066452878cc95b"}