### Installing Ragie SDK with Bun Source: https://github.com/ragieai/ragie-typescript/blob/main/README.md This command installs the Ragie SDK using the Bun package manager, leveraging Bun's fast runtime and package management capabilities. ```bash bun add ragie ``` -------------------------------- ### Installing Ragie SDK with PNPM Source: https://github.com/ragieai/ragie-typescript/blob/main/README.md This command installs the Ragie SDK using the pnpm package manager, providing a disk-space efficient way to manage dependencies. ```bash pnpm add ragie ``` -------------------------------- ### Installing Ragie SDK with Yarn Source: https://github.com/ragieai/ragie-typescript/blob/main/README.md This command installs the Ragie SDK and its peer dependency 'zod' using the Yarn package manager, as Yarn does not automatically install peer dependencies. ```bash yarn add ragie zod ``` -------------------------------- ### Installing Ragie SDK with NPM Source: https://github.com/ragieai/ragie-typescript/blob/main/README.md This command installs the Ragie SDK using the npm package manager, making it available for use in your Node.js or TypeScript projects. ```bash npm add ragie ``` -------------------------------- ### Creating a Document with Ragie SDK Source: https://github.com/ragieai/ragie-typescript/blob/main/README.md This TypeScript example demonstrates how to initialize the Ragie SDK with an authentication token and then use it to create a document by uploading a file. It uses `node:fs` to open the file as a Blob. ```typescript import { openAsBlob } from "node:fs"; import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "", }); async function run() { const result = await ragie.documents.create({ file: await openAsBlob("example.file"), }); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Configuring Standalone MCP Server Source: https://github.com/ragieai/ragie-typescript/blob/main/README.md This JSON configuration defines an MCP server named 'Todos' that runs a previously downloaded standalone binary, specifying the command and arguments to start it. ```json { "mcpServers": { "Todos": { "command": "./DOWNLOAD/PATH/mcp-server", "args": [ "start" ] } } } ``` -------------------------------- ### Displaying Ragie MCP Server Help Source: https://github.com/ragieai/ragie-typescript/blob/main/README.md This command executes the 'mcp start --help' command from the 'ragie' package using npx, providing a comprehensive list of available arguments and options for the Ragie MCP server. ```bash npx -y --package ragie -- mcp start --help ``` -------------------------------- ### Initializing ListEntitiesByDocumentResponse in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/operations/listentitiesbydocumentresponse.md This snippet demonstrates how to initialize an example `ListEntitiesByDocumentResponse` object in TypeScript. It illustrates the expected structure of the response, including pagination details and an array of entity objects, each with its unique ID, timestamps, and associated document/instruction IDs. This example requires importing the `ListEntitiesByDocumentResponse` type from `ragie/models/operations`. ```typescript import { ListEntitiesByDocumentResponse } from "ragie/models/operations"; let value: ListEntitiesByDocumentResponse = { result: { pagination: { totalCount: 940486, }, entities: [ { id: "312a36a6-c78d-4732-b38f-b3ebb49e8869", createdAt: new Date("2025-05-04T00:00:17.371Z"), updatedAt: new Date("2024-03-15T19:18:06.815Z"), instructionId: "434bac73-ded0-4eb1-ba6b-5afa62f2ff77", documentId: "369de787-229b-49cd-9262-10c37455135f", data: { "key": "" } } ] } }; ``` -------------------------------- ### Configuring Ragie MCP Server for Claude Source: https://github.com/ragieai/ragie-typescript/blob/main/README.md This JSON configuration defines a Ragie MCP server for Claude, specifying the command and arguments to start the server using npx and the ragie package, including an API authentication placeholder. ```json { "mcpServers": { "Ragie": { "command": "npx", "args": [ "-y", "--package", "ragie", "--", "mcp", "start", "--api-auth", "..." ] } } } ``` -------------------------------- ### Creating Document using Ragie SDK - TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/documents/README.md Demonstrates how to create a document using the main Ragie SDK client. It shows how to import the SDK, authenticate, and call the `documents.create` method with a file blob. The example includes handling the asynchronous result. ```typescript import { openAsBlob } from "node:fs"; import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "", }); async function run() { const result = await ragie.documents.create({ file: await openAsBlob("example.file"), }); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Configuring Ragie MCP Server for Cursor Source: https://github.com/ragieai/ragie-typescript/blob/main/README.md This JSON configuration defines a Ragie MCP server for Cursor, specifying the command and arguments to start the server using npx and the ragie package, including an API authentication placeholder. ```json { "mcpServers": { "Ragie": { "command": "npx", "args": [ "-y", "--package", "ragie", "--", "mcp", "start", "--api-auth", "..." ] } } } ``` -------------------------------- ### Initializing ConnectionStats in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/connectionstats.md This snippet demonstrates how to create an instance of the `ConnectionStats` object in TypeScript. It shows the required `documentCount` and `pageCount` properties, both of which are numbers, and assigns example values to them. ```TypeScript import { ConnectionStats } from "ragie/models/components"; let value: ConnectionStats = { documentCount: 658067, pageCount: 6297.95 }; ``` -------------------------------- ### Example Metadata Filter for Ragie.ai (JSON) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/instruction.md This JSON snippet demonstrates a metadata filter using the `$in` operator. It specifies that an instruction will only apply to documents where the 'toppings' metadata field contains either 'pizza' or 'mushrooms'. This filter is used during document update and creation operations in Ragie.ai. ```JSON { "toppings": { "$in": [ "pizza", "mushrooms" ] } } ``` -------------------------------- ### Getting Document Source using Standalone Function (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/documents/README.md This example illustrates how to use the `documentsGetSource` standalone function, which is ideal for tree-shaking performance. It utilizes `RagieCore` for authentication and demonstrates how to call the function with the core instance, document ID, and partition, including robust error handling. ```typescript import { RagieCore } from "ragie/core.js"; import { documentsGetSource } from "ragie/funcs/documentsGetSource.js"; // Use `RagieCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const ragie = new RagieCore({ auth: "", }); async function run() { const res = await documentsGetSource(ragie, { documentId: "00000000-0000-0000-0000-000000000000", partition: "acme_customer_id", }); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result); } run(); ``` -------------------------------- ### Initializing ConnectionBase in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/connectionbase.md This snippet demonstrates how to declare and initialize a variable of type `ConnectionBase`. It shows the basic structure for setting properties like `partitionStrategy` (an empty object in this example) and `pageLimit` (set to 1000). This object can then be used to configure data connections. ```typescript import { ConnectionBase } from "ragie/models/components"; let value: ConnectionBase = { partitionStrategy: {}, pageLimit: 1000, }; ``` -------------------------------- ### Configuring Multiple Document Partition Strategies Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/updatedocumentfileparams.md This example illustrates how to specify partition strategies for multiple document types simultaneously. It sets 'static' (textual) documents to 'hi_res' for detailed extraction, 'audio' files to be processed, and 'video' files to extract only the video component. ```JSON { "static": "hi_res", "audio": true, "video": "video_only" } ``` -------------------------------- ### Getting Connection Details using Standalone Function (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/connections/README.md This example illustrates using the tree-shakable 'RagieCore' and the 'connectionsGet' standalone function to fetch connection details. It includes robust error handling for the response and demonstrates how to extract the value from a successful result, emphasizing performance benefits. ```TypeScript import { RagieCore } from "ragie/core.js"; import { connectionsGet } from "ragie/funcs/connectionsGet.js"; // Use `RagieCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const ragie = new RagieCore({ auth: "" }); async function run() { const res = await connectionsGet(ragie, { connectionId: "af154d9d-a1af-4619-964d-b1589f2ec4f8" }); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result); } run(); ``` -------------------------------- ### Importing CreateDocumentParams (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/createdocumentparams.md This snippet demonstrates the standard way to import the `CreateDocumentParams` type from the `ragie/models/components` module in a TypeScript project. It also includes a comment indicating the current lack of specific usage examples for this model. ```typescript import { CreateDocumentParams } from "ragie/models/components"; // No examples available for this model ``` -------------------------------- ### Initializing PartitionDetail Object in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/partitiondetail.md This snippet demonstrates how to initialize an instance of the `PartitionDetail` model in TypeScript. It shows the required fields such as `name`, `isDefault`, `limitExceededAt`, `limits`, and `stats`, along with example values for each. The `PartitionDetail` type is imported from `ragie/models/components`. ```typescript import { PartitionDetail } from "ragie/models/components"; let value: PartitionDetail = { name: "", isDefault: false, limitExceededAt: new Date("2023-05-03T00:00:03.241Z"), limits: { pagesProcessedLimitMonthly: 8331.52, pagesHostedLimitMonthly: 9002.14, pagesProcessedLimitMax: 9246.23, pagesHostedLimitMax: 9599.05 }, stats: { pagesProcessedMonthly: 4315.89, pagesHostedMonthly: 5076.26, pagesProcessedTotal: 9301.51, pagesHostedTotal: 6751.33, documentCount: 624393 } }; ``` -------------------------------- ### Initializing ConnectorSourceTypeInfo in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/connectorsourcetypeinfo.md This snippet demonstrates how to create and initialize an instance of `ConnectorSourceTypeInfo` in TypeScript. It shows the required fields (`sourceType`, `displayName`, `iconUrl`, `docsUrl`) and provides example string values for each, illustrating the basic structure for defining a connector source type. ```TypeScript import { ConnectorSourceTypeInfo } from "ragie/models/components"; let value: ConnectorSourceTypeInfo = { sourceType: "zendesk", displayName: "Isabel.Mills33", iconUrl: "https://gleaming-smoke.info/", docsUrl: "https://nervous-armchair.org" }; ``` -------------------------------- ### Initializing Partition Model in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/partition.md This snippet demonstrates how to initialize an instance of the `Partition` model in TypeScript. It imports the `Partition` type from `ragie/models/components` and assigns a sample object with required fields like `name`, `isDefault`, `limitExceededAt`, and `limits` to a variable named `value`. This example showcases the structure and expected data types for the `Partition` object. ```typescript import { Partition } from "ragie/models/components"; let value: Partition = { name: "", isDefault: false, limitExceededAt: new Date("2025-04-25T22:48:45.167Z"), limits: { pagesProcessedLimitMonthly: 5401.94, pagesHostedLimitMonthly: 5582.05, pagesProcessedLimitMax: 1088.01, pagesHostedLimitMax: 9255.76 } }; ``` -------------------------------- ### Initializing ListPartitionsPartitionsGetRequest in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/operations/listpartitionspartitionsgetrequest.md This snippet demonstrates how to import the `ListPartitionsPartitionsGetRequest` type from the `ragie/models/operations` module and initialize an empty instance of it. This serves as the basic setup for constructing a request to list partitions, which can then be populated with optional parameters like `cursor` or `pageSize`. ```TypeScript import { ListPartitionsPartitionsGetRequest } from "ragie/models/operations"; let value: ListPartitionsPartitionsGetRequest = {}; ``` -------------------------------- ### Specifying Multiple Document Partition Strategies (JSON) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/createdocumentparams.md This example demonstrates how to configure different partitioning strategies for multiple document types within a single JSON object. It sets 'hi_res' for textual ('static') documents, enables audio processing for audio files, and specifies 'video_only' extraction for video files. ```JSON { "static": "hi_res", "audio": true, "video": "video_only" } ``` -------------------------------- ### Creating Instruction with Standalone Function - TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/entities/README.md This snippet illustrates how to create a new instruction using the `entitiesCreateInstruction` standalone function, leveraging `RagieCore` for optimized tree-shaking. It performs the same instruction creation as the SDK instance example but shows an alternative import and usage pattern, including explicit error handling for the API response. ```TypeScript import { RagieCore } from "ragie/core.js"; import { entitiesCreateInstruction } from "ragie/funcs/entitiesCreateInstruction.js"; // Use `RagieCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const ragie = new RagieCore({ auth: "" }); async function run() { const res = await entitiesCreateInstruction(ragie, { name: "Find all pizzas", prompt: "Find all pizzas described in the text.", entitySchema: { "key": "", "key1": "" }, filter: { "toppings": { "$in": [ "pizza", "mushrooms" ] } }, partition: "" }); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result); } run(); ``` -------------------------------- ### Creating Document with Ragie SDK in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/USAGE.md This snippet demonstrates how to initialize the Ragie SDK with an authentication token and then upload a file to create a new document. It uses `node:fs.openAsBlob` to read the file as a Blob, which is then passed to the `ragie.documents.create` method. The result of the document creation is logged to the console. A bearer token is required for authentication. ```typescript import { openAsBlob } from "node:fs"; import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "", }); async function run() { const result = await ragie.documents.create({ file: await openAsBlob("example.file") }); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Listing Entities by Instruction using Standalone Function (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/entities/README.md This example shows how to list entities using the standalone `entitiesListByInstruction` function for improved tree-shaking. It initializes `RagieCore` once and passes it to the function along with the instruction ID and partition. The snippet also includes error handling and processes paginated results. Requires `ragie/core.js` and `ragie/funcs/entitiesListByInstruction.js`. ```TypeScript import { RagieCore } from "ragie/core.js"; import { entitiesListByInstruction } from "ragie/funcs/entitiesListByInstruction.js"; // Use `RagieCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const ragie = new RagieCore({ auth: "" }); async function run() { const res = await entitiesListByInstruction(ragie, { instructionId: "00000000-0000-0000-0000-000000000000", partition: "acme_customer_id" }); if (!res.ok) { throw res.error; } const { value: result } = res; for await (const page of result) { // Handle the page console.log(page); } } run(); ``` -------------------------------- ### Retrieving Document using Ragie Class in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/documents/README.md This snippet demonstrates how to initialize the Ragie client and fetch a specific document by its ID and partition using the main `Ragie` class. It shows the basic setup and an asynchronous call to the `documents.get` method, logging the result. ```typescript import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "", }); async function run() { const result = await ragie.documents.get({ documentId: "00000000-0000-0000-0000-000000000000", partition: "acme_customer_id", }); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Syncing Connections with Ragie SDK in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/connections/README.md This snippet demonstrates how to initialize the Ragie SDK with an authentication token and then use the 'connections.sync' method to synchronize a specific connection by its ID. It shows the basic setup and execution flow for interacting with the Ragie API. ```TypeScript import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "" }); async function run() { const result = await ragie.connections.sync({ connectionId: "cf2b9381-3cee-4449-b7d1-9eb470186924" }); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Assigning a Value to PartitionStrategy1 in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/partitionstrategy1.md This snippet demonstrates how to import and assign a string literal value to the `PartitionStrategy1` type. It shows a basic usage example for initializing a variable with one of the allowed strategy values, specifically 'fast'. ```TypeScript import { PartitionStrategy1 } from "ragie/models/components"; let value: PartitionStrategy1 = "fast"; ``` -------------------------------- ### Initializing DocumentList in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/documentlist.md This snippet demonstrates how to initialize an instance of the `DocumentList` type in TypeScript. It shows the expected structure, including `pagination` details and an array of `documents`, each with various properties like `id`, `name`, `createdAt`, `updatedAt`, `status`, `metadata`, and `partition`. This example provides a concrete representation of the `DocumentList` data model. ```TypeScript import { DocumentList } from "ragie/models/components"; let value: DocumentList = { pagination: { totalCount: 878808, }, documents: [ { status: "", id: "c9fa669e-2e04-4b1b-aee1-aae2e77822dd", createdAt: new Date("2023-01-16T04:16:13.143Z"), updatedAt: new Date("2024-12-22T21:06:26.072Z"), name: "", metadata: { "key": "" }, partition: "" } ] }; ``` -------------------------------- ### Listing Connection Source Types using Standalone Function (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/connections/README.md This example shows how to use the `RagieCore` for optimized tree-shaking and directly call the `connectionsListConnectionSourceTypes` standalone function. It handles potential errors and logs the successful result, demonstrating a more modular approach. ```typescript import { RagieCore } from "ragie/core.js"; import { connectionsListConnectionSourceTypes } from "ragie/funcs/connectionsListConnectionSourceTypes.js"; // Use `RagieCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const ragie = new RagieCore({ auth: "", }); async function run() { const res = await connectionsListConnectionSourceTypes(ragie); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result); } run(); ``` -------------------------------- ### Listing Connections with Standalone Function - TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/connections/README.md This example shows how to list connections using the standalone `connectionsList` function from `ragie/funcs/connectionsList.js` for better tree-shaking. It uses `RagieCore` for initialization and handles potential errors from the API response, then processes paginated results. ```typescript import { RagieCore } from "ragie/core.js"; import { connectionsList } from "ragie/funcs/connectionsList.js"; // Use `RagieCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const ragie = new RagieCore({ auth: "", }); async function run() { const res = await connectionsList(ragie, { filter: "{\"department\":{\"$in\":[\"sales\",\"marketing\"]}}", }); if (!res.ok) { throw res.error; } const { value: result } = res; for await (const page of result) { // Handle the page console.log(page); } } run(); ``` -------------------------------- ### Setting Partition Limits using Standalone Function (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/partitions/README.md This snippet illustrates how to set partition limits using the standalone `partitionsSetLimits` function, which is recommended with `RagieCore` for optimal tree-shaking. It initializes `RagieCore` with an authentication token and then calls the function, passing the `RagieCore` instance and the limit parameters. The example also includes robust error handling, throwing an error if the operation is not successful, and then logging the successful result. ```typescript import { RagieCore } from "ragie/core.js"; import { partitionsSetLimits } from "ragie/funcs/partitionsSetLimits.js"; // Use `RagieCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const ragie = new RagieCore({ auth: "" }); async function run() { const res = await partitionsSetLimits(ragie, { partitionId: "", partitionLimitParams: { pagesHostedLimitMonthly: 1000, pagesProcessedLimitMonthly: 1000, pagesHostedLimitMax: 1000, pagesProcessedLimitMax: 1000 } }); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result); } run(); ``` -------------------------------- ### Initializing a Document Object in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/document.md This snippet demonstrates how to declare and initialize a `Document` object from the `ragie/models/components` module. It showcases the typical structure of a Document, including properties like status, ID, timestamps, name, metadata, and partition, with example values for each. ```typescript import { Document } from "ragie/models/components"; let value: Document = { status: "", id: "67b05821-2979-45f8-b725-57191c31b4f1", createdAt: new Date("2025-03-15T09:54:05.217Z"), updatedAt: new Date("2024-12-15T02:09:05.252Z"), name: "", metadata: { "key": 826206, }, partition: "", }; ``` -------------------------------- ### Initializing DocumentGet Object in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/documentget.md This snippet demonstrates how to initialize an instance of the `DocumentGet` type, imported from `ragie/models/components`. It shows the structure of the `DocumentGet` object, including properties like `status`, `id`, `createdAt`, `updatedAt`, `name`, `metadata`, `partition`, and `errors`, with example values for each. ```typescript import { DocumentGet } from "ragie/models/components"; let value: DocumentGet = { status: "", id: "df1734b7-d561-4df2-b528-ed030bd85127", createdAt: new Date("2023-10-09T13:06:45.255Z"), updatedAt: new Date("2023-09-27T05:53:58.801Z"), name: "", metadata: { "key": "" }, partition: "", errors: [ "" ] }; ``` -------------------------------- ### Setting Connection Limits with Ragie SDK (Class-based) - TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/connections/README.md This example demonstrates how to set a page limit for a specific connection using the Ragie class. It initializes the SDK with an authentication token and then calls the connections.setLimits method, specifying the connectionId and the pageLimit. ```typescript import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "", }); async function run() { const result = await ragie.connections.setLimits({ connectionId: "ab1a17e7-8b6f-470a-aeda-1c8e11512d19", connectionLimitParams: { pageLimit: 1000, }, }); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Ingesting Raw Text with Ragie Client (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/documents/README.md This snippet demonstrates how to ingest a document as raw text using the `createRaw` method of the `Ragie` client. It shows the basic setup, authentication, and calling the asynchronous `createRaw` function with `partition` and `data` parameters, then logging the result. ```typescript import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "" }); async function run() { const result = await ragie.documents.createRaw({ partition: "", data: "" }); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Importing FileT Model - TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/filet.md This snippet demonstrates how to import the `FileT` model from the `ragie/models/components` module in TypeScript. It shows the basic syntax for making the `FileT` type available for use in other parts of the application, noting that no specific usage examples are provided for this model. ```typescript import { FileT } from "ragie/models/components"; // No examples available for this model ``` -------------------------------- ### Example Usage - ListDocumentsResponse - TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/operations/listdocumentsresponse.md This snippet demonstrates how to create and populate an instance of the `ListDocumentsResponse` object in TypeScript. It illustrates the expected data structure, including pagination details and an array of document objects, showcasing typical values for various fields like ID, creation/update timestamps, and metadata. ```typescript import { ListDocumentsResponse } from "ragie/models/operations"; let value: ListDocumentsResponse = { result: { pagination: { totalCount: 18197, }, documents: [ { status: "", id: "08ad32d2-d65d-47f3-bdf4-475a654a2355", createdAt: new Date("2024-06-20T22:49:52.888Z"), updatedAt: new Date("2025-05-02T15:35:12.818Z"), name: "", metadata: { "key": 704761, }, partition: "", }, ], }, }; ``` -------------------------------- ### Authenticating Ragie TypeScript SDK with Bearer Token Source: https://github.com/ragieai/ragie-typescript/blob/main/README.md This example illustrates how to authenticate the Ragie TypeScript SDK client using an HTTP Bearer token. The `auth` parameter must be set during SDK initialization, enabling secure API calls, such as creating a document from a file. ```TypeScript import { openAsBlob } from "node:fs"; import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "", }); async function run() { const result = await ragie.documents.create({ file: await openAsBlob("example.file"), }); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Getting Document Summary with Standalone Ragie Function (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/documents/README.md This example illustrates using the `documentsGetSummary` standalone function with `RagieCore` for improved tree-shaking. It also requires `documentId` and `partition` and includes error handling for the API response. This method is suitable for applications where bundle size optimization is critical. ```typescript import { RagieCore } from "ragie/core.js"; import { documentsGetSummary } from "ragie/funcs/documentsGetSummary.js"; // Use `RagieCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const ragie = new RagieCore({ auth: "" }); async function run() { const res = await documentsGetSummary(ragie, { documentId: "00000000-0000-0000-0000-000000000000", partition: "acme_customer_id" }); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result); } run(); ``` -------------------------------- ### Listing Instructions using Ragie SDK (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/entities/README.md This snippet demonstrates how to list all instructions using the main Ragie SDK. It initializes the SDK with an authentication token and then calls the `entities.listInstructions()` method. The result is logged to the console, providing a straightforward way to interact with the API. ```typescript import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "", }); async function run() { const result = await ragie.entities.listInstructions(); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Importing and Assigning OAuthUrlCreateMode1 in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/oauthurlcreatemode1.md This snippet demonstrates how to import the `OAuthUrlCreateMode1` type from the `ragie/models/components` module and assign one of its valid string literal values ('fast') to a variable. It shows a basic usage example for initializing a variable with this specific OAuth URL creation mode. ```typescript import { OAuthUrlCreateMode1 } from "ragie/models/components"; let value: OAuthUrlCreateMode1 = "fast"; ``` -------------------------------- ### Getting Connection Statistics with Ragie SDK (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/connections/README.md This snippet demonstrates how to initialize the Ragie client with an authentication token and then use its `connections.getStats` method to fetch statistics for a specific connection ID. It showcases the typical usage pattern for the full Ragie SDK, providing a straightforward way to interact with the API. ```typescript import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "" }); async function run() { const result = await ragie.connections.getStats({ connectionId: "1568dd0e-2d57-45b1-a9f4-9d646aec54a2" }); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Retrieving Partition with Standalone Function (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/partitions/README.md This example illustrates using `RagieCore` and the `partitionsGet` standalone function for improved tree-shaking. It shows how to handle the `Result` type returned by standalone functions, checking for success (`res.ok`) or throwing an error if the operation failed. ```TypeScript import { RagieCore } from "ragie/core.js"; import { partitionsGet } from "ragie/funcs/partitionsGet.js"; // Use `RagieCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const ragie = new RagieCore({ auth: "", }); async function run() { const res = await partitionsGet(ragie, { partitionId: "", }); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result); } run(); ``` -------------------------------- ### Retrieving Document using Standalone Function with RagieCore in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/documents/README.md This example illustrates fetching a document using the standalone `documentsGet` function, which is optimized for tree-shaking. It utilizes `RagieCore` for initialization, emphasizing its benefit for performance, and includes robust error handling for the API response. ```typescript import { RagieCore } from "ragie/core.js"; import { documentsGet } from "ragie/funcs/documentsGet.js"; // Use `RagieCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const ragie = new RagieCore({ auth: "", }); async function run() { const res = await documentsGet(ragie, { documentId: "00000000-0000-0000-0000-000000000000", partition: "acme_customer_id", }); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result); } run(); ``` -------------------------------- ### Getting Document Source using Ragie SDK (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/documents/README.md This snippet demonstrates how to use the `getSource` method through the main `Ragie` SDK instance. It shows the necessary import, instantiation with an authentication token, and an asynchronous call to retrieve the document's source file using its ID and partition. ```typescript import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "", }); async function run() { const result = await ragie.documents.getSource({ documentId: "00000000-0000-0000-0000-000000000000", partition: "acme_customer_id", }); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Listing Partitions with Ragie SDK - TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/partitions/README.md This snippet demonstrates how to list all partitions using the main Ragie SDK. It initializes the SDK with an authentication token and then iterates through paginated results, logging each page of partitions. ```typescript import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "", }); async function run() { const result = await ragie.partitions.list({}); for await (const page of result) { // Handle the page console.log(page); } } run(); ``` -------------------------------- ### Initializing DocumentWithContent Model in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/documentwithcontent.md This snippet demonstrates how to declare and initialize a `DocumentWithContent` object. It shows the structure of the model, including required fields like `status`, `id`, `createdAt`, `updatedAt`, `name`, `metadata`, `partition`, and `content`, with example values assigned to each property. ```typescript import { DocumentWithContent } from "ragie/models/components"; let value: DocumentWithContent = { status: "", id: "1feff81a-a4f8-475a-95bc-8ac79e88fa71", createdAt: new Date("2024-04-08T17:54:19.683Z"), updatedAt: new Date("2023-08-05T03:50:53.816Z"), name: "", metadata: { "key": 839455, }, partition: "", content: "", }; ``` -------------------------------- ### Configuring Global Retries for Ragie TypeScript SDK Source: https://github.com/ragieai/ragie-typescript/blob/main/README.md This example shows how to set a default retry strategy for all supported operations across the entire Ragie TypeScript SDK. The `retryConfig` is provided during SDK initialization, ensuring consistent retry behavior for all subsequent API calls. ```TypeScript import { openAsBlob } from "node:fs"; import { Ragie } from "ragie"; const ragie = new Ragie({ retryConfig: { strategy: "backoff", backoff: { initialInterval: 1, maxInterval: 50, exponent: 1.1, maxElapsedTime: 100, }, retryConnectionErrors: false, }, auth: "", }); async function run() { const result = await ragie.documents.create({ file: await openAsBlob("example.file"), }); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Listing Entities by Instruction using Ragie Class (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/entities/README.md This snippet demonstrates how to list entities associated with a specific instruction ID and partition using the main `Ragie` class. It initializes the SDK with an authentication token and iterates through paginated results to process each page of entities. Requires the `ragie` package. ```TypeScript import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "" }); async function run() { const result = await ragie.entities.listByInstruction({ instructionId: "00000000-0000-0000-0000-000000000000", partition: "acme_customer_id" }); for await (const page of result) { // Handle the page console.log(page); } } run(); ``` -------------------------------- ### Initializing Instruction Model in TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/models/components/instruction.md This snippet demonstrates how to declare and initialize an `Instruction` object from the `ragie/models/components` module in TypeScript. It shows the structure of an `Instruction` object, including its unique identifier, creation and update timestamps, a descriptive name, the prompt text, an optional entity schema, and a filter object for data selection. This initialization is crucial for defining specific instructions for data processing or retrieval. ```typescript import { Instruction } from "ragie/models/components"; let value: Instruction = { id: "89994601-8cf9-4731-a349-de541af8dda2", createdAt: new Date("2024-06-29T04:14:18.600Z"), updatedAt: new Date("2023-10-20T20:22:48.983Z"), name: "Find all pizzas", prompt: "Find all pizzas described in the text.", entitySchema: { "key": "" }, filter: { "toppings": { "$in": [ "pizza", "mushrooms" ] } }, partition: null }; ``` -------------------------------- ### Creating Documents with Standalone Function (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/FUNCTIONS.md This example demonstrates how to use the `documentsCreate` standalone function with `RagieCore` to upload a file. It showcases the `Result` type pattern for error handling, specifically checking for `res.ok` for success and `SDKValidationError` or generic `Error` for different error scenarios, ensuring exhaustive error checks. ```typescript import { openAsBlob } from "node:fs"; import { RagieCore } from "ragie/core.js"; import { documentsCreate } from "ragie/funcs/documentsCreate.js"; import { SDKValidationError } from "ragie/models/errors/sdkvalidationerror.js"; // Use `RagieCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const ragie = new RagieCore({ auth: "", }); async function run() { const res = await documentsCreate(ragie, { file: await openAsBlob("example.file"), }); switch (true) { case res.ok: // The success case will be handled outside of the switch block break; case res.error instanceof SDKValidationError: // Pretty-print validation errors. return console.log(res.error.pretty()); case res.error instanceof Error: return console.log(res.error); default: // TypeScript's type checking will fail on the following line if the above // cases were not exhaustive. res.error satisfies never; throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error); } const { value: result } = res; // Handle the result console.log(result); } run(); ``` -------------------------------- ### Setting Connection Limits with Ragie SDK (Standalone Function) - TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/connections/README.md This example shows how to set a page limit using the standalone connectionsSetLimits function, which is recommended for tree-shaking performance. It initializes RagieCore and passes the instance along with connection parameters to the function, handling potential errors. ```typescript import { RagieCore } from "ragie/core.js"; import { connectionsSetLimits } from "ragie/funcs/connectionsSetLimits.js"; // Use `RagieCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const ragie = new RagieCore({ auth: "", }); async function run() { const res = await connectionsSetLimits(ragie, { connectionId: "ab1a17e7-8b6f-470a-aeda-1c8e11512d19", connectionLimitParams: { pageLimit: 1000, }, }); if (!res.ok) { throw res.error; } const { value: result } = res; // Handle the result console.log(result); } run(); ``` -------------------------------- ### Creating a Partition with Ragie SDK Client - TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/partitions/README.md This snippet demonstrates how to create a new partition using the main `Ragie` client. It initializes the client with an authentication token and then calls the `partitions.create` method, specifying the partition name and optional monthly and maximum page limits. The result of the operation is logged to the console. ```typescript import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "" }); async function run() { const result = await ragie.partitions.create({ name: "", pagesHostedLimitMonthly: 1000, pagesProcessedLimitMonthly: 1000, pagesHostedLimitMax: 1000, pagesProcessedLimitMax: 1000 }); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Getting Connection Details using Ragie Client (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/connections/README.md This snippet demonstrates how to initialize the Ragie client with an authentication token and then use its 'connections.get' method to retrieve details for a specific connection ID. It shows the basic asynchronous call pattern and logging the result. ```TypeScript import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "" }); async function run() { const result = await ragie.connections.get({ connectionId: "af154d9d-a1af-4619-964d-b1589f2ec4f8" }); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Creating Instruction with Ragie SDK Instance - TypeScript Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/entities/README.md This snippet demonstrates how to create a new instruction using the `createInstruction` method of the `Ragie` SDK instance. It defines an instruction to find pizzas, specifying a natural language prompt, an entity schema for structured data extraction, and a filter for document properties. The result of the instruction creation is logged to the console. ```TypeScript import { Ragie } from "ragie"; const ragie = new Ragie({ auth: "", }); async function run() { const result = await ragie.entities.createInstruction({ name: "Find all pizzas", prompt: "Find all pizzas described in the text.", entitySchema: { "key": "", "key1": "" }, filter: { "toppings": { "$in": [ "pizza", "mushrooms" ] } }, partition: "" }); // Handle the result console.log(result); } run(); ``` -------------------------------- ### Creating OAuth Redirect URL using Standalone Function (TypeScript) Source: https://github.com/ragieai/ragie-typescript/blob/main/docs/sdks/connections/README.md This example illustrates using the standalone `connectionsCreateOAuthRedirectUrl` function with `RagieCore` for optimized tree-shaking. It initializes `RagieCore` with an authentication token and then calls the function, passing the core instance and configuration parameters. It also includes error handling for the response. ```typescript import { RagieCore } from "ragie/core.js"; import { connectionsCreateOAuthRedirectUrl } from "ragie/funcs/connectionsCreateOAuthRedirectUrl.js"; // Use `RagieCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const ragie = new RagieCore({ auth: "", }); async function run() { const res = await connectionsCreateOAuthRedirectUrl(ragie, { redirectUri: "https://babyish-rationale.biz/", pageLimit: 1000, }); if (!res.ok) { throw res.error; n} const { value: result } = res; // Handle the result console.log(result); } run(); ```