Skip to contents

Create a tool configuration for code interpreter. Allows the AI to execute Python code in a sandboxed container environment.

Usage

tool_code_interpreter(mem_limit = "1g", file_ids = NULL)

Arguments

mem_limit

Memory limit for the container. One of "1g" (default), "4g", "16g", or "64g". Higher tiers offer more RAM and are billed at higher rates.

file_ids

Optional character vector of file IDs to include in the container. Files must be uploaded via the Files API first.

Value

Tool configuration list

Details

The code interpreter runs in a sandboxed container that expires after 20 minutes of inactivity. Pricing is $0.03 per container session.

Examples

if (FALSE) { # \dontrun{
# Basic usage with default 1GB memory
openai_with_tools(
  prompt = "Calculate the first 20 Fibonacci numbers",
  tools = list(tool_code_interpreter())
)

# With increased memory for data-intensive tasks
openai_with_tools(
  prompt = "Analyze this large dataset",
  tools = list(tool_code_interpreter(mem_limit = "4g"))
)
} # }