Skip to content

Llm.Extract

Overview

Available Operations

createSchema

Create and store a reusable JSON Schema template for structured data extraction. Define the schema structure, add a descriptive name (1-100 chars), optional description (max 500 chars), and custom metadata for your extraction use case. Once created, the schema can be referenced by ID for consistent extraction across multiple files. Useful for building libraries of extraction templates for different document types (invoices, receipts, forms, contracts, etc.). The schema is validated before storage to ensure it's a valid JSON Schema structure.

Example Usage

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  serverURL: "https://api.example.com",
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.llm.extract.createSchema({
    name: "<value>",
    schema: {
      "key": "<value>",
      "key1": "<value>",
      "key2": "<value>",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmExtractCreateSchema } from "@meetkai/mka1/funcs/llmExtractCreateSchema.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  serverURL: "https://api.example.com",
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await llmExtractCreateSchema(sdk, {
    name: "<value>",
    schema: {
      "key": "<value>",
      "key1": "<value>",
      "key2": "<value>",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmExtractCreateSchema failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Mutation hook for triggering the API call.
  useLlmExtractCreateSchemaMutation
} from "@meetkai/mka1/react-query/llmExtractCreateSchema.js";

Parameters

ParameterTypeRequiredDescription
requestcomponents.ExtractionSchema✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<components.SchemaCreateResponse>

Errors

Error TypeStatus CodeContent Type
errors.APIError4XX, 5XX*/*

getSchema

Retrieve a stored extraction schema and its metadata.

Example Usage

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  serverURL: "https://api.example.com",
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.llm.extract.getSchema({
    schemaId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmExtractGetSchema } from "@meetkai/mka1/funcs/llmExtractGetSchema.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  serverURL: "https://api.example.com",
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await llmExtractGetSchema(sdk, {
    schemaId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmExtractGetSchema failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Query hooks for fetching data.
  useLlmExtractGetSchema,
  useLlmExtractGetSchemaSuspense,

  // Utility for prefetching data during server-side rendering and in React
  // Server Components that will be immediately available to client components
  // using the hooks.
  prefetchLlmExtractGetSchema,
  
  // Utilities to invalidate the query cache for this query in response to
  // mutations and other user actions.
  invalidateLlmExtractGetSchema,
  invalidateAllLlmExtractGetSchema,
} from "@meetkai/mka1/react-query/llmExtractGetSchema.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.GetExtractSchemaRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<components.SchemaGetResponse>

Errors

Error TypeStatus CodeContent Type
errors.APIError4XX, 5XX*/*

updateSchema

Update an existing extraction schema and its metadata.

Example Usage

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  serverURL: "https://api.example.com",
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.llm.extract.updateSchema({
    schemaId: "<id>",
    requestBody: {},
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmExtractUpdateSchema } from "@meetkai/mka1/funcs/llmExtractUpdateSchema.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  serverURL: "https://api.example.com",
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await llmExtractUpdateSchema(sdk, {
    schemaId: "<id>",
    requestBody: {},
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmExtractUpdateSchema failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Mutation hook for triggering the API call.
  useLlmExtractUpdateSchemaMutation
} from "@meetkai/mka1/react-query/llmExtractUpdateSchema.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.UpdateExtractSchemaRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<components.SchemaUpdateResponse>

Errors

Error TypeStatus CodeContent Type
errors.APIError4XX, 5XX*/*

deleteSchema

Remove a stored extraction schema.

Example Usage

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  serverURL: "https://api.example.com",
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.llm.extract.deleteSchema({
    schemaId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmExtractDeleteSchema } from "@meetkai/mka1/funcs/llmExtractDeleteSchema.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  serverURL: "https://api.example.com",
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await llmExtractDeleteSchema(sdk, {
    schemaId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmExtractDeleteSchema failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Mutation hook for triggering the API call.
  useLlmExtractDeleteSchemaMutation
} from "@meetkai/mka1/react-query/llmExtractDeleteSchema.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.DeleteExtractSchemaRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions 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.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<components.SchemaDeleteResponse>

Errors

Error TypeStatus CodeContent Type
errors.APIError4XX, 5XX*/*