Download the PHP package ruscoe/openai-php without Composer

On this page you can find all versions of the php package ruscoe/openai-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package openai-php

PHP library for the OpenAI API

An unofficial library for OpenAI's API.

release

Requirements

Quick set up

git clone [email protected]:ruscoe/openai-php.git

cd openai-php

composer install

Usage examples

The following examples assume you store your API key in an environment variable. To do this on a Linux or MacOS system, run:

export OPENAI_API_KEY=sk-XA0yN...

Be sure to substitute your own API key after OPENAI_API_KEY=.

Completions

This example asks the gpt-3.5-turbo model to describe a keyboard. It instructs the OpenAI API to use more than the default number of tokens so a reasonable length description can be returned.

The response:

Chat

This example sends a simple chat message.

The response:

Images

Create image

This example asks for two images of a red six-sided dice in water.

The response

img-OFmHrZWgvmnGmizogrqP5SGv img-9O0Nv8GCurUr86pzzkv4dlJE

Create image variation

The source and response

variation variation1

Create image edit

The source and response

edit edit_mask edit1

Fine-tuning a model

First, take a look at the official documentation on fine-tuning.

Create and upload your training file. Example:

training.jsonl

List your files to get the file ID:

Create a new training job using the file ID you've obtained:

List models to get the name of your new fine-tuned model:

The model name will start with curie:ft and end with the current date and time.

Create a new completion using your fine-tuned model.

The response should include "animal".

The response should include "rock".

Available functions

Models

Class Function Description
OpenAIModels getModels Gets available OpenAI models.
OpenAIModels getModel Gets a specific OpenAI model.

Completions

Class Function Description
OpenAICompletions create Creates one or more completions from a given input.

Chat

Class Function Description
OpenAIChat create Creates one or more completions from a chat conversation.

Edits

Class Function Description
OpenAIEdits create Performs an edit on a given input.

Images

Class Function Description
OpenAIImages createAsURL Generates a number of images and returns URLs.
OpenAIImages createAsBase64 Generates a number of images and returns Base64 encoded image(s).
OpenAIImages createVariationAsURL Generates a number of image variations and returns URL(s).
OpenAIImages createVariationAsBase64 Generates a number of image variations and returns Base64 encoded image(s).
OpenAIImages createVariation Generates a number of image variations from a given image.
OpenAIImages createEditAsURL Generates a number of image edits and returns URL(s).
OpenAIImages createEditAsBase64 Generates a number of image edits and returns Base64 encoded image(s).
OpenAIImages createEdit Generates a number of image edits from a given image.

Embeddings

Class Function Description
OpenAIEmbeddings create Creates an embedding vector from given input.

Audio

Class Function Description
OpenAIAudio transcribe Transcribes text from an audio file.

Files

Class Function Description
OpenAIFiles getFiles Gets files owned by the user's organization.
OpenAIFiles uploadFile Uploads a file.
OpenAIFiles deleteFile Deletes a file.
OpenAIFiles getFile Gets information about a file.
OpenAIFiles getFileContent Gets the content of a file.

Fine-Tunes

Class Function Description
OpenAIFineTunes create Creates a fine-tune job.
OpenAIFineTunes getFineTunes Gets existing fine-tunes.
OpenAIFineTunes cancelFineTune Cancels a fine-tune job.
OpenAIFineTunes getFineTuneEvents Gets status updates of a fine-tune job.
OpenAIFineTunes deleteModel Deletes a fine-tuned model.

Moderations

Class Function Description
OpenAIModerations create Requests a moderation result from OpenAI.

License

MIT


All versions of openai-php with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
guzzlehttp/guzzle Version ^7.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ruscoe/openai-php contains the following files

Loading the files please wait ....