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

ActiveLibrary[API Development](/categories/api)

dragnsurvey/openai
==================

Laravel Package to interract with OpenAI API

v1.0.1(2y ago)023MITPHPPHP &gt;=8.0

Since Nov 14Pushed 2y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Laravel OpenAI Package
======================

[](#laravel-openai-package)

Description
-----------

[](#description)

Laravel OpenAI Package is a Laravel wrapper for the OpenAI API, providing easy integration and usage of OpenAI's capabilities such as GPT-3, DALL-E, and more within Laravel applications. This package simplifies the process of connecting to OpenAI's API and performing various AI-driven tasks.

Features
--------

[](#features)

- Easy integration with Laravel projects.
- Supports various OpenAI API functionalities like Chat, Image Generation, etc.
- Customizable to fit specific use cases.

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

[](#requirements)

- PHP &gt;= 7.4
- Laravel &gt;= 8.0
- Guzzle HTTP Client

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

[](#installation)

Install the package via Composer:

```
composer require dragnsurvey/openai
```

After installing, publish the configuration file (if needed):

```
php artisan vendor:publish
--provider="Dragnsurvey\OpenAi\OpenAiServiceProvider"
```

Configuration
-------------

[](#configuration)

To configure the package, add your OpenAI API key to your `.env` file:

```
OPENAI_API_KEY=your_api_key_here
```

Set other configuration options in `config/openai.php` (if the configuration file was published).

Usage
-----

[](#usage)

### Using Chat API

[](#using-chat-api)

To use the Chat API:

```
use Dragnsurvey\OpenAi\Chat\ChatRequest;

$chatRequest = new ChatRequest();
$chatRequest->setModel("gpt-4");
$chatRequest->addSystemMessage("You answer questions about football using
the tone of a sportscaster ");
$chatRequest->addUserMessage("Hello, who won the world cup in 1998?");
$response = $chatRequest->send();

print_r($response);
```

### Using Image Generation API

[](#using-image-generation-api)

To use the Image Generation API:

```
use Dragnsurvey\OpenAi\Image\ImageRequest;

$imageRequest = new ImageRequest();
$imageRequest->setPrompt("A two-headed dragon");
$response = $imageRequest->send();

//OR pass the prompt in the constructor
$imageRequest = new ImageRequest("A two-headed dragon");
$response = $imageRequest->send();

//change model
$imageRequest->setModel('dall-e-3')

print_r($response);
```

Advanced Usage
--------------

[](#advanced-usage)

For advanced usage, refer to [OpenAI's official documentation](https://platform.openai.com/docs/api-reference).

Testing
-------

[](#testing)

Run the tests with:

```
vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Contributions are welcome, and any help is greatly appreciated.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

Credits
-------

[](#credits)

- Roman STEC ()

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

915d ago

PHP version history (2 changes)v1.0.0PHP ^8.1.0

v1.0.1PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d3b2be2c8044e72937f0bf36fa0aad31bc0284f04e4970d451f044a89fe34b0c?d=identicon)[tipo94](/maintainers/tipo94)

---

Top Contributors

[![tipo94](https://avatars.githubusercontent.com/u/7853012?v=4)](https://github.com/tipo94 "tipo94 (4 commits)")

### Embed Badge

![Health badge](/badges/dragnsurvey-openai/health.svg)

```
[![Health](https://phpackages.com/badges/dragnsurvey-openai/health.svg)](https://phpackages.com/packages/dragnsurvey-openai)
```

###  Alternatives

[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M112](/packages/darkaonline-l5-swagger)[echolabsdev/prism

A powerful Laravel package for integrating Large Language Models (LLMs) into your applications.

2.3k388.3k10](/packages/echolabsdev-prism)[sburina/laravel-whmcs-up

WHMCS API client and user provider for Laravel

271.3k](/packages/sburina-laravel-whmcs-up)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
