DEV Community

Building AI APIs With Node.js (opens in new tab)

Discussed on DEV

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
Sign in to keep reading the full article.

Keyboard Shortcuts

Navigation

Next / previous post
j/k
Open post
oorEnter
Preview post
v

Post Actions

Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Save / unsave
s

Recommendations

Add interest / feed
Enter
Not interested
x

Go to

Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Discover
gb
Search
/

General

Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help