Download the PHP package wmwgijol28/openai-php without Composer
On this page you can find all versions of the php package wmwgijol28/openai-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package openai-php
OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API, forked from https://github.com/openai-php/client
Table of Contents
- Get Started
- Usage
- Models Resource
- Completions Resource
- Chat Resource
- Audio Resource
- Edits Resource
- Embeddings Resource
- Files Resource
- FineTunes Resource
- Moderations Resource
- Images Resource
- Testing
- Services
- Azure
Get Started
Requires PHP 7.3+
First, install OpenAI via the Composer package manager:
Ensure that the php-http/discovery
composer plugin is allowed to run or install a client manually if your project does not already have a PSR-18 client integrated.
Then, interact with OpenAI's API:
If necessary, it is possible to configure and create a separate client.
Usage
Models
Resource
list
Lists the currently available models, and provides basic information about each one such as the owner and availability.
retrieve
Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
delete
Delete a fine-tuned model.
Completions
Resource
create
Creates a completion for the provided prompt and parameters.
create streamed
Creates a streamed completion for the provided prompt and parameters.
Chat
Resource
create
Creates a completion for the chat message.
created streamed
Creates a streamed completion for the chat message.
Audio
Resource
transcribe
Transcribes audio into the input language.
translate
Translates audio into English.
Edits
Resource
create
Creates a new edit for the provided input, instruction, and parameters.
Embeddings
Resource
create
Creates an embedding vector representing the input text.
Files
Resource
list
Returns a list of files that belong to the user's organization.
delete
Delete a file.
retrieve
Returns information about a specific file.
upload
Upload a file that contains document(s) to be used across various endpoints/features.
download
Returns the contents of the specified file.
FineTunes
Resource
create
Creates a job that fine-tunes a specified model from a given dataset.
list
List your organization's fine-tuning jobs.
retrieve
Gets info about the fine-tune job.
cancel
Immediately cancel a fine-tune job.
list events
Get fine-grained status updates for a fine-tune job.
list events streamed
Get streamed fine-grained status updates for a fine-tune job.
Moderations
Resource
create
Classifies if text violates OpenAI's Content Policy.
Images
Resource
create
Creates an image given a prompt.
edit
Creates an edited or extended image given an original image and a prompt.
variation
Creates a variation of a given image.
Testing
The package provides a fake implementation of the OpenAI\Client
class that allows you to fake the API responses.
To test your code ensure you swap the OpenAI\Client
class with the OpenAI\Testing\ClientFake
class in your test case.
The fake responses are returned in the order they are provided while creating the fake client.
All responses are having a fake()
method that allows you to easily create a response object by only providing the parameters relevant for your test case.
In case of a streamed response you can optionally provide a resource holding the fake response data.
After the requests have been sent there are various methods to ensure that the expected requests were sent:
To write tests expecting the API request to fail you can provide a Throwable
object as the response.
Services
Azure
In order to use the Azure OpenAI Service, it is necessary to construct the client manually using the factory.
To use Azure, you must deploy a model, identified by the {deployment-id}, which is already incorporated into the API calls. As a result, you do not have to provide the model during the calls since it is included in the BaseUri
.
Therefore, a basic sample completion call would be:
OpenAI PHP is an open-sourced software licensed under the MIT license.
All versions of openai-php with dependencies
php-http/discovery Version ^1.18.1
php-http/multipart-stream-builder Version ^1.3.0
psr/http-client Version ^1.0.2
psr/http-client-implementation Version ^1.0.1
psr/http-factory-implementation Version *
psr/http-message Version ^1.0.1|^2.0.0