Hi guys, I am struggling to understand how to get my function to run as expected. I can get it to run locally, and can get it to build on appwrite cloud, but I think my file structure is wrong or I am missing some package manager step or dependencies or something... first time doing this so not really sure how local and cloud differs. Can anyone give advice on this? Thanks!
I had the function at least executing and logging last night, but now I am getting a weird curl error and have zero visibility into the function itself.
Internal curl error has occurred within the executor! Error Number: 52
Error Code: 500
For context I am doing something like this:
...build payload above
console.log("Constructed messages for OpenAI API:", JSON.stringify(messages, null, 2));
// Initialize OpenAI client
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
// Send request to OpenAI API
console.log("Sending request to OpenAI API...");
const response = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages
});
// Return OpenAI API response
const prompt = response.choices[0]?.message?.content || "No prompt generated";
console.log("OpenAI API response:", prompt);
return res.json({ prompt });
} catch (err) {
console.error("Error occurred during execution:", err.message);
return res.json({ error: "Internal server error", details: err.message });
}
File structure looks like this:
I have the OPENAI_API_KEY set as an env variable, and the only other command I am running is npm install openai what am I missing?!
Recommended threads
- RowList: The value of total is coming as...
RowList: The value of total is coming as a String, so it throws an error because it’s not parsed into an int. Error: TypeError: \"37\": type 'String' is not a ...
- User Blocked - False Positive
Today I tried to log in to my cloud console and it said the user is blocked and I didn't even receive any email regarding this like what kind of violation is my...
- Websocket error Realtime
Hi peeps, I am trying to create realtime updates and I am having websocket error Code is below this msg