Skip to content

Llm.Batches

Overview

Available Operations

create

Creates and executes a batch from an uploaded JSONL file of requests. Each line must have custom_id, method, url, and body fields.

Example Usage

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

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.llm.batches.create({
    inputFileId: "file_abc123",
    endpoint: "/v1/chat/completions",
    completionWindow: "24h",
    metadata: {
      "description": "evaluation job",
    },
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

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

async function run() {
  const res = await llmBatchesCreate(sdk, {
    inputFileId: "file_abc123",
    endpoint: "/v1/chat/completions",
    completionWindow: "24h",
    metadata: {
      "description": "evaluation job",
    },
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmBatchesCreate 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.
  useLlmBatchesCreateMutation
} from "@meetkai/mka1/react-query/llmBatchesCreate.js";

Parameters

ParameterTypeRequiredDescription
requestcomponents.CreateBatchRequest✔️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.BatchObject>

Errors

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

list

Returns a paginated list of batches owned by the authenticated user.

Example Usage

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

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.llm.batches.list({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

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

async function run() {
  const res = await llmBatchesList(sdk, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmBatchesList 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.
  useLlmBatchesList,
  useLlmBatchesListSuspense,

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

Parameters

ParameterTypeRequiredDescription
requestoperations.ListBatchesRequest✔️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.ListBatchesResponse>

Errors

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

get

Retrieves a batch by its ID.

Example Usage

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

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.llm.batches.get({
    batchId: "batch_aa87e2b1112a455b8deabed784372198",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

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

async function run() {
  const res = await llmBatchesGet(sdk, {
    batchId: "batch_aa87e2b1112a455b8deabed784372198",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmBatchesGet 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.
  useLlmBatchesGet,
  useLlmBatchesGetSuspense,

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

Parameters

ParameterTypeRequiredDescription
requestoperations.GetBatchRequest✔️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.BatchObject>

Errors

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

cancel

Cancels an in-progress batch. The batch status changes to cancelling, and remaining requests will not be processed.

Example Usage

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

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.llm.batches.cancel({
    batchId: "batch_aa87e2b1112a455b8deabed784372198",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

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

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

async function run() {
  const res = await llmBatchesCancel(sdk, {
    batchId: "batch_aa87e2b1112a455b8deabed784372198",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmBatchesCancel 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.
  useLlmBatchesCancelMutation
} from "@meetkai/mka1/react-query/llmBatchesCancel.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.CancelBatchRequest✔️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.BatchObject>

Errors

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