Reference · Tools

OpenAI Code Interpreter

Execute code in a sandboxed environment via OpenAI Responses API code interpreter tool.

Action (binary) AI v1 Binary data

OpenAI Code Interpreter lets the model write and run Python in a sandbox to answer a request, returning both textual results and any files it produced — charts, exports — as binary data. A typical build is generating a chart from a dataset and attaching the image to a report.

Node type
Action (binary)
Parameters
7
Outputs
Output, Error
Credentials
OpenAI

OpenAI Code Interpreter

Execute code in a sandboxed environment via OpenAI code interpreter

Overview

The OpenAI Code Interpreter tool sends a user message to the OpenAI Responses API with the code_interpreter tool enabled, allowing the model to write and execute code in a sandboxed environment. The model can run Python code, perform data analysis, generate charts and files, and return both textual results and output files. Output files can be automatically downloaded and stored as binary data.

Category: AI
Tool Name: openai_code_interpreter
Version: 1

Appearance: Icon: openai | Color: #10a37f

Node Type

Action (Binary) — handles file/binary data operations

Input / Output

DirectionPort(s)
InputInput
OutputOutput, Error

Credentials

This tool requires OpenAI credentials. See the Credentials Guide for setup instructions.

Parameters

ParameterTypeRequiredDefaultDescription
ModeloptionsYes(current default)The OpenAI model to use for code interpretation. Always uses the latest version (auto-updated).
Options: the OpenAI chat models available to your workspace — pick one from the dropdown.
System PromptstringNoOptional system-level instructions for the model. Guides how the model approaches code execution tasks. Supports expressions.
User MessagestringYesThe user message or prompt to send. The model will write and execute code to fulfill this request. Supports expressions.
Attachment File IDstringNoOptional OpenAI file ID (file-…) returned by openai_file_upload. When provided, the file is referenced by ID and the tool skips the automatic binary upload step — useful for re-using a previously uploaded file across multiple code_interpreter runs. Falls back to item.json.attachmentFileId if empty. Supports {{ $json.fileId }} expressions from an upstream openai_file_upload node. If both this and an input binary are present, the file ID takes precedence.
OptionscollectionNo{}Optional execution and output settings — add only the fields you need.
— TemperaturenumberNo1Sampling temperature (0-2). Lower values make output more deterministic.
— Max Output TokensnumberNo0Maximum number of tokens in the response. 0 means no limit (model default).
— Download FilesbooleanNotrueWhether to automatically download files produced by code execution and store them as binary data.
— Binary Property NamestringNodataName of the binary property for input file attachments and the first output file. Additional output files use file_1, file_2, etc. Names are case-sensitive — see the upstream node’s Binary Data panel for the exact names to use.
— Response Field NamestringNoresponseName of the JSON field to store the model text response in.
Include InputbooleanNofalseWhether to include the original input item JSON fields in the output.
Max ConcurrencynumberNo5Maximum number of items to process concurrently. Keep low to respect OpenAI rate limits.

Output Data

One output item per input item. The model’s written answer lands on the field named by Response Field Name (response by default), accompanied by the code it ran and what that code returned. The rest of the input item JSON is dropped unless Include Input is on.

{
  "response": "The model's explanation of what it computed",
  "code": "import pandas as pd\n...",
  "codeResults": [],
  "model": "the model that ran the code",
  "usage": { "input_tokens": 640, "output_tokens": 900 }
}
  • code is the source the model actually executed — keep it when you need an audit trail of the analysis.
  • codeResults holds the raw results the sandbox returned, including entries describing any files that were produced.
  • When Download Files is on, generated files are fetched and attached as binary data: the first file uses Binary Property Name (data by default) and any further files land on file_1, file_2, and so on, merged with binary the item already carried.
  • If an input item carries binary data and no Attachment File ID is set, that file is uploaded to the sandbox so the code can read it.

Reference the result downstream by expression, e.g. {{ $json.response }}.

Usage Examples

  • Run Python code to analyze a CSV file
  • Generate a chart from data and download the image
  • Perform data transformations with code execution
  • Execute statistical analysis on uploaded data
  • Create a visualization and return it as binary

Example Configuration

Analyze the CSV attached to each item:

{
  "type": "openai_code_interpreter",
  "parameters": {
    "userMessage": "Load the attached CSV, then report the row count and the mean of every numeric column."
  }
}

Deterministic analysis with no file downloads:

{
  "type": "openai_code_interpreter",
  "parameters": {
    "systemPrompt": "Write concise Python. Return only the computed numbers, no commentary.",
    "userMessage": "Compute the 95th percentile of {{ $json.values }}.",
    "maxConcurrency": 10,
    "options": {
      "temperature": 0,
      "downloadFiles": false,
      "responseFieldName": "stats"
    }
  }
}

Produce a chart and keep it as binary on a named property:

{
  "type": "openai_code_interpreter",
  "parameters": {
    "userMessage": "Plot monthly revenue from the attached file as a line chart and save it as a PNG.",
    "includeInput": true,
    "options": {
      "downloadFiles": true,
      "binaryPropertyName": "chart"
    }
  }
}

Error Handling

ModeBehavior
stopHalts workflow on first error
continueSkips failed items, passes successful ones through
errorPortRoutes failed items to Error output port

Tips

The OpenAI Code Interpreter tool executes Python code in a sandboxed environment by sending user messages to the OpenAI Responses API with the code interpreter capability enabled. Use it when a workflow requires dynamic computation, data analysis, or chart generation that cannot be handled by static logic nodes. It outputs textual results and downloadable binary file data on the main channel, or routes execution failures to the error channel.

Frequently asked questions

Can it produce files as well as text?

Yes — downloadable file data comes back as binary on the main output, which is what makes it useful for chart and export generation rather than just calculation.

Where does the code run?

In OpenAI's sandboxed environment as part of the Responses API call — nothing executes in your workflow environment.

When should I use this over a code node?

When the analysis is exploratory or depends on data shapes you cannot predict. For fixed, repeatable logic, a code node you control is cheaper and more predictable.

Which credential does it need?

An OpenAI credential with access to a model supporting the code interpreter tool.

Build with the OpenAI Code Interpreter node

Drop it into a workflow, wire it to an agent, or call it on a schedule. You'll need OpenAI credentials first.

Open BusyBot

Last updated . Spotted something wrong? Tell us.