Error while adding openAI provider

Created on 22 December 2024, 6 months ago

Hello,

I'm trying this module. I stored a new OpenAI key, but when I added it and clicked on "Save Configuration," I got this error:

The website encountered an unexpected error. Try again later.
Error: Class "OpenAI" not found in Drupal\ai_provider_openai\Form\OpenAiConfigForm->validateForm() (line 106 of modules/ai_provider_openai/src/Form/OpenAiConfigForm.php).

thank you for your help

🐛 Bug report
Status

Active

Version

1.0

Component

User interface

Created by

🇲🇦Morocco lakhal

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @lakhal
  • 🇮🇳India anjaliprasannan

    I encountered the same issue as well. To resolve it, I ran
    composer require openai-php/client
    to install the required OpenAI PHP SDK, followed by drush cr to rebuild the Drupal cache. This fixed the error, and the OpenAI provider was successfully added.

  • 🇬🇧United Kingdom MrDaleSmith

    I can only assume you didn't install through composer, or else had some kind of composer error whilst installing, but I cannot recreate thios issue and the required library is listed in the composer.json file for both versions, so I'm going to close this as works as designed.

Production build 0.71.5 2024