Create a tool configuration for code interpreter. Allows the AI to execute Python code in a sandboxed container environment.
Details
The code interpreter runs in a sandboxed container that expires after 20 minutes of inactivity. Pricing is $0.03 per container session.
See also
Other openai-tools:
openai_with_tools(),
tool_computer_use(),
tool_file_search(),
tool_mcp(),
tool_web_search()
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"))
)
} # }
