Getting an error when importing Configuration and OpenAIApi from 'openai'

Hello!
I’m trying to run the quickstart from the openai tutorial page in my next js 13 app and keep getting the following error:

  • warn ./app/api/chat/route.js
    Attempted import error: ‘Configuration’ is not exported from ‘openai’ (imported as ‘Configuration’).
    Import trace for requested module:
    ./app/api/chat/route.js
    ./app/api/chat/route.js
    Attempted import error: ‘OpenAIApi’ is not exported from ‘openai’ (imported as ‘OpenAIApi’).
    Import trace for requested module:
    ./app/api/chat/route.js

Is Configuration and OpenAIApi no longer imported from ‘openai’?

1 Like

Are you using openai v4? v4 had a number of significant changes, including no more Configuration class.

See the migration guide: v3 to v4 Migration Guide · openai/openai-node · Discussion #217 · GitHub

3 Likes

Yes I am using v4. That would explain it, thanks!

This is work thank you so much! :heart_eyes:

Thank you. in v3 Configuration is working :+1::+1: