Nitro with openai-node
You can migrate from OAI API or Azure OpenAI to Nitro using your existing NodeJS code quickly
The ONLY thing you need to do is to override
baseURL
inopenai
init withNitro
URL
- NodeJS OpenAI SDK: https://www.npmjs.com/package/openai
Chat Completion
Engine | Typescript Code |
Nitro |
|
OAI |
|
Azure OAI |
|
Resource:
Embedding
Engine | Embedding |
Nitro |
|
OAI |
|
Azure OAI |
|
Audio
Coming soon
How to reproduce
Step 1: Dependencies installation
npm install --save openai typescript
# or
yarn add openai
Step 2: Fill tsconfig.json
{
"compilerOptions": {
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"target": "es2020",
"lib": ["es2020"],
"module": "commonjs",
},
"lib": ["es2015"]
}
Step 3: Fill index.ts
file with code.
Step 4: Build with npx tsc
.
Step 5: Run the code with node dist/index.js
.