#Nothing happens I dont get a response
1 messages · Page 1 of 1 (latest)
firstly check if the model key is correct, and make sure the try block is correct and compeleted right (you have catch etc) you can show the try block if you want but it could mainly be these issues.
if that doesn't solve anything / you dont find anything please provide the try block so i can see if its a issue in there. Shouldn't have any senestive things.
thx
I have tried changing the keys but it still doesnt work
hmm
try adding a catch block and print the err it catches using console.log
that will help us more finding a solution
try {
const response = await openai.chat.completions.create({
model: process.env.AI_MODEL,
messages: [
{
role: "user",
content: prompt,
},
],
});
console.log("AI response:");
console.log(response.choices[0].message.content);
} catch (error) {
if (error.status === 401 || error.status === 403) {
console.error(
"Authentication error: Check your AI_KEY and make sure it’s valid."
);
} else if (error.status >= 500) {
console.error(
"AI provider error: Something went wrong on the provider side. Try again shortly."
);
} else {
console.error(
"Unexpected error:",
error.message || error
);
}
}
theres already one in here
ok
okay try moving the try block inside a async function example: async function main(){Your try block here } and call main function after (you can name it anything)
like this?
nope still nothing
hm
lets take a differnet approach at the top of your file above everything add a console.log saying something like FILE STARTED! and before calling the main function add a console.log saying going to Main FUNCTION
this way we can see if it even gets to calling the main function in the first place or gets stuck some where else
you can also try adding console.log("AI_KEY set?", Boolean(process.env.AI_KEY));
console.log("AI_URL:", process.env.AI_URL);
console.log("AI_MODEL:", process.env.AI_MODEL); before the try catch in the main function
If AI_KEY set? is false or AI_URL/AI_MODEL is undefined, that’s why the request never succeeds.
ok i added the logs i still dont get any response in console what could be the issue
wait so you dont get file started?
nope
wow thats a weird problem
do you know how run the file manually instead of using run button like using the built in terminial in Scrimba?
no
run 'node index.js' in the terminal and go back to see in console to see if anything logs
last thing i suggest doing is add a random thing at the top like wqklfhkfqlkfq, and if you still dont get any outputs in the console that means the file itself is not running somehow
as you said the api/ai things are correct, atleast with what i reviewed i think it is a Scrimba issue. since the file doesn't even run like you said.
heres the result im getting
also if your goal is groq? why dont you use the offical link not by openrouter..
Okay so i think its because your using openrouter try using the offical link
the solution i posted before didnt work for me so i removed it.
whats the official link ?
then a api key from the offical dev page, you can go to the website console.groq.com to create a account and get a api key and it should.. work
im using open router right now