code-interpreter template when you want notebook-style execution
inside a hosted sandbox. It adds stateful cells, package installation,
stdout/stderr callbacks, structured results, artifacts, and language contexts
on templates that include them.
Use raw Commands instead when you only need a process
to run and return stdout or stderr.
Quick Example
When To Use It
| Need | Use Code Interpreter? |
|---|---|
| Keep variables between cells | Yes. Use contexts to preserve kernel state. |
| Return rich results or downloadable artifacts | Yes. Results can include text, images, HTML, and files. |
| Stream stdout and stderr during execution | Yes. Use callbacks or streaming APIs. |
| Run a normal CLI command or service | Usually no. Use Commands instead. |
| Preinstall a repeatable analysis stack | Build a custom template and use it with Code Interpreter. |
Core Concepts
| Concept | Meaning |
|---|---|
| Template | code-interpreter includes the runtime for notebook-style execution. |
| Context | A stateful kernel namespace that can keep variables and imports warm. |
| Run | One code execution request, with logs, results, artifacts, and errors. |
| Artifact | A generated file or rich output your app can inspect or download. |
Package Installs
Rich Output
Guides
Analyze data with AI
Run stateful Python, R, JavaScript, TypeScript, Java, or Bash cells.
Charts and visualizations
Generate static charts, interactive HTML outputs, and downloadable files.
Supported languages
Choose a kernel and keep state in language-specific contexts.
Streaming
Stream stdout, stderr, results, artifacts, and errors as code executes.