Sandbox
Overview
Available Operations
- create - Create Session
- list - List Sessions
- get - Get Session
- getPricing - Get Sandbox Pricing
- setPricing - Set Sandbox Pricing
- getBrowserUrl - Get Browser Session URL
getUrl- Get Browser Session URL (Deprecated) ⚠️ Deprecated Use getBrowserUrl instead.- 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
- downloadArchive - Download Workspace Archive
- uploadArchive - Upload Workspace Archive
create
Create a sandbox session and return its public session metadata, session token, and provider. 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. It does not queue requests for session kinds the deployment does not support. Browser sessions require a Firecracker-backed deployment; standard-only deployments reject them immediately with browser_sessions_not_enabled.
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({
createSessionRequest: {
sessionId: "demo-python-20260316",
sessionKind: "standard",
sandboxFeatures: [],
runtimeProfile: "standard",
},
});
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, {
createSessionRequest: {
sessionId: "demo-python-20260316",
sessionKind: "standard",
sandboxFeatures: [],
runtimeProfile: "standard",
},
});
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 | operations.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,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateSandboxList,
invalidateAllSandboxList,
} from "@meetkai/mka1/react-query/sandboxList.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.ListSessionsRequest | ✔️ | 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 | */* |
get
Return the current state, configuration, and resource allocation 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 | */* |
getPricing
Current sandbox pricing rate card, keyed by SKU (standard, browser, eval-python). Metered sandbox usage is billed hours × (per_hour + reserved_memory_GiB × per_gib_hour); SKUs without a configured rate accrue no spend. Cluster admins only.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.getPricing();
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { sandboxGetPricing } from "@meetkai/mka1/funcs/sandboxGetPricing.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 sandboxGetPricing(sdk);
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxGetPricing 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.
useSandboxGetPricing,
useSandboxGetPricingSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchSandboxGetPricing,
// Utility to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateAllSandboxGetPricing,
} from "@meetkai/mka1/react-query/sandboxGetPricing.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.SandboxPricingCard>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.APIError | 4XX, 5XX | */* |
setPricing
Replace the sandbox pricing rate card. Full-replace semantics: SKUs omitted from the request become unpriced and accrue no spend. Takes effect on the next meter window without a restart. Cluster admins only.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.setPricing({
rates: {
"standard": {
perHour: 0.1,
perGibHour: 0.05,
},
"browser": {
perHour: 0.4,
perGibHour: 0.05,
},
"eval-python": {
perHour: 0.2,
perGibHour: 0.05,
},
},
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { sandboxSetPricing } from "@meetkai/mka1/funcs/sandboxSetPricing.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 sandboxSetPricing(sdk, {
rates: {
"standard": {
perHour: 0.1,
perGibHour: 0.05,
},
"browser": {
perHour: 0.4,
perGibHour: 0.05,
},
"eval-python": {
perHour: 0.2,
perGibHour: 0.05,
},
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxSetPricing 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.
useSandboxSetPricingMutation
} from "@meetkai/mka1/react-query/sandboxSetPricing.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | components.SandboxPricingUpdate | ✔️ | 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.SandboxPricingCard>
Errors
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |
getBrowserUrl
Return the public gateway URL for a browser session's Chrome DevTools Protocol endpoint. Playwright can use this HTTP endpoint directly. For clients that require a WebSocket endpoint, request json/version and use its rewritten webSocketDebuggerUrl. Insert subpaths before the query string; for example, use /ports/9222/json/version?session_token=.... Send the same MKA1 API-key authorization header on the HTTP and WebSocket requests. Standard sessions do not expose a public URL; use the command, code, and workspace operations instead.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.getBrowserUrl({
sessionId: "browser-demo-20260318",
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 { sandboxGetBrowserUrl } from "@meetkai/mka1/funcs/sandboxGetBrowserUrl.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 sandboxGetBrowserUrl(sdk, {
sessionId: "browser-demo-20260318",
sessionToken: "sandbox_test_browser_20260318",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxGetBrowserUrl 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.
useSandboxGetBrowserUrl,
useSandboxGetBrowserUrlSuspense,
// Utility for prefetching data during server-side rendering and in React
// Server Components that will be immediately available to client components
// using the hooks.
prefetchSandboxGetBrowserUrl,
// Utilities to invalidate the query cache for this query in response to
// mutations and other user actions.
invalidateSandboxGetBrowserUrl,
invalidateAllSandboxGetBrowserUrl,
} from "@meetkai/mka1/react-query/sandboxGetBrowserUrl.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.GetBrowserSessionUrlRequest | ✔️ | 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 | */* |
getUrl
Deprecated compatibility alias for getBrowserUrl. Return the public gateway URL for a browser session's Chrome DevTools Protocol endpoint. Standard sessions do not expose a public URL; use the command, code, and workspace operations instead.
⚠️ DEPRECATED: Use sandbox.getBrowserUrl instead.. Use
getBrowserUrlinstead.
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: "browser-demo-20260318",
sessionToken: "sandbox_test_browser_20260318",
port: 9222,
});
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: "browser-demo-20260318",
sessionToken: "sandbox_test_browser_20260318",
port: 9222,
});
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}/browser-url as the base. Insert CDP subpaths such as json/version or json/list before its query string, preserving the session_token parameter. This low-level proxy is intended for browser sessions on port 9222 and still requires the normal MKA1 API-key authorization header.
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 | */* |
downloadArchive
Download a zip archive containing the selected workspace paths.
Example Usage
import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.sandbox.downloadArchive({
sessionId: "demo-python-20260316",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
workspaceArchiveRequest: {
paths: [
"outputs/report.txt",
],
},
});
console.log(result);
}
run();Standalone function
The standalone function version of this method:
import { SDKCore } from "@meetkai/mka1/core.js";
import { sandboxDownloadArchive } from "@meetkai/mka1/funcs/sandboxDownloadArchive.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 sandboxDownloadArchive(sdk, {
sessionId: "demo-python-20260316",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
workspaceArchiveRequest: {
paths: [
"outputs/report.txt",
],
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxDownloadArchive 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.
useSandboxDownloadArchiveMutation
} from "@meetkai/mka1/react-query/sandboxDownloadArchive.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.DownloadWorkspaceArchiveRequest | ✔️ | 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 | */* |
uploadArchive
Upload a zip archive and extract its files into 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.uploadArchive({
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 { sandboxUploadArchive } from "@meetkai/mka1/funcs/sandboxUploadArchive.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 sandboxUploadArchive(sdk, {
sessionId: "demo-python-20260316",
sessionToken: "sandbox_test_20260316_4f9c2b1a",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("sandboxUploadArchive 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.
useSandboxUploadArchiveMutation
} from "@meetkai/mka1/react-query/sandboxUploadArchive.js";Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request | operations.UploadWorkspaceArchiveRequest | ✔️ | 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 | */* |