Skip to main content
The FlexOrch TypeScript SDK gives you a fully typed, Promise-based interface to upload documents, monitor processing jobs, and export LLM-ready datasets from any Node.js or TypeScript project. This guide walks you through installation and your first end-to-end document run.

Prerequisites

  • Node.js 18 or later (the SDK uses native fetch and Buffer)
  • A FlexOrch API key (format: dfx_<random_string>) — find yours in the FlexOrch dashboard

Installation

1
Install the package
2
npm install @flexorch/sdk
3
Store your API key
4
Never hardcode credentials in source code. Add your key to your environment instead:
5
export FLEXORCH_API_KEY="dfx_your_key_here"
6
Or add it to a .env file (and add .env to .gitignore):
7
FLEXORCH_API_KEY=dfx_your_key_here
8
Initialize the client
9
import { FlexOrch } from "@flexorch/sdk";

const client = new FlexOrch({
  apiKey: process.env.FLEXORCH_API_KEY,
});
10
If FLEXORCH_API_KEY is set in your environment, the SDK picks it up automatically — you can omit apiKey from the constructor.
11
Upload your first document
12
Pass a local file path to client.documents.upload(). The method returns a Promise<Job> that resolves as soon as the document is queued.
13
const job = await client.documents.upload("invoice.pdf");
console.log(`Job created: ${job.id} | Status: ${job.status}`);
14
Wait for processing to complete
15
Call job.waitUntilDone() to await the job’s terminal state (completed or failed). The SDK handles polling and exponential back-off automatically.
16
const finishedJob = await job.waitUntilDone();
17
Inspect the results
18
console.log(`Quality grade:  ${finishedJob.qualityGrade}`);      // "A" | "B" | "C" | "D"
console.log(`Quality score:  ${finishedJob.qualityScore}`);       // 0.0 – 1.0
console.log(`PII findings:   ${finishedJob.piiFindingsCount}`);
console.log(`Summary:        ${finishedJob.processingSummary}`);

Full working example

import { FlexOrch } from "@flexorch/sdk";

async function main() {
  const client = new FlexOrch({
    apiKey: process.env.FLEXORCH_API_KEY,
  });

  // Upload a document
  let job = await client.documents.upload("invoice.pdf");
  console.log(`Uploaded — job ID: ${job.id}`);

  // Wait for the pipeline to finish
  job = await job.waitUntilDone();

  if (job.status === "completed") {
    console.log(`Grade:        ${job.qualityGrade}`);
    console.log(`Score:        ${job.qualityScore}`);
    console.log(`PII findings: ${job.piiFindingsCount}`);
    console.log(`Summary:      ${job.processingSummary}`);
  } else {
    console.error(`Job failed: ${job.processingSummary}`);
  }
}

main();
Processing time depends on file size and plan tier. Most documents under 10 MB complete within 30 seconds on the Growth plan.

Next steps

Upload Documents

Learn single-file, batch, and connector-based upload patterns.

Manage Jobs

Poll job status, filter by quality grade, and submit feedback.

Build Datasets

Combine completed jobs into exportable, LLM-ready datasets.

API Reference

Full class and method reference for the TypeScript SDK.