(files.extractStructuredData)
Extract structured data from files
- sync - Extract Structured Data - Sync
- start - Extract Structured Data - Async Start
- result - Extract Structured Data - Async Result
Extracts structured data from a file. Supported file types are image, pdf (more coming soon!). It accepts the file and requested schema for the data to be extracted.
import { IntunedClient } from "@intuned/client";
const intunedClient = new IntunedClient({
apiKey: "<YOUR_API_KEY_HERE>",
workspaceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
});
async function run() {
const result = await intunedClient.files.extractStructuredData.sync({
type: "pdf",
source: {
type: "url",
data: "http://unconscious-margin.name",
},
}, {
"key": "<value>",
});
// Handle the result
console.log(result)
}
run();
The standalone function version of this method:
import { IntunedClientCore } from "@intuned/client/core.js";
import { filesExtractStructuredDataSync } from "@intuned/client/funcs/filesExtractStructuredDataSync.js";
// Use `IntunedClientCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const intunedClient = new IntunedClientCore({
apiKey: "<YOUR_API_KEY_HERE>",
workspaceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
});
async function run() {
const res = await filesExtractStructuredDataSync(intunedClient, {
type: "image",
source: {
type: "base64",
data: "<value>",
},
}, {
"key": "<value>",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
file |
components.FileT | ✔️ | N/A |
dataSchema |
Record<string, any> | ✔️ | The schema (in JSONSchema) to which the extracted data should conform to. More about JSONSchema JSONSchema |
strategy |
components.ExtractStructuredDataStrategy | ➖ | The strategy to extract structured data from a file. Includes the model and type of extraction. |
prompt |
string | ➖ | Prompt given to the AI model to help with extraction. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.StructuredDataExtractionSyncResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.ApiErrorInvalidInput | 400 | application/json |
errors.ApiErrorUnauthorized | 401 | application/json |
errors.SDKError | 4xx-5xx | / |
Starts an asynchronous operation to extract structured data from a file. Supported file types are image, pdf (more coming soon!). It accepts the file and requested schema for the data to be extracted. It responds with an ID to track the operation status and retrieve the result.
import { IntunedClient } from "@intuned/client";
const intunedClient = new IntunedClient({
apiKey: "<YOUR_API_KEY_HERE>",
workspaceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
});
async function run() {
const result = await intunedClient.files.extractStructuredData.start({
type: "image",
source: {
type: "base64",
data: "<value>",
},
}, {
"key": "<value>",
});
// Handle the result
console.log(result)
}
run();
The standalone function version of this method:
import { IntunedClientCore } from "@intuned/client/core.js";
import { filesExtractStructuredDataStart } from "@intuned/client/funcs/filesExtractStructuredDataStart.js";
// Use `IntunedClientCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const intunedClient = new IntunedClientCore({
apiKey: "<YOUR_API_KEY_HERE>",
workspaceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
});
async function run() {
const res = await filesExtractStructuredDataStart(intunedClient, {
type: "pdf",
source: {
type: "base64",
data: "<value>",
},
}, {
"key": "<value>",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
file |
components.FileT | ✔️ | N/A |
dataSchema |
Record<string, any> | ✔️ | The schema (in JSONSchema) to which the extracted data should conform to. More about JSONSchema JSONSchema |
strategy |
components.ExtractStructuredDataStrategy | ➖ | The strategy to extract structured data from a file. Includes the model and type of extraction. |
prompt |
string | ➖ | Prompt given to the AI model to help with extraction. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.AsyncFilePendingResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.ApiErrorInvalidInput | 400 | application/json |
errors.ApiErrorUnauthorized | 401 | application/json |
errors.SDKError | 4xx-5xx | / |
Gets the result of the structured data extraction operation using the operation ID.
import { IntunedClient } from "@intuned/client";
const intunedClient = new IntunedClient({
apiKey: "<YOUR_API_KEY_HERE>",
workspaceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
});
async function run() {
const result = await intunedClient.files.extractStructuredData.result("aaaabbbCCCCdddd");
// Handle the result
console.log(result)
}
run();
The standalone function version of this method:
import { IntunedClientCore } from "@intuned/client/core.js";
import { filesExtractStructuredDataResult } from "@intuned/client/funcs/filesExtractStructuredDataResult.js";
// Use `IntunedClientCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const intunedClient = new IntunedClientCore({
apiKey: "<YOUR_API_KEY_HERE>",
workspaceId: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
});
async function run() {
const res = await filesExtractStructuredDataResult(intunedClient, "aaaabbbCCCCdddd");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
operationId |
string | ✔️ | The ID for the requested file operation. This is obtained from the start request. | [object Object] |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. | |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
|
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.StructuredDataExtractionAsyncResponse>
Error Object | Status Code | Content Type |
---|---|---|
errors.ApiErrorInvalidInput | 400 | application/json |
errors.ApiErrorUnauthorized | 401 | application/json |
errors.SDKError | 4xx-5xx | / |