Skip to main content

Overview

The Run Code feature allows you to execute code in multiple programming languages directly on GBOX.

Supported Languages

LanguageIdentifierDescription
PythonpythonPython 3.x with common packages
TypeScripttypescriptTypeScript with tsx runtime
BashbashBash shell commands

Usage

import GboxSDK from "gbox-sdk";
import * as dotenv from "dotenv";

dotenv.config();

const gboxSDK = new GboxSDK({
  apiKey: process.env["GBOX_API_KEY"],
});

async function main() {
  try {
    // Create a Linux box
    const box = await gboxSDK.create({ type: "linux" });

    // Example 1: Simple Python code execution
    console.log("=== Python Example ===");
    const pythonResult1 = await box.runCode("print('Hello, world!')");
    console.log(pythonResult1);

    // Example 2: Python code with explicit language specification
    const pythonResult2 = await box.runCode({
      code: `print("Hello, world!")`,
      language: "python",
    });
    console.log(pythonResult2);

    // Example 3: TypeScript code execution
    console.log("\n=== TypeScript Examples ===");
    const tsResult1 = await box.runCode({
      code: `console.log("Hello, world!");`,
      language: "typescript",
    });
    console.log(tsResult1);

    // Clean up - terminate the box
    await box.terminate();
    console.log("\n✅ Box terminated successfully");
  } catch (error) {
    console.error("❌ Error:", error);
  }
}

// Run the main function
main();
https://img.icons8.com/?size=100&id=FBO05Dys9QCg&format=png&color=000000

OpenAI Simple Integration

Learn how to integrate OpenAI with GBOX to generate and execute Python code from natural language prompts
https://img.icons8.com/?size=100&id=FBO05Dys9QCg&format=png&color=000000

OpenAI Function Calling

Use OpenAI’s Function Calling feature to create an AI assistant that can execute code in GBOX based on user queries
https://img.icons8.com/?size=100&id=XDigO1YmCwbW&format=png&color=000000

Anthropic Simple Integration

Learn how to integrate Anthropic Claude with GBOX to generate and execute Python code from natural language prompts
https://img.icons8.com/?size=100&id=XDigO1YmCwbW&format=png&color=000000

Anthropic Function Calling

Use Anthropic’s Function Calling feature to create an AI assistant that can execute code in GBOX based on user queries