Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.
Greg Priday edited this page Jul 7, 2021 · 4 revisions

OpenAI API PHP Wrapper

This is a PHP wrapper for OpenAI's GPT-3 API. It's built on top of GuzzleHTTP.

Installation

You can install the package via composer:

composer require siteorigin/openai-api

Getting Started

Once you have everything installed, you can create a client and start making API calls.

use SiteOrigin\OpenAI\Client;
use SiteOrigin\OpenAI\Engines;
$client = new Client($_ENV['OPENAI_API_KEY']);
$completions = $client->completions(Engines::DAVINCI)->complete("The most important technology for humanity is", [
    'max_tokens' => 32,
    'temperature' => 0.8,
    'n' => 4,
    'stop' => ["\n", '.']
]);

Easy. Now we can dive into all the specific API calls.

Clone this wiki locally