Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/easygithdev/phpopenai-examples
Examples for the project PHPOpenAI
https://github.com/easygithdev/phpopenai-examples
Last synced: 21 days ago
JSON representation
Examples for the project PHPOpenAI
- Host: GitHub
- URL: https://github.com/easygithdev/phpopenai-examples
- Owner: EasyGithDev
- License: mit
- Created: 2023-03-24T10:39:04.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-25T13:05:47.000Z (10 months ago)
- Last Synced: 2024-02-25T14:25:34.035Z (10 months ago)
- Size: 3.2 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHPOpenAI-Examples
Examples for the project PHPOpenAIWelcome to the GitHub project page for "PHPOpenAI-Examples", a project that enables the use of the OpenAI API in PHP.
The main project is hosted here :
[https://github.com/EasyGithDev/PHPOpenAI](https://github.com/EasyGithDev/PHPOpenAI).
## 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 >= 8.1
- cURL extension## 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.
### Github install
#### Clone the project
To install the project, you can clone it from GitHub using the following Git command:
```bash
git clone [email protected]:EasyGithDev/PHPOpenAI-Examples.git
```#### Install the project
```bash
composer install
```## 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.
Here's an example code that shows you how to use the OpenAI API in PHP:
```php
Completion()->create(
ModelEnum::TEXT_DAVINCI_003,
"Say this is a test",
)->toObject();// Response as stClass object
echo '', print_r($response, true), '';
```The full documentation is here :
[https://github.com/EasyGithDev/PHPOpenAI](https://github.com/EasyGithDev/PHPOpenAI).