import { UnstructuredClient } from "unstructured-client";
import { PartitionResponse } from "unstructured-client/dist/sdk/models/operations";
import * as fs from "fs";
const key = "YOUR_API_KEY";
const client = new UnstructuredClient({
// you may need to provide your unique API URL
// serverURL: "YOUR_API_URL",
security: {
apiKeyAuth: key,
},
});
const filename = "sample-docs/layout-parser-paper.pdf";
const data = fs.readFileSync(filename);
client.general.partition({
// Note that this currently only supports a single file
files: {
content: data,
fileName: filename,
},
// Other partition params
strategy: "fast",
}).then((res: PartitionResponse) => {
if (res.statusCode == 200) {
console.log(res.elements);
}
}).catch((e) => {
console.log(e.statusCode);
console.log(e.body);
});