Llm.Files
Overview
Available Operations
- upload - Upload file
- list - List files
- get - Retrieve file
- delete - Delete file
- content - Retrieve file content
upload
Upload a file that can be used with Assistants, Vector Stores, and other features. Files are uploaded to S3 for durable storage.
Example Usage
import { SDK } from "@meetkai/mka1";
import { openAsBlob } from "node:fs";
const sdk = new SDK({
serverURL: "https://api.example.com",
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.files.upload({
file: await openAsBlob("example.file"),
purpose: "assistants",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmFilesUpload } from "@meetkai/mka1/funcs/llmFilesUpload.js";
import { openAsBlob } from "node:fs";
// 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 llmFilesUpload(sdk, {
file: await openAsBlob("example.file"),
purpose: "assistants",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmFilesUpload 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.
useLlmFilesUploadMutation
} from "@meetkai/mka1/react-query/llmFilesUpload.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.UploadFileRequestBody | ✔️ | 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.FileT>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
list
Returns a list of files that have been uploaded.
Example Usage
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.files.list({});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmFilesList } from "@meetkai/mka1/funcs/llmFilesList.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 llmFilesList(sdk, {});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmFilesList 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.
useLlmFilesList,
useLlmFilesListSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchLlmFilesList,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateLlmFilesList,
invalidateAllLlmFilesList,
} from "@meetkai/mka1/react-query/llmFilesList.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.ListFilesRequest | ✔️ | 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.FileList>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
get
Returns information about a specific file.
Example Usage
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.files.get({
fileId: "<id>",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmFilesGet } from "@meetkai/mka1/funcs/llmFilesGet.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 llmFilesGet(sdk, {
fileId: "<id>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmFilesGet 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.
useLlmFilesGet,
useLlmFilesGetSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchLlmFilesGet,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateLlmFilesGet,
invalidateAllLlmFilesGet,
} from "@meetkai/mka1/react-query/llmFilesGet.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.GetFileRequest | ✔️ | 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.FileT>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
delete
Delete a file from storage. This will also remove it from any vector stores.
Example Usage
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.files.delete({
fileId: "<id>",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmFilesDelete } from "@meetkai/mka1/funcs/llmFilesDelete.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 llmFilesDelete(sdk, {
fileId: "<id>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmFilesDelete 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.
useLlmFilesDeleteMutation
} from "@meetkai/mka1/react-query/llmFilesDelete.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.DeleteFileRequest | ✔️ | 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.FileDeletionStatus>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
content
Returns the contents of the specified file as a data URI.
Example Usage
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.files.content({
fileId: "<id>",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmFilesContent } from "@meetkai/mka1/funcs/llmFilesContent.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 llmFilesContent(sdk, {
fileId: "<id>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("llmFilesContent 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.
useLlmFilesContent,
useLlmFilesContentSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchLlmFilesContent,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateLlmFilesContent,
invalidateAllLlmFilesContent,
} from "@meetkai/mka1/react-query/llmFilesContent.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.GetFileContentRequest | ✔️ | 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<string>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |