Llm.Prompts
Overview
Available Operations
- create - Create a prompt
- list - List prompts
- get - Get a prompt
- update - Update a prompt
- delete - Delete a prompt
- createVersion - Create a new version
- listVersions - List versions
- getVersion - Get a specific version
- rollback - Rollback to a version
create
Creates a new prompt with its first version. The template supports placeholders.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.prompts.create({
name: "Customer Support Classifier",
description: "Classifies incoming customer messages by intent",
template: "Classify the following customer message into one of these categories: {{categories}}\n\nMessage: {{message}}",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmPromptsCreate } from "@meetkai/mka1/funcs/llmPromptsCreate.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 llmPromptsCreate(sdk, {
name: "Customer Support Classifier",
description: "Classifies incoming customer messages by intent",
template: "Classify the following customer message into one of these categories: {{categories}}\n\nMessage: {{message}}",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmPromptsCreate 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.
import {
// Mutation hook for triggering the API call.
useLlmPromptsCreateMutation
} from "@meetkai/mka1/react-query/llmPromptsCreate.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | components.CreatePromptRequest | ✔️ | The request object to use for the request. |
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. |
Response
Promise<components.CreatePromptResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
list
Returns a paginated list of prompts owned by the authenticated user.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.prompts.list({});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmPromptsList } from "@meetkai/mka1/funcs/llmPromptsList.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 llmPromptsList(sdk, {});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmPromptsList 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.
import {
// Query hooks for fetching data.
useLlmPromptsList,
useLlmPromptsListSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchLlmPromptsList,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateLlmPromptsList,
invalidateAllLlmPromptsList,
} from "@meetkai/mka1/react-query/llmPromptsList.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.ListPromptsRequest | ✔️ | The request object to use for the request. |
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. |
Response
Promise<components.ListPromptsResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
get
Retrieves a prompt by its ID, including the active template. Pass version to get a specific version's template. Pass variables as a JSON-encoded map to render the template with substitutions.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.prompts.get({
id: "prompt_aa87e2b1112a455b8deabed784372198",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmPromptsGet } from "@meetkai/mka1/funcs/llmPromptsGet.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 llmPromptsGet(sdk, {
id: "prompt_aa87e2b1112a455b8deabed784372198",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmPromptsGet 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.
import {
// Query hooks for fetching data.
useLlmPromptsGet,
useLlmPromptsGetSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchLlmPromptsGet,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateLlmPromptsGet,
invalidateAllLlmPromptsGet,
} from "@meetkai/mka1/react-query/llmPromptsGet.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.GetPromptRequest | ✔️ | The request object to use for the request. |
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. |
Response
Promise<components.GetPromptResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
update
Updates prompt metadata. To update the template content, create a new version instead.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.prompts.update({
id: "prompt_aa87e2b1112a455b8deabed784372198",
requestBody: {
name: "Customer Support Classifier v2",
},
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmPromptsUpdate } from "@meetkai/mka1/funcs/llmPromptsUpdate.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 llmPromptsUpdate(sdk, {
id: "prompt_aa87e2b1112a455b8deabed784372198",
requestBody: {
name: "Customer Support Classifier v2",
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmPromptsUpdate 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.
import {
// Mutation hook for triggering the API call.
useLlmPromptsUpdateMutation
} from "@meetkai/mka1/react-query/llmPromptsUpdate.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.UpdatePromptRequest | ✔️ | The request object to use for the request. |
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. |
Response
Promise<components.UpdatePromptResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
delete
Deletes a prompt and all its versions.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.prompts.delete({
id: "prompt_aa87e2b1112a455b8deabed784372198",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmPromptsDelete } from "@meetkai/mka1/funcs/llmPromptsDelete.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 llmPromptsDelete(sdk, {
id: "prompt_aa87e2b1112a455b8deabed784372198",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmPromptsDelete 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.
import {
// Mutation hook for triggering the API call.
useLlmPromptsDeleteMutation
} from "@meetkai/mka1/react-query/llmPromptsDelete.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.DeletePromptRequest | ✔️ | The request object to use for the request. |
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. |
Response
Promise<components.DeletePromptResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
createVersion
Creates a new version of a prompt. The new version automatically becomes the active version. Fields not provided are carried forward from the previous version.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.prompts.createVersion({
id: "prompt_aa87e2b1112a455b8deabed784372198",
requestBody: {
template: "You are a customer support classifier. Classify the message into: {{categories}}\n\nRespond with only the category name.\n\nMessage: {{message}}",
},
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmPromptsCreateVersion } from "@meetkai/mka1/funcs/llmPromptsCreateVersion.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 llmPromptsCreateVersion(sdk, {
id: "prompt_aa87e2b1112a455b8deabed784372198",
requestBody: {
template: "You are a customer support classifier. Classify the message into: {{categories}}\n\nRespond with only the category name.\n\nMessage: {{message}}",
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmPromptsCreateVersion 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.
import {
// Mutation hook for triggering the API call.
useLlmPromptsCreateVersionMutation
} from "@meetkai/mka1/react-query/llmPromptsCreateVersion.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.CreatePromptVersionRequest | ✔️ | The request object to use for the request. |
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. |
Response
Promise<components.CreateVersionResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
listVersions
Returns the version history of a prompt, ordered by version number.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.prompts.listVersions({
id: "prompt_aa87e2b1112a455b8deabed784372198",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmPromptsListVersions } from "@meetkai/mka1/funcs/llmPromptsListVersions.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 llmPromptsListVersions(sdk, {
id: "prompt_aa87e2b1112a455b8deabed784372198",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmPromptsListVersions 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.
import {
// Query hooks for fetching data.
useLlmPromptsListVersions,
useLlmPromptsListVersionsSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchLlmPromptsListVersions,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateLlmPromptsListVersions,
invalidateAllLlmPromptsListVersions,
} from "@meetkai/mka1/react-query/llmPromptsListVersions.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.ListPromptVersionsRequest | ✔️ | The request object to use for the request. |
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. |
Response
Promise<components.ListVersionsResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
getVersion
Retrieves a specific version of a prompt by version number.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.prompts.getVersion({
id: "prompt_aa87e2b1112a455b8deabed784372198",
version: 1,
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmPromptsGetVersion } from "@meetkai/mka1/funcs/llmPromptsGetVersion.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 llmPromptsGetVersion(sdk, {
id: "prompt_aa87e2b1112a455b8deabed784372198",
version: 1,
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmPromptsGetVersion 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.
import {
// Query hooks for fetching data.
useLlmPromptsGetVersion,
useLlmPromptsGetVersionSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchLlmPromptsGetVersion,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateLlmPromptsGetVersion,
invalidateAllLlmPromptsGetVersion,
} from "@meetkai/mka1/react-query/llmPromptsGetVersion.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.GetPromptVersionRequest | ✔️ | The request object to use for the request. |
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. |
Response
Promise<components.CreateVersionResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
rollback
Sets the active version of a prompt to a previous version. This does not delete newer versions — it only changes which version is active.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.prompts.rollback({
id: "prompt_aa87e2b1112a455b8deabed784372198",
requestBody: {
version: 1,
},
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmPromptsRollback } from "@meetkai/mka1/funcs/llmPromptsRollback.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 llmPromptsRollback(sdk, {
id: "prompt_aa87e2b1112a455b8deabed784372198",
requestBody: {
version: 1,
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmPromptsRollback 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.
import {
// Mutation hook for triggering the API call.
useLlmPromptsRollbackMutation
} from "@meetkai/mka1/react-query/llmPromptsRollback.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.RollbackPromptRequest | ✔️ | The request object to use for the request. |
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. |
Response
Promise<components.UpdatePromptResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |