How do you implement OpenAI GPT-3 Api Client in PHP?

Viewed 22

I need help understanding the vague instructions on https://packagist.org/packages/orhanerday/open-ai

I downloaded the package from https://github.com/orhanerday/open-ai

I installed the package by running "composer require orhanerday/open-ai" in my Command Prompt

Instructions stop making sense from there.....

What does the "use Orhanerday\OpenAi\OpenAi;" code mean and where is it applied? Am I to create a php file say index.php with content:

<?php

use Orhanerday\OpenAi\OpenAi;

$complete = $open_ai->complete([

   'engine' => 'davinci',
   'prompt' => 'Hello',
   'temperature' => 0.9,
   'max_tokens' => 150,
   'frequency_penalty' => 0,
   'presence_penalty' => 0.6,
]
?>

how and where do I add my api key? Do I create a file Orhanerday\OpenAi\OpenAi.php and enter my api key there? i.e. OPENAI_API_KEY=sk-**********************************************

Thanks for you assistance

0 Answers
Related