250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- node.js
- solidity
- API
- nextJS
- CLASS
- Redux
- REACT
- Props
- bitcoin
- built in object
- typeScript
- blockchain
- evm
- web
- JavaScript
- 기준
- SSR
- tailwindcss
- middleware
- graphQL
- hardhat
- 삶
- concept
- HTML
- CSS
- Ethereum
- Interface
- express.js
- useState
- error
Archives
- Today
- Total
ReasonJun
OpenAI V4 : Module '"openai"' has no exported member 'Configuration'. Did you mean to use 'import Configuration from "openai"' instead? 본문
카테고리 없음
OpenAI V4 : Module '"openai"' has no exported member 'Configuration'. Did you mean to use 'import Configuration from "openai"' instead?
ReasonJun 2023. 9. 15. 12:47728x90
OpenAI NodeJS SDK v4 was released on August 16, 2023, and is a complete rewrite of the SDK.
If you install V4 and apply the grammar from V3, you'll get the error above.
https://platform.openai.com/docs/api-reference/chat
The above is the official Openai api documentation, but there is no update as of (2023.09.15) on how to use 4.0.0. (Am I missing something?)
Anyway, I googled it and here's what I found.
// Old
import { Configuration, OpenAIApi } from "openai";
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
// New
import OpenAI from 'openai';
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
It is said to have been upgraded from version 3 with the following changes.
What's new
- Streaming support for completions and chat completions!
- Automatic retries (defaults to 2)
- Improved typescript types for responses & errors
- Support for ESM, cloudflare workers, vercel edge functions, deno
- Improved latency through reusing TCP connections
- Simpler initialization logic
https://github.com/openai/openai-node/discussions/182
Migration Guide
https://github.com/openai/openai-node/discussions/217
728x90
Comments