Classify
(llm.classify)
Overview
Available Operations
- classifyText - Classify text into predefined categories
classifyText
Intelligently classify text content into one of the provided labels using advanced language models. Supports sentiment analysis, topic categorization, intent detection, content moderation, and custom classification tasks. The model analyzes the input text and selects the most appropriate label from your predefined list (minimum 2 labels required). Returns the classification result with an optional confidence score (0-1) indicating certainty, and optional reasoning explaining the model's decision. Supports custom prompts to guide the classification with domain-specific instructions or context.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.classify.classifyText({
model: "Focus",
text: "<value>",
labels: [],
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmClassifyClassifyText } from "@meetkai/mka1/funcs/llmClassifyClassifyText.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 llmClassifyClassifyText(sdk, {
model: "Focus",
text: "<value>",
labels: [],
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmClassifyClassifyText 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.
useLlmClassifyClassifyTextMutation
} from "@meetkai/mka1/react-query/llmClassifyClassifyText.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.ClassifyTextRequestBody | ✔️ | 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<operations.ClassifyTextResponseBody>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |