Download the PHP package ze/openai-php without Composer
On this page you can find all versions of the php package ze/openai-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ze/openai-php
More information about ze/openai-php
Files in ze/openai-php
Package openai-php
Short Description OpenAI GPT-3 Api Client in PHP
License MIT
Homepage https://github.com/zyz954489346/opanai-php
Informations about the package openai-php
OpenAI GPT-3 Api Client in PHP
Fork from orhanerday/open-ai
Add http exception catching Add curl prox supportRequires PHP 7.4+
Update Record
date | features |
---|---|
2023-04-12 | - add support to Azure OpenAI API |
Endpoint Support
- Chat
- [x] ChatGPT API
- Models
- [x] List models
- [x] Retrieve model
- Completions
- Edits
- [x] Create edits
- Images
- [x] Create image
- [x] Create image edit
- [x] Create image variation
- Embeddings
- Files
- [x] List files
- [x] Upload file
- [x] Delete file
- [x] Retrieve file
- [x] Retrieve file content
- Fine-tunes
- Moderation
Engines(deprecated)
Installation
You can install the package via composer:
Quick Start
Before you get starting, you should set OPENAI_API_KEY as ENV key, and set OpenAI key as env value with the following commands;
Powershell
Cmd
Linux or macOS
Getting issues while setting up env? Please read the article or you can check my StackOverflow answer for the Windows® ENV setup.
Create your index.php
file and paste the following code part into the file.
Run the server with the following command
Usage
Load your key from an environment variable.
According to the following code
$open_ai
is the base variable for all open-ai operations.
Requesting organization
For users who belong to multiple organizations, you can pass a header to specify which organization is used for an API request. Usage from these API requests will count against the specified organization's subscription quota.
``
Custom URL
You can specify Origin URL with the third parameter of the OpenAI constructor method;
``
Chat (as known as ChatGPT API)
Given a chat conversation, the model will return a chat completion response.
Completions
Given a prompt, the model will return one or more predicted completions, and can also return the probabilities of alternative tokens at each position.
Stream Example
This feature might sound familiar from ChatGPT.
Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.
``
Add this part inside <body>
of the HTML
``
You should see a response like the in video;
Edits
Creates a new edit for the provided input, instruction, and parameters
Images (DALL·E)
All DALL·E Examples available in this repo.
Given a prompt, the model will return one or more generated images as urls or base64 encoded.
Create image
Creates an image given a prompt.
Create image edit
Creates an edited or extended image given an original image and a prompt.
You need HTML upload for image edit or variation? Please check DALL·E Examples
``
Create image variation
Creates a variation of a given image.
``
Searches
(Deprecated)
This endpoint is deprecated and will be removed on December 3rd, 2022 OpenAI developed new methods with better performance. Learn more.
Given a query and a set of documents or labels, the model ranks each document based on its semantic similarity to the provided query.
Embeddings
Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
Related guide: Embeddings
Create embeddings
Answers
(Deprecated)
This endpoint is deprecated and will be removed on December 3rd, 2022 We’ve developed new methods with better performance. Learn more.
Given a question, a set of documents, and some examples, the API generates an answer to the question based on the information in the set of documents. This is useful for question-answering applications on sources of truth, like company documentation or a knowledge base.
Classifications
(Deprecated)
This endpoint is deprecated and will be removed on December 3rd, 2022 OpenAI developed new methods with better performance. Learn more.
Given a query and a set of labeled examples, the model will predict the most likely label for the query. Useful as a drop-in replacement for any ML classification or text-to-label task.
Content Moderations
Given a input text, outputs if the model classifies it as violating OpenAI's content policy.
Know more about Content Moderations here: OpenAI Moderations
List engines
(Deprecated)
The Engines endpoints are deprecated. Please use their replacement, Learn more.
Lists the currently available engines, and provides basic information about each one such as the owner and availability.
Files
Files are used to upload documents that can be used across features like Answers, Search, and Classifications
List files
Returns a list of files that belong to the user's organization.
Upload file
Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Please contact OpenAI if you need to increase the storage limit.
Upload file with HTML Form
Delete file
Retrieve file
Retrieve file content
Fine-tunes
Manage fine-tuning jobs to tailor a model to your specific training data.
Create fine-tune
List fine-tune
Retrieve fine-tune
Cancel fine-tune
List fine-tune events
Delete fine-tune model
Retrieve engine
(Deprecated)
Retrieves an engine instance, providing basic information about the engine such as the owner and availability.
Models
List and describe the various models available in the API.
List models
Lists the currently available models, and provides basic information about each one such as the owner and availability.
Retrieve model
Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
Printing results i.e. $search
Testing
To run all tests:
To run only those tests that work for most user (exclude those that require a missing folder or that hit deprecated endpoints no longer available to most users):
License
The MIT License (MIT). Please see License File for more information.
All versions of openai-php with dependencies
ext-curl Version *
ext-json Version *