PHPackages                             softcreatr/php-openai-sdk - 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. [API Development](/categories/api)
4. /
5. softcreatr/php-openai-sdk

ActiveLibrary[API Development](/categories/api)

softcreatr/php-openai-sdk
=========================

A powerful and easy-to-use PHP SDK for the OpenAI API, allowing seamless integration of advanced AI-powered features into your PHP projects.

3.1.0(1y ago)101.0k2ISCPHPPHP &gt;=8.1

Since Mar 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/SoftCreatR/php-openai-sdk)[ Packagist](https://packagist.org/packages/softcreatr/php-openai-sdk)[ Fund](https://ecologi.com/softcreatr?r=61212ab3fc69b8eb8a2014f4)[ GitHub Sponsors](https://github.com/softcreatr)[ RSS](/packages/softcreatr-php-openai-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (7)Versions (9)Used By (0)

OpenAI API Wrapper for PHP
==========================

[](#openai-api-wrapper-for-php)

[![Build](https://camo.githubusercontent.com/9da43a27638d15cee2913b16bdd912f2aacaf2f3eb175bd62feea8057612ef48/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f536f66744372656174522f7068702d6f70656e61692d73646b2f2e6769746875622f776f726b666c6f77732f6372656174652d72656c656173652e796d6c3f6272616e63683d6d61696e)](https://github.com/SoftCreatR/php-openai-sdk/actions/workflows/create-release.yml) [![Latest Release](https://camo.githubusercontent.com/facca17ee34d30845634c57c41a8088e7e8c4ee2c07158a13571f8453c254f0e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f536f66744372656174522f7068702d6f70656e61692d73646b3f636f6c6f723d626c7565266c6162656c3d4c617465737425323052656c65617365)](https://packagist.org/packages/softcreatr/php-openai-sdk) [![ISC licensed](https://camo.githubusercontent.com/95c61c397ca3825757ec835268e50886b2c10ddc4f0676e1222b19037610927f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4953432d626c75652e737667)](./LICENSE.md) [![Plant Tree](https://camo.githubusercontent.com/e751d267acfa70a4be08989f626ff706c90cec4e0ab98940e620250f26a991be/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f64796e616d69632f6a736f6e3f636f6c6f723d627269676874677265656e266c6162656c3d506c616e74253230547265652671756572793d2532342e746f74616c2675726c3d68747470732533412532462532467075626c69632e65636f6c6f67692e636f6d2532467573657273253246736f66746372656174722532467472656573)](https://ecologi.com/softcreatr?r=61212ab3fc69b8eb8a2014f4) [![Codecov branch](https://camo.githubusercontent.com/abad3b3e353ff78c92d458a5f38a43cd78cda16666d091be135cb77d8a0c9a04/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f536f66744372656174522f7068702d6f70656e61692d73646b)](https://codecov.io/gh/SoftCreatR/php-openai-sdk) [![Code Climate maintainability](https://camo.githubusercontent.com/85559ee2e6fd94fd58b1dfece4023b40a71002746ca69d86bb92ac83ae33079c/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792d70657263656e746167652f536f66744372656174522f7068702d6f70656e61692d73646b)](https://codeclimate.com/github/SoftCreatR/php-openai-sdk)

This PHP library provides a simple wrapper for the OpenAI API, allowing you to easily integrate the OpenAI API into your PHP projects.

Features
--------

[](#features)

- Easy integration with OpenAI API
- Supports all OpenAI API endpoints
- Streaming support for real-time responses in chat completions
- Utilizes PSR-17 and PSR-18 compliant HTTP clients and factories for making API requests

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- A PSR-17 HTTP Factory implementation (e.g., [guzzle/psr7](https://github.com/guzzle/psr7) or [nyholm/psr7](https://github.com/Nyholm/psr7))
- A PSR-18 HTTP Client implementation (e.g., [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) or [symfony/http-client](https://github.com/symfony/http-client))

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

[](#installation)

You can install the library via [Composer](https://getcomposer.org/):

```
composer require softcreatr/php-openai-sdk
```

Usage
-----

[](#usage)

First, include the library in your project:

```
