Need Help with "OpenAIClient" Class Not Found Error

Hello everyone,I hope this message finds you well. I recently installed the OpenAI PHP client library from
https://github.com/openai-php/client/tree/mainI used Composer (in tools) for the installation process. However, I’m encountering an issue with the following error message:Class “PHPMaker2023\med\OpenAIClient” not found
I have included the relevant snippet of my code for your reference:

public function rowRendered()
{
    $filedNameContent = $this->id->CurrentValue;  // Arabic content from filed_name
    $apiKey = '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';

    $yourApiKey = getenv($apiKey);

    $openai1 = new OpenAIClient($yourApiKey);

    $result = $openai1->chat()->create([
        'model' => 'gpt-4',
        'messages' => [
            ['role' => 'user', 'content' => 'Hello!'],
        ],
    ]);
    $translatedContent = $result->choices[0]->message->content;
    $this->Trans->ViewValue = $translatedContent;
}

I would appreciate any guidance or assistance in resolving this issue. If anyone has experience with this library or can provide insights into why the “OpenAIClient” class is not being found, I would be grateful for your help.Thank you in advance!Best regards,

Try to adjust this part:

$openai1 = new OpenAIClient($yourApiKey);

to:

$openai1 = new \OpenAIClient($yourApiKey);
1 Like