Skip to main content
OpenAI Code Interpreter gives an OpenAI agent a sandboxed Python environment for exact math, data slicing, and analysis.

What it does

When enabled, the agent can call OpenAI’s hosted python tool to write and run Python in an ephemeral container. Use it when you need exact results that language models alone cannot guarantee — for example splitting spreadsheet rows into precise batches, computing statistics, or transforming tabular data. Important: Code Interpreter is for computation only. Downloadable files (PDF, DOCX, XLSX, CSV) are still created through File Tools (write_file). The agent should print results as CSV/JSON text, then call write_file so Fetch Hive stores a real asset in your workspace.

Requirements

  • Agent provider must be OpenAI.
  • The tool is not enabled by default — add it from the tool picker.

Adding the tool to an agent

  1. Open an agent in the editor.
  2. Click the button with the tooltip Add MCP Tool or Sub Agent.
  3. In MCP Tools, click OpenAI Code Interpreter.
There are no per-tool settings in v1. Containers use OpenAI’s default 1 GB memory tier.

How it works with File Tools

Typical flow for spreadsheet slicing:
  1. The agent (or File Tools read_file) loads the source data.
  2. Code Interpreter runs Python to slice or transform the data and prints CSV/JSON.
  3. The agent calls write_file with that text to create downloadable XLSX/CSV assets.
Files created inside OpenAI’s container are ephemeral and are not surfaced as Fetch Hive downloads. Sandbox images and ephemeral OpenAI file URLs are redacted from tool activity — they are not shown as downloads. Always prefer write_file for user-facing files.

Limitations (v1)

  • OpenAI only — Anthropic and xAI code-execution tools are not wired yet.
  • No multi-turn Python state — each agent turn starts a fresh container; variables from a previous turn do not persist.
  • Fixed 1 GB memory — higher OpenAI memory tiers are not exposed yet.
  • Each Code Interpreter call counts as 1 task credit (same pattern as GPT Search). Container-minute spend is tracked only as estimated operator metadata (estimated: true) on the completion — not a separate user-facing USD line item. On hosted keys, OpenAI container minutes are absorbed by Fetch Hive.

Use cases

  • Exact row slicing (rows 1–50, 51–100, …) before exporting XLSX batches.
  • Numerical / statistical calculations that must be precise.
  • Parsing or reshaping tabular data before writing a file.

Notes