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
- Enabling Overage Usage
Hello Appwrite Support Team, I am currently using Appwrite under the GitHub Student Developer Pack plan. Recently, my project hit the database read limit, and ...
- appwrite-docs MCP fails in Cursor — SSE ...
Hi team, I'm having trouble getting the hosted Appwrite docs MCP working in Cursor on Windows. Environment IDE: Cursor (latest) OS: Windows 11 Node: v24.15.0 ...
- Migration from Cloud to Self-Hosted not ...
Hello Appwrite Community, I've got the problem, that when I try to migrate my Appwrite Project from the cloud to my self-hosted Appwrite, that an API Key is mi...