Skip to content

zonesql/phpopenai

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 

phpOpenAI

PHP OpenAI ChatGPT Class. 🚀 Native PHP, Zero dependencies.

OpenAPI.php

Overview

A PHP integration with OpenAI API (ChatGPT) allowing text completions and image generations. Easy & quick to implement, Pure PHP, no dependencies.

Installation

Copy the class to your project, obtain your API key and replace YOUR_API_KEY in the line below:

private const API_KEY = "YOUR_API_KEY";

Usage

$ai = new OpenAI();
$response = $ai->generateTextFromPrompt('what did humpty dumpty sit on?');
echo "Response: " . $response['data'];

Requirements

  • PHP 7.4 or newer.
  • cURL extension enabled.
  • Valid OpenAI API key.
  • Active internet connection to communicate with the OpenAI API.
  • JSON extension (usually enabled by default in PHP installations).

Licensing

See LICENCE file for details.

Author

Adam Tandowski

Links

About

A PHP integration with OpenAI API (ChatGPT) allowing text completions and image generations. Easy & quick to implement, native PHP, zero dependencies.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages