Skip to content

Responses

(llm.responses)

Overview

Available Operations

createResponse

Create a new AI agent response using advanced language models with autonomous tool usage capabilities. The agent can access various tools including web search, file search, image generation, code interpreter, computer use simulation, and Model Context Protocol (MCP) integrations. Specify the model, input messages or prompts, select which tools to enable, configure modalities (text and audio), set output formats (text or JSON), choose between foreground or background processing, and enable streaming for real-time responses. Background responses run asynchronously and can be retrieved later by ID. The agent autonomously decides when and how to use tools to fulfill requests. Returns a response object containing the agent's output, tool usage logs, metadata, and processing status. Useful for building conversational AI assistants, automated workflows, research agents, and complex multi-step task automation.

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.responses.createResponse({
    model: "Taurus",
  });

  for await (const event of result) {
    console.log(event);
  }
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmResponsesCreateResponse } from "@meetkai/mka1/funcs/llmResponsesCreateResponse.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 llmResponsesCreateResponse(sdk, {
    model: "Taurus",
  });
  if (res.ok) {
    const { value: result } = res;
    for await (const event of result) {
    console.log(event);
  }
  } else {
    console.log("llmResponsesCreateResponse 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.
  useLlmResponsesCreateResponseMutation
} from "@meetkai/mka1/react-query/llmResponsesCreateResponse.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.CreateResponseRequestBody✔️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<EventStream<operations.CreateResponseResponseBody>>

Errors

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

getResponse

Retrieve a previously created agent response using its unique ID. Returns complete details including the response status (in_progress, completed, failed, cancelled), the model used, all input messages or prompts, the agent's output (text, JSON, or audio), complete tool usage logs showing which tools were called and their results, metadata such as creation and completion timestamps, token usage statistics, and any error information if the response failed. Essential for retrieving background responses after asynchronous processing completes. Use the optional stream parameter to enable streaming support for real-time updates (currently returns full response). Returns 404 if the response ID doesn't exist. Useful for building status dashboards, retrieving async job results, debugging agent behavior, and auditing tool usage.

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.responses.getResponse({
    responseId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmResponsesGetResponse } from "@meetkai/mka1/funcs/llmResponsesGetResponse.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 llmResponsesGetResponse(sdk, {
    responseId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmResponsesGetResponse 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.
  useLlmResponsesGetResponse,
  useLlmResponsesGetResponseSuspense,

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

Parameters

ParameterTypeRequiredDescription
requestoperations.GetResponseRequest✔️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<operations.GetResponseResponseBody>

Errors

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

deleteResponse

Permanently delete an agent response and all associated data including input messages, output content, tool usage logs, and metadata. This operation cannot be undone - once deleted, the response cannot be retrieved again. Use this to clean up completed responses, remove sensitive data, manage storage quotas, or comply with data retention policies. Returns a deletion confirmation object with the response ID and deleted status. Returns 404 if the response ID doesn't exist or has already been deleted. Note that deleting a response does not cancel it if it's currently in progress - use the cancel endpoint first if you need to stop processing before deletion.

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.responses.deleteResponse({
    responseId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmResponsesDeleteResponse } from "@meetkai/mka1/funcs/llmResponsesDeleteResponse.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 llmResponsesDeleteResponse(sdk, {
    responseId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmResponsesDeleteResponse 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.
  useLlmResponsesDeleteResponseMutation
} from "@meetkai/mka1/react-query/llmResponsesDeleteResponse.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.DeleteResponseRequest✔️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<operations.DeleteResponseResponseBody>

Errors

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

cancelResponse

Cancel an agent response that is currently processing in the background. Immediately stops any ongoing LLM generation, tool execution, or workflow processing. The response status is updated to 'cancelled' and any partial results are preserved. Useful for stopping long-running agent tasks, managing resource usage, implementing user-initiated cancellations, or enforcing timeout policies. Returns the updated response object with cancelled status. Returns 404 if the response ID doesn't exist. Returns 409 conflict if the response has already completed, failed, or been cancelled - only in-progress responses can be cancelled. Note that cancellation may not be instantaneous if the agent is in the middle of a tool execution. The Temporal workflow (if enabled) is also cancelled to free up background processing resources.

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.responses.cancelResponse({
    responseId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmResponsesCancelResponse } from "@meetkai/mka1/funcs/llmResponsesCancelResponse.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 llmResponsesCancelResponse(sdk, {
    responseId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmResponsesCancelResponse 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.
  useLlmResponsesCancelResponseMutation
} from "@meetkai/mka1/react-query/llmResponsesCancelResponse.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.CancelResponseRequest✔️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<operations.CancelResponseResponseBody>

Errors

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

listInputItems

Retrieve a paginated list of all input items (messages, prompts, instructions) that were provided when creating the specified agent response. Each item includes its type (message, system instruction, user prompt), content (text, images, audio, files), timestamps, and ordering information. Supports cursor-based pagination using the 'after' parameter to fetch subsequent pages and 'limit' parameter to control page size (default 20, max 100). Returns a list object containing the input items array, pagination cursors (first_id, last_id, has_more), and total count. Useful for reviewing conversation history, auditing input data, debugging agent behavior, or reconstructing the full context provided to the agent. Returns 404 if the response ID doesn't exist.

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.responses.listInputItems({
    responseId: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmResponsesListInputItems } from "@meetkai/mka1/funcs/llmResponsesListInputItems.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 llmResponsesListInputItems(sdk, {
    responseId: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmResponsesListInputItems 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.
  useLlmResponsesListInputItems,
  useLlmResponsesListInputItemsSuspense,

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

Parameters

ParameterTypeRequiredDescription
requestoperations.ListInputItemsRequest✔️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<operations.ListInputItemsResponseBody>

Errors

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