No assistant found with ID:

My node js program returns no assistant found with id. I’ve double checked the ID and also recreated an assistant and it still says it can’t find it. Anyone knows what’s wrong?

Have you checked your API key too? Also sometimes you may need to pass the organization key on the code.

I’m currently using my Assistant ID on a .env file and passing it as a string to be created like following:

const run = await 
openai.beta.threads.runs.create(threadId, 
{ assistant_id: assistantId }
);
1 Like

I have never touched the organisation ID. I use the api for peronal use. I’ve tried multiple API keys but it’s still not working…

1 Like

Wow, thats weird! Wanna share a code snippet so I can try to help? Maybe it could be something with your account too…

Also, not trying to be to annoying but have you checked if the documentation has something to help? Assistants API Documentation

const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const assistant = await openai.beta.assistants.retrieve(“assitent_id”);
const thread = await openai.beta.threads.create();
const message = await openai.beta.threads.messages.create(thread.id, {
role:“user”,
content:textDescription
});
const run = await openai.beta.threads.runs.create(thread.id, {
assistant_id: assistant.id
});
const assistantResponse = run.choices[0].message.content;
res.json({ description: assistantResponse });

This is part of my code. Do you see any problems here? I’ve already checked the documentation btw.

“assitent_id”

Bruh.

It should be your assistant ID. not “assitent_id” .

I have my actual assistant ID there. I just put that here in the text because I don’t want to share my actual assistant ID. It doesn’t actually say that in my code haha

2 Likes

Ok :laughing:

Have you tried running the thread using the assistant in the playground and then going to make sure your API key is the same?

I’ve tested it in playground yeah. I’m not sure what you mean with the same API key. Playground doesn’t require an API key right?

You are signed in so the authentication is already performed for you.

The idea is to look at your assistant, make sure the ID is the same, then goto your API keys on your account and make sure you are using one of the listed keys.

Yes I have triple checked the assistant ID it is correct. I have also recreated multiple API keys and tested them but it still says this:
error: {
message: “No assistant found with id ‘asst_xxx’.”,
type: ‘invalid_request_error’,
param: null,
code: null
},
code: null,
param: null,
type: ‘invalid_request_error’
}

(asst_xxx is my actual assistant id in my code)

Ok. Create a new message in the playground, take note of the ThreadID and then try and retrieve it using your API.

You should also include your organization ID in the headers of your request in the API and see if it accepts it

(taken from the API reference)

curl [change_me]\
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "OpenAI-Organization: org-tuLbHtz9QdHjHznsmRltLCQQ"

I’m 80% certain this is one of those head-smacking issues that will be glaringly obvious once resolved.

“error: {
message: “No thread found with id ‘thread_Ga66mAY1Tg70In9QGZLrLm3q’.”,
type: ‘invalid_request_error’,
param: null,
code: null
},” It also gives the same error as with the assistant but now with the thread.

I’ve also added the organization ID in the header but that doesn’t change anything

Ok. In your API create a new assistant and save the ID and then see if it shows up in your playgrounds.

Hi, thanks a lot for your help thusfar. Here is the error it gives now when creating an assistant in my js file: “error: {
message: “The requested model ‘gpt-4-1106-preview’ does not exist.”,
type: ‘invalid_request_error’,
param: ‘model’,
code: ‘model_not_found’
},
code: ‘model_not_found’,
param: ‘model’,
type: ‘invalid_request_error’
}”

I’ve also noticed something else which might be the problem. In the error it says: “‘openai-version’: ‘2020-10-01’” Seems to be a very outdated version. I’ve npm uninstalled openai, reinstalled it and updated it but it still gives this version. This is the code I used for testing and creating an assistant inside my code:
"const { OpenAI } = require(‘openai’);

const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });

async function createAssistant() {
const response = await openai.beta.assistants.create({
name: “New Assistant”,
instructions: “You are an assistant to help with general inquiries.”,
model: “gpt-4-1106-preview”
});
return response.data.id; // This is the new assistant’s ID
}

createAssistant().then(assistantId => {
console.log(“Created Assistant ID:”, assistantId);
}).catch(error => {
console.error(“Error creating assistant:”, error);
});
"

Nevermind I think I’ve fixed it. I tried to use the API key directly in the JS file and now it doesn’t give the error anymore. There must’ve been something wrong with my env variable then. Thanks a lot for your help!

2 Likes

same issue I encountered. The problem was definitely in loading the environment variable in my python script. when I directly set my API key in the request, it works fine.

and the real cause of my problem was I have the same environment variable name in my console config file and in my .env in my project file. I had to rename OPENAI_API_KEY to something else in my project .env file

Hi jjkroesb.
You can update assistant in node like this
const assistant = await openai.beta.assistants.update(ASSISTANT_ID, {
name: ASSISTANT_NAME,
instructions: ASSISTANT_DEFAULT_INSTRUCTIONS,
model: ASSISTANT_MODEL,
tools: [{ “type”: “code_interpreter” }],
file_ids: [file_id]
});