So I’ve been going back and forth through the forums for the past 2 weeks and still haven’t been able to solve my issue.
I’m trying to create an assistant using “Assistants API”, the message part works fine, but running a thread is a pain and always responds with “Error running the assistant: 400 Client Error: Bad Request for url:”
Here’s my code, after of course creating the assistant, the thread and the message:
Headers = {
'Authorization': 'Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'Content-Type': 'application/json',
'OpenAI-Beta': 'assistants=v2'
}
Thread_Id = "thread_7hJY7anghFlp0qECNbpkaxWd"
#== Running The Assistant ==
Instructions = "Please address the user as James Bond"
Run_Url = f"v1/threads/{Thread_Id}/runs"
try:
Run_Response = Req.post(
Run_Url,
headers = Headers,
json={
"instructions": Instructions,
}
)
Run_Response.raise_for_status()
Run = Run_Response.json()
except Req.exceptions.RequestException as e:
Log.error(f"Error running the assistant: {e}")
raise
I still get the same response if I use something like this:
try:
Run = Client.beta.threads.runs.create(
thread_id = Thread_Id,
assistant_id = Assistant_Id,
instructions = Instructions,
)
except Exception as e:
Log.error(f"Error Running The Assistant: {e}")
Hope this helps, and thanks in advance!