Hey there, I’m setting up the Assistant API to work in my custom app. I just wanted to double-check I’m doing everything in the right order based off of the cURL documentation: https://platform.openai.com/docs/api-reference/assistants
First, I set up the initial code:
curl https://api.openai.com/v1/threads/runs \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-H "OpenAI-Beta: assistants=v2" \
-d '{
"assistant_id": "asst_abc123",
"thread": {
"messages": [
{"role": "user", "content": "Explain deep learning to a 5 year old."}
]
}
}'
I’m pretty certain this is all working because I do get the initial response with all the id information, and my real-time user input system was working with the regular version of ChatGPT before I decided to switch to Assistants API as shown in the screenshot below:
Next, I start by creating the thread and run (following the section “Create thread and run”)
Then, I create message by extracting the thread and run id and putting them together into new url like here (following the “Create message section”)
Next, I retrieve the run again using the id strings to create the final url (following the “Retrieve run” section)
But, instead of getting the AI’s response to the user’s input, it gives me this error repeatedly: https://api.openai.com/v1/threads/invalid_value/runs/messageInvalid'thread_id': 'invalid_value. Expected an ID that begins with 'thread'.
But the link I generated does have the thread id just like how the documentation shows it to be.
Am I doing this process in the wrong order, or am I missing some steps?
Here’s a breakdown of the API call flow you’ll need when using CURL directly with OpenAI’s Assistants API, especially when handling file uploads and vector stores, optional, but we’ll start with that first:
Upload Files
Endpoint:POST https://api.openai.com/v1/files
Purpose: Upload your files with "purpose": "assistants".
Polling: Not required here; the file upload returns immediately with a file ID.
Thanks for the help! I was able to figure everything out thanks in no small part to your help. I’m connecting Open AI Assistants to Unreal Engine using the Varest plugin and I’ve now got everything working!