# Code Interpreter

CodeInterpreter extends Python-based coding environments with integrated data analysis, enabling developers to run scripts, visualize results, and prototype solutions inside supported platforms

- **Category:** developer tools
- **Auth:** NO_AUTH
- **Composio Managed App Available?** N/A
- **Tools:** 5
- **Triggers:** 0
- **Slug:** `CODEINTERPRETER`
- **Version:** 20260211_00

## Tools

### Create Sandbox

**Slug:** `CODEINTERPRETER_CREATE_SANDBOX`

Create a sandbox to execute python code in a Jupyter notebook cell. This is useful for agents to communicate, execute code, see output, read files, write files, etc. It's like you own personal computer, but in the cloud. Use /home/user folder to write/read files.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `keep_alive` | integer | No | The number of seconds to keep the sandbox alive after creation. Default is 300 seconds (5 minutes). Can be in between 0 and 3600. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### Execute Code

**Slug:** `CODEINTERPRETER_EXECUTE_CODE`

Execute python code in a sandbox and return any result, stdout, stderr, and error. Use /home/user folder to write/read files. Try to not use plt.show() as the code is executed remotely. Use files for image/chart output instead.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `timeout` | integer | No | The timeout in seconds for the execution of the code. |
| `keep_alive` | integer | No | The number of seconds to keep the sandbox alive after execution. Default is 300 seconds (5 minutes). Can be between 0 and 3600. |
| `sandbox_id` | string | No | The ID of the sandbox to execute the code in. Try to find an existing sandbox ID from context in order to access the previous modification session. In case not found, this value might be omitted, a new sandbox will be created. |
| `code_to_execute` | string | Yes | The python code to execute in a single cell. If a file is to be saved, it should be saved under /home/user/ directory. At the end of the code, a success message print is good to have. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### Get File

**Slug:** `CODEINTERPRETER_GET_FILE_CMD`

Get a file from the sandbox and returns the file. The files should be read from /home/user folder.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `timeout` | integer | No | The timeout in seconds for the command to run. |
| `file_path` | string | Yes | The path(on the sandbox) of the file to get. Give absolute path. Should start with /home/user/ |
| `sandbox_id` | string | Yes | The ID of the sandbox where the file has been created. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### Run Terminal Command

**Slug:** `CODEINTERPRETER_RUN_TERMINAL_CMD`

Run a command in the terminal and returns the stdout, stderr, and error code. Use /home/user folder to write/read files.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `command` | string | Yes | The command to run in the terminal. |
| `timeout` | integer | No | The timeout in seconds for the command to run. |
| `keep_alive` | integer | No | The number of seconds to keep the sandbox alive after execution. Default is 300 seconds (5 minutes). |
| `sandbox_id` | string | No | The ID of the sandbox to execute the code in. Try to find an existing sandbox ID from contextinorder to access the previous modification session. In case not found, this value might be omitted, a new sandbox will be created. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### Upload File

**Slug:** `CODEINTERPRETER_UPLOAD_FILE_CMD`

Upload a file to the sandbox environment. The files should be uploaded to the /home/user folder.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `file` | object | Yes | The file to upload, containing the file name and base64-encoded content. |
| `overwrite` | boolean | No | Whether to overwrite the file if it already exists. |
| `sandbox_id` | string | Yes | The ID of the sandbox where the file will be uploaded. |
| `destination_path` | string | Yes | The destination path in the sandbox where the file will be saved. Provide an absolute path starting with /home/user/. The file name from 'file' will be appended if destination_path is a directory. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |
