Download the PHP package orhanerday/open-ai without Composer

On this page you can find all versions of the php package orhanerday/open-ai. 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 open-ai

OpenAI API Client in PHP



ChatGPT API is currently supported, click here for the implementation introductions.


A message from creator,
Thank you for visiting the @orhanerday/open-ai repository! If you find this repository helpful or useful, we encourage you to star it on GitHub. Starring a repository is a way to show your support for the project. It also helps to increase the visibility of the project and to let the community know that it is valuable. Thanks again for your support and we hope you find the repository useful!

Orhan



Latest Version on Packagist Total Downloads





Featured in

Jetbrains Blog

Laravel News

日思录

logo_new

Comparison With Other Packages

Project Name Required PHP Version (Lower is better) Description Type (Official / Community) Support
orhanerday/open-ai PHP 7.4+ Most downloaded, forked, contributed, huge community supported, and used PHP SDK for OpenAI GPT-3 and DALL-E. It also supports chatGPT-like streaming. Community Available, (Community driven Discord Server or personal mail [email protected])
openai-* /c****t PHP 8.1+ OpenAI PHP API client. Community -


About this package

Fully open-source and secure community-maintained, PHP SDK for accessing the OpenAI GPT-3 API.

For more information, you can read laravel news blog post.

Free support is available. Join our discord server

To get started with this package, you'll first want to be familiar with the OpenAI API documentation and examples. Also you can get help from our discord channel that called #api-support

News

Requires PHP 7.4+

Join our discord server

Discord Banner 2

Click here to join the Discord server

Support this project

As you may know, OpenAI PHP is an open-source project wrapping tool for OpenAI. We rely on the support of our community to continue developing and maintaining the project, and one way that you can help is by making a donation.

Donations allow us to cover expenses such as hosting costs(for testing), development tools, and other resources that are necessary to keep the project running smoothly. Every contribution, no matter how small, helps us to continue improving OpenAI PHP for everyone.

If you have benefited from using OpenAI PHP and would like to support its continued development, we would greatly appreciate a donation of any amount. You can make a donation through;

Thank you for considering a donation to Orhanerday/OpenAI PHP SDK. Your support is greatly appreciated and helps to ensure that the project can continue to grow and improve.

Sincerely,

Orhan Erday / Creator.

Documentation

Please visit https://orhanerday.gitbook.io/openai-php-api-1/

Endpoint Support

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

NVIDIA NIM INTEGRATION

orhanerday/open-ai supports Nvidia NIM. The below example is MixtralAI. Check https://build.nvidia.com/explore/discover for more examples.

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.

``

Base URL

You can specify Origin URL with setBaseURL() method;

``

Use Proxy

You can use some proxy servers for your requests api;

``

Set header

Get cURL request info

!!! WARNING:Your API key will expose if you add this method to your code, therefore remove the method before deployment. Be careful !

You can get cURL info after the request.

``

Chat (as known as ChatGPT API)

Given a chat conversation, the model will return a chat completion response.

Accessing the Element

Related: ChatGPT Clone Project

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.


ChatGPT Clone Project

Video of demo:

https://user-images.githubusercontent.com/22305274/219878695-c76a58c0-5081-402c-a1b5-2b1fd971735a.mp4

ChatGPT clone is a simple web application powered by the OpenAI library and built with PHP. It allows users to chat with an AI language model that responds in real-time. Chat history is saved using cookies, and the project requires the use of an API key and enabled SQLite3.

Url of The ChatGPT-Clone Repo https://github.com/orhanerday/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;

https://user-images.githubusercontent.com/22305274/209847128-f72c9345-dd34-46f0-bbc5-daf1d7b6121f.mp4

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.

Audio

Text To Speech (TTS)

Create Transcription

Transcribes audio into the input language.

Response

Create Translation

Translates audio into English.

I use Turkish voice for translation thanks to famous science YouTuber Barış Özcan

Response

Need HTML upload for audio? Check this section and change api references. Example :

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

Assistants (beta)

Allows you to build AI assistants within your own applications.

Create assistant

Create an assistant with a model and instructions.

Retrieve assistant

Modify assistant

Delete assistant

Lists assistants

Returns a list of assistants.

Create assistant file

Create an assistant file by attaching a File to an assistant.

Retrieve assistant file

Delete assistant file

List assistant files

Returns a list of assistant files.

Threads (beta)

Create threads that assistants can interact with.

Create thread

Retrieve thread

Modify thread

Delete thread

Messages (beta)

Create messages within threads.

Create message

Retrieve message

Modify message

Lists messages

Returns a list of messages for a given thread.

Retrieve message file

List message files

Returns a list of message files.

Runs (beta)

Represents an execution run on a thread.

Create run

Retrieve run

Modify run

Lists runs

Returns a list of runs belonging to a thread.

Submit tool outputs

When a run has the status: "requires_action" and required_action.type is submit_tool_outputs, this endpoint can be used to submit the outputs from the tool calls once they're all completed. All outputs must be submitted in a single request.

Cancel run

Cancels a run that is "in_progress".

Create thread and run

Create a thread and run it in one request.

Retrieve run step

Retrieves a step in execution of a run.

List run steps

Returns a list of run steps belonging to a run.

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):

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please report security vulnerabilities to [email protected]

Credits

License

The MIT License (MIT). Please see License File for more information.

Donation

Buy Me A Coffee

Star History

Star History Chart


All versions of open-ai with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-curl Version *
ext-json Version *
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 orhanerday/open-ai contains the following files

Loading the files please wait ....