I created platform.openai.com assistant and trying to access it from postman.
POST: https://api.openai.com/v1/assistants/{assistant-id}/completions
Body:
{
"prompt": "Tell me a funny daddy joke about computers.",
"max_tokens": 60
}
Headers:
Authorization : Bearer API_KEY
Content-Type : application/json
OpenAI-Beta : assistans=V1
And getting response 404 Not found
{
"error": {
"message": "Invalid URL (POST /v1/assistants/asst_EKb5utNB3oVKBHsZusxKKijO/completions)",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
If I try https://api.openai.com/v1/assistants/{assistant-id}
Body : {}
I get all my assistant info. So it means my authorization works, but where is the problem with first approach?
I expect to get answer to my request.
You don’t understand how assistants work. It’s not that straightforward. You missed a lot of steps.
The following are steps you need to follow to get an answer from the assistant:
STEP 1: Create an Assistant
POST https://api.openai.com/v1/assistants
STEP 2: Create a Thread
POST https://api.openai.com/v1/threads
STEP 3: Add a Message to a Thread
POST https://api.openai.com/v1/threads/{thread_id}/messages
STEP 4: Run the Assistant
POST https://api.openai.com/v1/threads/{thread_id}/runs
STEP 5: Periodically retrieve the Run to check on its status to see if it has moved to completed
GET https://api.openai.com/v1/threads/{thread_id}/runs/{run_id}
STEP 6: Retrieve the Messages added by the Assistant to the Thread
GET https://api.openai.com/v1/threads/{thread_id}/messages
The following image from the official OpenAI documentation is a nice visual example of how assistants work.
Also, I’ve made a YouTube tutorial on how to use the Assistants API and posted the code on my GitHub profile.
Can you provide a linke to the API documetastion for this usage of
completions
?