Create Assistant API Request [ 2023 ]
Create Assistant API Request
This tutorial will teach us how to create an AI Assistant using the Create Assistant API request. We will use the Python programming language and Spyder IDE.
Pre-requisites
Assistant API Request
In this example, we’re creating an Assistant that is a GPT-4 model with the Code Interpreter tool enabled. The Python code to create a new AI assistant using the API call is as follows:
Code:
“””
Create Assistant API Request
— Python OpenAI SDK
— OpenAI Tutorials — www.TestingDocs.com
“””
from openai import OpenAI
client = OpenAI()
try:
assistant = client.beta.assistants.create(
name=”TestingDocs Assistant”,
instructions=”A helpful code assistant”,
tools=[{“type”: “code_interpreter”}],
model=”gpt-4-turbo-preview”,
)
except Exception:
print(“An error occurred”)
else:
print(“Assistant created successfully”,assistant)
finally:
pass
This will create a new assistant. The model picked was gpt-4-turbo, and we have enabled the Code Interpreter tool. We can enable the following tools :
- Code Interpreter
- Retrieval
- Function calling
Verification
To verify and cross-check, log in to the OpenAI Platform. Click on the left navigation Assistants tab.
We can see that the assistant was successfully created.
That’s it.
—
OpenAI API Tutorials
OpenAI tutorials on this website can be found at:
OpenAI website