How to use ChatGPT Code Interpreter through API?
When this works "https://chat.openai.com/?model=gpt-4-code-interpreter"
this returns an error "there are no such model":
response = openai.Completion.create(
engine="code-interpreter", # gpt-4-code-interpreter
prompt=final_prompt,
temperature=0,
max_tokens=150,
top_p=1.0,
frequency_penalty=0.0,
presence_penalty=0.0,
stop=["#", ";"]
)
UPDATE: April 2024
The OpenAI Assistants API v2
has been released. See the migration guide.
UPDATE: November 2023
The Code Interpreter tool is now available through the OpenAI Assistants API v1
, as stated in the official OpenAI documentation:
Code Interpreter allows the Assistants API to write and run Python code in a sandboxed execution environment. This tool can process files with diverse data and formatting, and generate files with data and images of graphs. Code Interpreter allows your Assistant to run code iteratively to solve challenging code and math problems. When your Assistant writes code that fails to run, it can iterate on this code by attempting to run different code until the code execution succeeds.
I created a personal math tutor and made a YouTube tutorial about it. It's a tutorial on how to use the Assistants API with the Code Interpreter tool.
As the error says, the Code Interpreter API doesn't exist as of today.
See the list of all OpenAI models in the official OpenAI documentation.
Also, there's a discussion on the official OpenAI forum.