Fix: Add better API error handling and logging

This commit is contained in:
2025-12-17 09:11:56 -08:00
parent 1a1d50a79d
commit df97ff97b9

View File

@@ -28,6 +28,10 @@ const apiCall = async (prompt, model, temp, effort) => {
},
{ headers: { Authorization: `Bearer ${process.env.OPENROUTER_KEY}` } }
);
if (!res.data.choices || !res.data.choices[0]) {
console.error('API Response:', JSON.stringify(res.data, null, 2));
throw new Error('Invalid API response structure');
}
return res.data.choices[0].message.content;
};