> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/maiagent-user-guide/maiagent-user-guide-en/agent-builder/code-interpreter.md).

# Code Interpreter

## What Is This? <a href="#what-is-this" id="what-is-this"></a>

Code Interpreter lets an Agent execute Python code in a **secure sandbox environment**, completing tasks programmatically.

With Code Interpreter enabled, the Agent can do more than just reply with text — it can write code to perform calculations, process files you upload, generate Word/PowerPoint/Excel documents, and return the results for you to download.

## How Is It Different from Tools? <a href="#code-interpreter-vs-tool" id="code-interpreter-vs-tool"></a>

|                       | Tools                                                  | Code Interpreter                                        |
| --------------------- | ------------------------------------------------------ | ------------------------------------------------------- |
| **Nature**            | Calls pre-defined external APIs                        | Writes and executes Python on the fly in a sandbox      |
| **Flexibility**       | Limited to what the API provides                       | Anything Python can do                                  |
| **Typical use cases** | Send emails, query CRM, integrate third-party services | Computation, data processing, file generation, charting |

**Quick rule of thumb**: Need to call an external API → Tools; need to compute, process files, or generate documents → Code Interpreter.

## What Can It Do? <a href="#what-it-can-do" id="what-it-can-do"></a>

* **Data analysis & computation**: CSV/Excel calculations, statistics, pivot tables, data cleaning
* **Chart creation**: Turn data into line charts, bar charts, pie charts, and more
* **Document generation**: Produce Word, PowerPoint, Excel, and PDF files for download
* **File processing**: Parse PDFs, convert formats, batch-process uploaded files

## Sandbox Environment <a href="#sandbox-environment" id="sandbox-environment"></a>

* The execution environment is a **secure sandbox**, isolated from production systems — it won't affect any other data
* Supports standard Python along with common data and document processing packages
* Files generated by the Agent appear in the **Output** panel within the chat interface and can be downloaded directly

## When to Use <a href="#when-to-use" id="when-to-use"></a>

* Finance/sales teams ask the Agent to organize Excel files and produce weekly reports
* HR/admin teams ask the Agent to turn survey results into charts and generate PowerPoint presentations
* Legal/contract teams ask the Agent to extract key fields from PDFs and output Word summaries
* Any conversation scenario that requires ad-hoc computation or on-the-fly file generation

## What Do I Need to Do? <a href="#what-do-i-need-to-do" id="what-do-i-need-to-do"></a>

1. **Go to Agent settings** — Open the settings page of the AI Assistant you want to enable it for
2. **Enable Code Interpreter** — Turn it on in the tools or advanced capabilities section
3. **Test** — Ask the Agent to perform a task that requires computation or file generation in a conversation, and verify that the Output panel allows normal downloads


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.maiagent.ai/maiagent-user-guide/maiagent-user-guide-en/agent-builder/code-interpreter.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
