dneustadt / openai-client
Client for OpenAI API
0.2.2
2022-11-05 20:03 UTC
Requires
- php: >=7.2
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.12
- phpunit/phpunit: ^8.0 || ^9.0
- symfony/dotenv: ^6.0
README
OpenAI is an AI research and deployment company. Our mission is to ensure that artificial general intelligence benefits all of humanity.
Installation & Usage
Requirements
PHP 7.2 and later.
Composer
To install via Composer:
composer require dneustadt/openai-client
Getting Started
Please follow the installation procedure and then run the following:
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure API key authorization: api_key $config = OpenAI\Client\Configuration::getDefaultConfiguration()->setApiKey('Authorization', 'YOUR_API_KEY'); $apiInstance = new OpenAI\Client\Api\AnswerApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $open_ai_organization = 'open_ai_organization_example'; // optional $answer_payload = new \OpenAI\Client\Model\AnswerPayload(); // \OpenAI\Client\Model\AnswerPayload try { $result = $apiInstance->postAnswer($open_ai_organization, $answer_payload); print_r($result); } catch (Exception $e) { echo 'Exception when calling AnswerApi->postAnswer: ', $e->getMessage(), PHP_EOL; }
API Endpoints
All URIs are relative to https://api.openai.com/v1
Models
Request Payloads
- AnswerPayload
- ClassificationPayload
- CompletionPayload
- ImagesGenerationsPayload
- SearchPayload
- EmbeddingsPayload
- FineTunesPayload
- ModerationsPayload