const aiFeedbackOnReport = async (req, res) => { const url = process.env.AI_API_ENDOINT; const api_key = process.env.AI_API_KEY; const payload = { "model": "gpt-4o-mini", "messages": [{ "role": "user", "content": JSON.stringify(req.body.score) + " - is the students report card. " + req.body.instruction }] } try { const apiResponse = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${api_key}`, // 'Authorization': api_key, }, body: JSON.stringify(payload) }); if (!apiResponse.ok) { return res.status(apiResponse.status).send({ error: 'API response was not ok'+res }); } const data = await apiResponse.json(); res.send(data); } catch (error) { console.error('Error fetching data:', error); res.status(500).send({ error: 'Something went wrong with the fetch operation' }); } } module.exports = aiFeedbackOnReport;