I created an assistant which works fine in playground, but can’t be called with the API, this error returns: “{ “error”: { “message”: “The model asst_NCwjfco9w3wegUA7JZzH6P6Q does not exist or you do not have access to it.”, “type”: “invalid_request_error”, “param”: null, “code”: “model_not_found” } }”. Anyone any idea’s?. This is the code that was suggested to use bij ChatGPT:
import openai
import os
Verkrijg de API-sleutel uit de omgevingsvariabele
openai.api_key = os.getenv(‘OPENAI_API_KEY’)
Gebruik de juiste assistant ID voor je eigen gemaakte assistant
response = openai.ChatCompletion.create(
model=“asst_NCwjfco9w3wegUA7JZzH6P6Q”, # Je eigen assistant ID
messages=[
{“role”: “system”, “content”: “You are a healthcare professional making suggestions to improve or support the quality of life.”},
{“role”: “user”, “content”: “Hoe kan ik de OpenAI API gebruiken?”}
]
)
Toon de response in de terminal
print(“Response from MyFirstAssistant:”, response[‘choices’][0][‘message’][‘content’])
Hi,
asst_… is the unique identifier for an API assistant, none related to a chat completion or a model name. Instead of this, try with a string like gpt-4o or gpt-4o-mini for the model.
Instead, your “custom AI” can just be system message instructions, with Chat Completions - written properly.
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{
"role": "system",
"content": "You are a creative writer"
},
{
"role": "user",
"content": "Hi!" # This shows sending past turns again
}
{
"role": "assistant", # and the past AI response gives "memory"
"content": "Hello there! I’m your friendly creative writer bot."
}
{
"role": "user",
"content": "Produce a short poem. Subject: turtles."
}
],
temperature=.8, top_p=.8, max_completion_tokens=1000
)
print(response.choices[0].message.content)
…and then receive your requested output.
In emerald shells, they slowly glide, Through sunlit waves, where secrets hide. Ancient travelers, wise and slow, With stories whispered in ebb and flow.
…
Can someone help me how to resolve this issue. I created a custom assistant and it works fine in playground. But it fails when I am trying to call it from API. The error message is below:
“The model ‘asst_****’ does not exist or you do not have access to it.”
I checked all prelim check list to confirm I am calling the right one. And all are good. Except I am failing to call it from API.
Try to reach the support, still waiting on their reply. ( I felt it is live support. But unfortunately it is not and slow in responding;()
Check that your key is for the the same project. And that your key has the right rights.
You might have different accounts / projects. Check the drop down in the top left?
Thanks for responding.
I did check that and it looks good. But I have a solution from another thread that we should make API calls to consume custom assistants differently unlike models.