> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gbox.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Basic

> Execute code in multiple languages directly on GBOX

## Overview

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

## Supported Languages

| Language | Identifier | Description |
| - | - | - |
| Python | `python` | Python 3.x with common packages |
| TypeScript | `typescript` | TypeScript with tsx runtime |
| Bash | `bash` | Bash shell commands |

## Usage

```typescript TypeScript highlight={17,21-24,29-32} icon="https://cdn.worldvectorlogo.com/logos/typescript.svg" theme={null}
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();
```

```python Python highlight={18,23-24,31-32} icon="https://cdn.worldvectorlogo.com/logos/python-5.svg" theme={null}
import os
from dotenv import load_dotenv
from gbox_sdk import GboxSDK

# Load environment variables from .env file
load_dotenv()

# Initialize the GBOX SDK
gbox_sdk = GboxSDK(api_key=os.getenv("GBOX_API_KEY"))

def main():
    try:
        # Create a Linux box
        box = gbox_sdk.create(type="linux")

        # Example 1: Simple Python code execution
        print("=== Python Example ===")
        python_result1 = box.run_code("print('Hello, world!')")
        print(python_result1)

        # Example 2: Python code with explicit language specification
        python_result2 = box.run_code(
            code="print('Hello, world!')",
            language="python"
        )
        print(python_result2)

        # Example 3: TypeScript code execution
        print("\n=== TypeScript Examples ===")
        ts_result1 = box.run_code(
            code="console.log('Hello, world!');",
            language="typescript"
        )
        print(ts_result1)

        # Clean up - terminate the box
        box.terminate()
        print("\n✅ Box terminated successfully")

    except Exception as error:
        print(f"❌ Error: {error}")

if __name__ == "__main__":
    main()
```

> [card] [OpenAI Simple Integration](https://docs.gbox.ai/run-code/openai/simple.md)
>
> Learn how to integrate OpenAI with GBOX to generate and execute Python code
> from natural language prompts

> [card] [OpenAI Function Calling](https://docs.gbox.ai/run-code/openai/function-calling.md)
>
> Use OpenAI's Function Calling feature to create an AI assistant that can
> execute code in GBOX based on user queries

> [card] [Anthropic Simple Integration](https://docs.gbox.ai/run-code/anthropic/simple.md)
>
> Learn how to integrate Anthropic Claude with GBOX to generate and execute
> Python code from natural language prompts

> [card] [Anthropic Function Calling](https://docs.gbox.ai/run-code/anthropic/function-calling.md)
>
> Use Anthropic's Function Calling feature to create an AI assistant that can
> execute code in GBOX based on user queries


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.