Building AI APIs With Node.js (opens in new tab)
Here's an endpoint that looks completely fine: routes/chat.ts import OpenAI from "openai"; const openai = new OpenAI(); app.post("/api/chat", async (req, res) => { const completion = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: req.body.messages, }); res.json(completion.choices[0].message); }); It compiles. It works in the demo. Your PM clicks the button, the answer shows up a few seconds later, everyone claps. Then it ships, and the cracks show up one at a time. Use...
Read the original article