PHPackages                             easygithdev/php-openai - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. easygithdev/php-openai

ActiveLibrary[HTTP &amp; Networking](/categories/http)

easygithdev/php-openai
======================

PHPOpenAI is a wrapper to access OpenAI API

v2.3(2y ago)5115MITPHPPHP &gt;=8.1

Since Mar 22Pushed 2y ago1 watchersCompare

[ Source](https://github.com/EasyGithDev/PHPOpenAI)[ Packagist](https://packagist.org/packages/easygithdev/php-openai)[ RSS](/packages/easygithdev-php-openai/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (21)Used By (0)

PHPOpenAI
=========

[](#phpopenai)

`PHPOpenAI` is a community-maintained library that enables the use of the `OpenAI` API in PHP.

The project is written in PHP and can be used to easily integrate the `OpenAI API` into your existing PHP project.

System Requirements
-------------------

[](#system-requirements)

This project is based on PHP version 8.1 in order to use features such as enumerations. This project does not require any external dependencies. However, you must have the cURL extension installed for it to work properly.

- PHP version &gt;= 8.1
- cURL extension

Installation
------------

[](#installation)

The project uses Composer to manage dependencies. If you haven't already installed Composer, you can do so by following the instructions on the official Composer website.

### Packagist install

[](#packagist-install)

To install the project, you can install the package from packagist.org using the following command:

```
composer require easygithdev/php-openai
```

Writing a first example
-----------------------

[](#writing-a-first-example)

To use the `OpenAI API`, you need to sign up on their website and obtain an API key. Once you have your API key, you can use it in your PHP code to send requests to the OpenAI API.

To find out how to get your key, go to the following address:

.

Here's an example code that shows you how to use the OpenAI API in PHP:

```
