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
- Local Serverless Function Testing: Are D...
I have followed the instructions to get the CLI working, and have been able to log-in, initialize my project, and created a simple Python function, which calls ...
- Update user email using OTP
Hi, I am trying to implement email update using OTP, there is not password associated with the account. One solution I found online is creating appwrite functio...
- Magic Link token automatically consumed
Hi, I'm using the Magic Link auth system with Appwrite Cloud and I'm running into huge issues getting users to log in successfully. About 9 times out of 10, th...