dneustadt/openai-client

Client for OpenAI API

0.2.2 2022-11-05 20:03 UTC

This package is auto-updated.

Last update: 2024-11-06 00:43:02 UTC


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

Response Models