stefano
stefano8mo ago

"use node" in tutorial

https://docs.convex.dev/tutorial/actions
"use node";
import OpenAI from "openai";

// Initialize the OpenAI client with the given API key
const apiKey = process.env.OPENAI_API_KEY!;
const openai = new OpenAI({ apiKey });`
"use node";
import OpenAI from "openai";

// Initialize the OpenAI client with the given API key
const apiKey = process.env.OPENAI_API_KEY!;
const openai = new OpenAI({ apiKey });`
is there a particular reason why you guys used "use node" in this example? I read the attached links about Convex runtime but also understood that the OpenAI package can be run in the default Convex Runtime, so wouldn't it better not to write "use node"?
2 Replies
Michal Srb
Michal Srb8mo ago
The tutorial was written almost a year ago. The Convex runtime has been improved a lot since and for the OpenAI library "use node" is no longer required. Still a good thing to know that the option of choosing Node.js is there when you need it. We'll think through how to update the tutorial.
stefano
stefanoOP8mo ago
ok cool!

Did you find this page helpful?