Jinba Toolbox
Integrations

SDK

TypeScript/JavaScript SDK usage

Installation

npm install @jinba-toolbox/sdk

Creating a Client

import { createClient } from "@jinba-toolbox/sdk";

const client = createClient({
  apiKey: "jtb_xxxxx",
  organizationId: "org-id", // Default organization ID (optional)
});

Configuration Options

ParameterTypeDefaultDescription
apiKeystring(required)API key
organizationIdstring-Default organization ID
baseUrlstringhttps://toolbox-api.jinba.devAPI base URL
timeoutnumber30000Request timeout (ms)

Tool Execution

Run (Published)

const result = await client.run("my-toolset", "my-tool", {
  name: "World",
});

console.log(result.success); // true
console.log(result.output);  // { message: "Hello, World!" }

Version specification:

const result = await client.run("my-toolset", "my-tool", { name: "World" }, {
  version: "1.0.0",
});

Test Run (Draft)

Test draft code without publishing.

const result = await client.test("my-toolset", "my-tool", {
  name: "World",
});

console.log(result.output); // { message: "Hello, World!" }
console.log(result.logs);   // { stdout: [...], stderr: [...] }

Organizations

// List organizations
const orgs = await client.listOrganizations();

// Get organization details
const org = await client.getOrganization("org-id");

ToolSet

// List
const toolSets = await client.listToolSets();

// Get details (includes Tools)
const toolSet = await client.getToolSet("my-toolset");

// Create
const newToolSet = await client.createToolSet({
  slug: "my-toolset",
  name: { default: "My ToolSet" },
  description: { default: "Description" },
  sandbox: {
    provider: "e2b",
    language: "python",
    packages: [{ name: "requests" }],
    resources: { timeout: 30 },
  },
});

// Update
await client.updateToolSet("my-toolset", {
  name: { default: "Updated Name" },
  mcpEnabled: true,
});

// Delete
await client.deleteToolSet("my-toolset");

Tool

// List
const tools = await client.listTools("my-toolset");

// Get details
const tool = await client.getTool("my-toolset", "my-tool");

// Create
const newTool = await client.createTool("my-toolset", {
  slug: "my-tool",
  name: { default: "My Tool" },
  description: { default: "Description" },
  inputSchema: { type: "object", properties: { name: { type: "string" } } },
  outputSchema: { type: "object", properties: { message: { type: "string" } } },
  code: `def run(input): return {"message": f"Hello, {input['name']}!"}`,
});

// Update
await client.updateTool("my-toolset", "my-tool", {
  code: "updated code...",
});

// Delete
await client.deleteTool("my-toolset", "my-tool");

Versions

// List
const versions = await client.listVersions("my-toolset");

// Publish new version
const version = await client.publishVersion("my-toolset", {
  version: "1.0.0",
  releaseNotes: "Initial release",
});

Run Logs

// List
const runs = await client.listRuns();

// Get details
const run = await client.getRun("run_xxx");

Type Definitions

RunResult

interface RunResult {
  runId: string;
  success: boolean;
  output?: Record<string, unknown>;
  error?: RunError;
  logs?: RunLogs;
  durationMs?: number;
}

interface RunError {
  name: string;
  message: string;
  traceback?: string;
}

interface RunLogs {
  stdout: string[];
  stderr: string[];
}

Run

interface Run {
  id: string;
  toolSetId: string;
  toolSetVersion: string;
  toolId: string;
  toolSlug: string;
  userId: string;
  input: Record<string, unknown>;
  output?: Record<string, unknown> | null;
  status: "pending" | "running" | "success" | "failed" | "timeout";
  error?: RunError | null;
  logs?: RunLogs | null;
  startedAt?: string | null;
  completedAt?: string | null;
  durationMs?: number | null;
  createdAt: string;
}

Error Handling

SDK errors are thrown as JinbaTBError.

import { JinbaTBError } from "@jinba-toolbox/sdk";

try {
  await client.run("my-toolset", "my-tool", { name: "World" });
} catch (err) {
  if (err instanceof JinbaTBError) {
    console.error(err.message);    // Error message
    console.error(err.statusCode); // HTTP status code
    console.error(err.details);    // Additional details
  }
}

Common Errors

statusCodeCause
400Invalid input parameters
401Invalid API key
402Insufficient credits
404Resource not found
408Request timeout

On this page