Sandbox
Overview
Available Operations
- create - Create Session
- list - List Sessions
- get - Get Session
- getUrl - Get Session URL
- proxyBrowserPortRequest - Proxy Browser Port Request
- runCommand - Run Command
- runCode - Run Code
- terminate - Terminate Session
- getWorkspace - Get Workspace Manifest
- downloadFile - Download Workspace File
- uploadFile - Upload Workspace File
create
Create a sandbox session and return a session token, provider, and base sandbox URL. Set session_kind to browser to start a browser-backed session instead of a standard command/code sandbox. Set queue_if_full to true to queue the request instead of failing when runner capacity is temporarily unavailable.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.create({
sessionId: "demo-python-20260316",
sessionKind: "standard",
sandboxFeatures: [],
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { sandboxCreate } from "@meetkai/mka1/funcs/sandboxCreate.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 sandboxCreate(sdk, {
sessionId: "demo-python-20260316",
sessionKind: "standard",
sandboxFeatures: [],
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxCreate 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.
useSandboxCreateMutation
} from "@meetkai/mka1/react-query/sandboxCreate.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | components.CreateSessionRequest | ✔️ | 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.CreateSessionResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
list
List sandbox sessions visible to the authenticated caller.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.list();
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { sandboxList } from "@meetkai/mka1/funcs/sandboxList.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 sandboxList(sdk);
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxList 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.
useSandboxList,
useSandboxListSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchSandboxList,
// Utility to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateAllSandboxList,
} from "@meetkai/mka1/react-query/sandboxList.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
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.SessionRecord[]>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
get
Return the current state, features, and runner metadata for a sandbox session.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.get({
sessionId: "demo-python-20260316",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { sandboxGet } from "@meetkai/mka1/funcs/sandboxGet.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 sandboxGet(sdk, {
sessionId: "demo-python-20260316",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxGet 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.
useSandboxGet,
useSandboxGetSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchSandboxGet,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateSandboxGet,
invalidateAllSandboxGet,
} from "@meetkai/mka1/react-query/sandboxGet.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.GetSessionRequest | ✔️ | 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.SessionRecord>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
getUrl
Resolve a gateway URL for a port exposed by the sandbox session. For browser sessions, omit port or set it to 9222 to get the browser proxy base URL; then use that URL directly with a CDP client such as Playwright/Puppeteer or append /json/version to inspect the browser endpoint over plain HTTP.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.getUrl({
sessionId: "demo-python-20260316",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
port: 8003,
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { sandboxGetUrl } from "@meetkai/mka1/funcs/sandboxGetUrl.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 sandboxGetUrl(sdk, {
sessionId: "demo-python-20260316",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
port: 8003,
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxGetUrl 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.
useSandboxGetUrl,
useSandboxGetUrlSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchSandboxGetUrl,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateSandboxGetUrl,
invalidateAllSandboxGetUrl,
} from "@meetkai/mka1/react-query/sandboxGetUrl.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.GetSessionUrlRequest | ✔️ | 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.SessionUrlResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
proxyBrowserPortRequest
Proxy an HTTP request to an exposed browser-session port through the gateway. Use the URL returned by GET /sessions/{session_id}/url as the base, then append CDP subpaths such as json/version or json/list. This low-level proxy is primarily intended for browser sessions on port 9222.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.proxyBrowserPortRequest({
sessionId: "browser-demo-20260318",
port: 9222,
subpath: "json/version",
sessionToken: "sandbox_test_browser_20260318",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { sandboxProxyBrowserPortRequest } from "@meetkai/mka1/funcs/sandboxProxyBrowserPortRequest.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 sandboxProxyBrowserPortRequest(sdk, {
sessionId: "browser-demo-20260318",
port: 9222,
subpath: "json/version",
sessionToken: "sandbox_test_browser_20260318",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxProxyBrowserPortRequest 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.
useSandboxProxyBrowserPortRequest,
useSandboxProxyBrowserPortRequestSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchSandboxProxyBrowserPortRequest,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateSandboxProxyBrowserPortRequest,
invalidateAllSandboxProxyBrowserPortRequest,
} from "@meetkai/mka1/react-query/sandboxProxyBrowserPortRequest.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.ProxyBrowserPortRequestRequest | ✔️ | 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<any>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
runCommand
Run a command in the session workspace and return stdout, stderr, exit code, and changed files.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.runCommand({
sessionId: "demo-python-20260316",
commandRequest: {
sessionId: "demo-python-20260316",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
command: "python3",
args: [
"-c",
"import math; print(math.sqrt(144))",
],
cwd: null,
env: {
},
},
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { sandboxRunCommand } from "@meetkai/mka1/funcs/sandboxRunCommand.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 sandboxRunCommand(sdk, {
sessionId: "demo-python-20260316",
commandRequest: {
sessionId: "demo-python-20260316",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
command: "python3",
args: [
"-c",
"import math; print(math.sqrt(144))",
],
cwd: null,
env: {
},
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxRunCommand 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.
useSandboxRunCommandMutation
} from "@meetkai/mka1/react-query/sandboxRunCommand.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.RunCommandRequest | ✔️ | 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.CommandResult>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
runCode
Execute source code in the session workspace using a supported runtime and return the execution result.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.runCode({
sessionId: "demo-python-20260316",
codeRequest: {
sessionId: "demo-python-20260316",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
runtime: "python",
code: "from pathlib import Path; Path('live_check.txt').write_text('ok'); print('code-ran')",
cwd: null,
env: {
},
},
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { sandboxRunCode } from "@meetkai/mka1/funcs/sandboxRunCode.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 sandboxRunCode(sdk, {
sessionId: "demo-python-20260316",
codeRequest: {
sessionId: "demo-python-20260316",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
runtime: "python",
code: "from pathlib import Path; Path('live_check.txt').write_text('ok'); print('code-ran')",
cwd: null,
env: {
},
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxRunCode 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.
useSandboxRunCodeMutation
} from "@meetkai/mka1/react-query/sandboxRunCode.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.RunCodeRequest | ✔️ | 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.CodeResult>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
terminate
Stop a sandbox session and release the backing sandbox resources.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.terminate({
sessionId: "demo-python-20260316",
terminateSessionRequest: {
sessionId: "demo-python-20260316",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
},
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { sandboxTerminate } from "@meetkai/mka1/funcs/sandboxTerminate.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 sandboxTerminate(sdk, {
sessionId: "demo-python-20260316",
terminateSessionRequest: {
sessionId: "demo-python-20260316",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxTerminate 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.
useSandboxTerminateMutation
} from "@meetkai/mka1/react-query/sandboxTerminate.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.TerminateSessionRequest | ✔️ | 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.TerminateSessionResponse>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
getWorkspace
List files currently stored in the session workspace, including paths, sizes, and etags.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.getWorkspace({
sessionId: "demo-python-20260316",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { sandboxGetWorkspace } from "@meetkai/mka1/funcs/sandboxGetWorkspace.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 sandboxGetWorkspace(sdk, {
sessionId: "demo-python-20260316",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxGetWorkspace 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.
useSandboxGetWorkspace,
useSandboxGetWorkspaceSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchSandboxGetWorkspace,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateSandboxGetWorkspace,
invalidateAllSandboxGetWorkspace,
} from "@meetkai/mka1/react-query/sandboxGetWorkspace.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.GetWorkspaceRequest | ✔️ | 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.WorkspaceManifest>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
downloadFile
Download raw bytes from a file in the session workspace.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.downloadFile({
sessionId: "demo-python-20260316",
filePath: "outputs/report.txt",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { sandboxDownloadFile } from "@meetkai/mka1/funcs/sandboxDownloadFile.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 sandboxDownloadFile(sdk, {
sessionId: "demo-python-20260316",
filePath: "outputs/report.txt",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxDownloadFile 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.
useSandboxDownloadFile,
useSandboxDownloadFileSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchSandboxDownloadFile,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateSandboxDownloadFile,
invalidateAllSandboxDownloadFile,
} from "@meetkai/mka1/react-query/sandboxDownloadFile.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.DownloadWorkspaceFileRequest | ✔️ | 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<ReadableStream<Uint8Array>>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
uploadFile
Upload raw bytes into the session workspace at the given path.
Example Usage
import { SDK } from "@meetkai/mka1";
import { openAsBlob } from "node:fs";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.uploadFile({
sessionId: "demo-python-20260316",
filePath: "inputs/config.json",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
requestBody: await openAsBlob("example.file"),
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { sandboxUploadFile } from "@meetkai/mka1/funcs/sandboxUploadFile.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({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const res = await sandboxUploadFile(sdk, {
sessionId: "demo-python-20260316",
filePath: "inputs/config.json",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
requestBody: await openAsBlob("example.file"),
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxUploadFile 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.
useSandboxUploadFileMutation
} from "@meetkai/mka1/react-query/sandboxUploadFile.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.UploadWorkspaceFileRequest | ✔️ | 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<{ [k: string]: string }>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |