PHPackages                             sysborg/chatgpt - 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. [Framework](/categories/framework)
4. /
5. sysborg/chatgpt

ActiveLibrary[Framework](/categories/framework)

sysborg/chatgpt
===============

Integração simples e eficaz entre o Laravel e o ChatGPT

0.0.4(8mo ago)116MITPHPPHP ^8.2

Since Jul 28Pushed 8mo agoCompare

[ Source](https://github.com/sysborg/chatgpt)[ Packagist](https://packagist.org/packages/sysborg/chatgpt)[ RSS](/packages/sysborg-chatgpt/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (6)Versions (5)Used By (0)

Sysborg ChatGPT Laravel Package
===============================

[](#sysborg-chatgpt-laravel-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1c0efb2e5de462727e24986719c6ba8c8ea0a7fb777e7c1450cad05fe896217c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737973626f72672f636861746770743f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sysborg/chatgpt)[![Total Downloads](https://camo.githubusercontent.com/5094da49f446c8aed8e20bd61041229f05c9929166d1c8e32329b59602e10bac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f737973626f72672f636861746770743f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sysborg/chatgpt)[![License: MIT](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Laravel](https://camo.githubusercontent.com/76d939fc04f6650848cda586b53d3a84d4972b6847440773b8cfbf85712f7f9d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302532422d7265643f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c)](https://camo.githubusercontent.com/76d939fc04f6650848cda586b53d3a84d4972b6847440773b8cfbf85712f7f9d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302532422d7265643f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c)[![PHP](https://camo.githubusercontent.com/266679b630bcbd5bf175b4a41064542172d6df5b0c8cc6ea61736e385e897018/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c75653f7374796c653d666c61742d737175617265266c6f676f3d706870)](https://camo.githubusercontent.com/266679b630bcbd5bf175b4a41064542172d6df5b0c8cc6ea61736e385e897018/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c75653f7374796c653d666c61742d737175617265266c6f676f3d706870)[![Composer](https://camo.githubusercontent.com/7595def966c952ef32fd0774a0b30821f190276337ee1035f50a1068557860c5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7265616479253230666f722d636f6d706f7365722d3839353261383f7374796c653d666c61742d737175617265266c6f676f3d636f6d706f736572)](https://camo.githubusercontent.com/7595def966c952ef32fd0774a0b30821f190276337ee1035f50a1068557860c5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7265616479253230666f722d636f6d706f7365722d3839353261383f7374796c653d666c61742d737175617265266c6f676f3d636f6d706f736572)

A simple and effective integration between Laravel and ChatGPT. This package provides a clean, developer-friendly interface for interacting with the OpenAI API, including support for chat, text completions, and image analysis with GPT-4 Vision.

---

Features
--------

[](#features)

- ✅ **Chat Completions** – Conversational AI with memory
- ✅ **Text Completions** – Continue or generate texts
- ✅ **Vision Analysis** – Image understanding with GPT-4 Vision
- ✅ **Rate Limiting** – Configurable request throttling
- ✅ **Retry Logic** – Automatic retries on failures
- ✅ **Multiple Models** – GPT-3.5, GPT-4, and GPT-4 Vision supported
- ✅ **Laravel Integration** – Includes Service Provider and Facade
- ✅ **Auto Discovery** – Automatically registered in Laravel

---

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

[](#installation)

Install the package via Composer:

```
composer require sysborg/chatgpt
```

### Publish Configuration

[](#publish-configuration)

To publish the config file:

```
php artisan vendor:publish --tag=chatgpt-config
```

### Set Your API Key

[](#set-your-api-key)

Add your OpenAI API key in the `.env` file:

```
OPENAI_API_KEY=your_openai_api_key_here
```

---

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

[](#configuration)

Customize `config/chatgpt.php` to match your needs:

```
return [
    'api_key' => env('OPENAI_API_KEY'),
    'base_url' => env('OPENAI_BASE_URL', 'https://api.openai.com/v1'),
    'default_model' => env('OPENAI_DEFAULT_MODEL', 'gpt-3.5-turbo'),
    'timeout' => env('OPENAI_TIMEOUT', 60),
    'max_tokens' => env('OPENAI_MAX_TOKENS', 1000),
    'temperature' => env('OPENAI_TEMPERATURE', 0.7),
    'retry_attempts' => env('OPENAI_RETRY_ATTEMPTS', 2),
    'retry_delay' => env('OPENAI_RETRY_DELAY', 1),
    'rate_limit' => env('OPENAI_RATE_LIMIT', 60), // 0 = unlimited
];
```

---

Basic Usage
-----------

[](#basic-usage)

### Simple Chat

[](#simple-chat)

```
use Sysborg\ChatGPT\Facades\ChatGPT;

$response = ChatGPT::chat('Hello, how are you?');
echo $response->getContent();
```

### Chat With History

[](#chat-with-history)

```
$messages = [
    ['role' => 'user', 'content' => 'What is the capital of Brazil?'],
    ['role' => 'assistant', 'content' => 'The capital of Brazil is Brasília.'],
    ['role' => 'user', 'content' => 'What is the population?']
];

$response = ChatGPT::chatWithHistory($messages);
echo $response->getContent();
```

### Text Completion

[](#text-completion)

```
$response = ChatGPT::completion('Once upon a time in a distant kingdom');
echo $response->getContent();
```

### Image Analysis

[](#image-analysis)

```
$response = ChatGPT::vision(
    'https://example.com/image.jpg',
    'Describe this image in detail'
);

// With base64 image
$base64 = base64_encode(file_get_contents('/path/to/image.jpg'));
$response = ChatGPT::visionFromBase64(
    $base64,
    'What do you see in this image?'
);

echo $response->getAnalysis();
```

---

Dynamic Configuration
---------------------

[](#dynamic-configuration)

```
$response = ChatGPT::setModel('gpt-4')
    ->setTemperature(0.9)
    ->setMaxTokens(2000)
    ->chat('Tell a creative story');
```

---

Handling Responses
------------------

[](#handling-responses)

### Chat Response

[](#chat-response)

```
$response = ChatGPT::chat('Hi!');

echo $response->getContent();
echo $response->getModel();
echo $response->getTotalTokens();
echo $response->getFinishReason();

if ($response->isComplete()) {
    echo "Completed successfully";
}

if ($response->isTruncated()) {
    echo "Response was truncated";
}
```

### Vision Response

[](#vision-response)

```
$response = ChatGPT::vision($imageUrl, 'Analyze this image');

echo $response->getAnalysis();
print_r($response->getDetectedEntities());
echo $response->getSummary();

if ($response->hasSafetyConcerns()) {
    echo "This image may contain sensitive content";
}
```

---

Error Handling
--------------

[](#error-handling)

```
use Sysborg\ChatGPT\Exceptions\ChatGPTException;
use Sysborg\ChatGPT\Exceptions\RateLimitException;

try {
    $response = ChatGPT::chat('Hi!');
} catch (RateLimitException $e) {
    echo "Rate limit exceeded. Retry in: " . $e->getRetryAfter() . " seconds";
} catch (ChatGPTException $e) {
    echo "API error: " . $e->getMessage();
    print_r($e->getContext());
}
```

---

Rate Limiting
-------------

[](#rate-limiting)

Built-in rate limit handling:

```
$status = ChatGPT::getRateLimitStatus();
echo "Requests remaining: " . $status['remaining'];

ChatGPT::resetRateLimit(); // Useful for testing
```

---

Available Models
----------------

[](#available-models)

```
$models = ChatGPT::getAvailableModels();
print_r($models);
```

**Example Output:**

```
[
    'gpt-3.5-turbo',
    'gpt-3.5-turbo-16k',
    'gpt-4',
    'gpt-4-turbo',
    'gpt-4-vision-preview',
    'gpt-4-32k'
]
```

---

Advanced Examples
-----------------

[](#advanced-examples)

### Chat with Custom Config

[](#chat-with-custom-config)

```
$response = ChatGPT::chatWithHistory([
    ['role' => 'system', 'content' => 'You are a programming assistant.'],
    ['role' => 'user', 'content' => 'How do I create a REST API in Laravel?']
], [
    'model' => 'gpt-4',
    'temperature' => 0.3,
    'max_tokens' => 1500,
    'top_p' => 0.9
]);
```

### Vision Analysis with Settings

[](#vision-analysis-with-settings)

```
$response = ChatGPT::vision($imageUrl, 'Analyze this image', [
    'model' => 'gpt-4-vision-preview',
    'detail' => 'high', // Options: low, high, auto
    'max_tokens' => 1000
]);
```

---

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

[](#contributing)

Contributions are welcome! Please open an issue or submit a pull request.

---

License
-------

[](#license)

This package is licensed under the [MIT License](LICENSE.md).

---

Author
------

[](#author)

**Anderson Arruda**📧 🐙 [@andmarruda on GitHub](https://github.com/andmarruda)

---

Support
-------

[](#support)

If you encounter any issues or have questions, please open a [GitHub Issue](https://github.com/sysborg/chatgpt/issues).

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance60

Regular maintenance activity

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~30 days

Total

4

Last Release

250d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a6c206a9669758146bf810648f37de32eb5cd5c07b8faa66c987b84fe3da696?d=identicon)[sysborg](/maintainers/sysborg)

---

Top Contributors

[![andmarruda](https://avatars.githubusercontent.com/u/29872593?v=4)](https://github.com/andmarruda "andmarruda (1 commits)")[![sysborg](https://avatars.githubusercontent.com/u/59512284?v=4)](https://github.com/sysborg "sysborg (1 commits)")

---

Tags

laravelaiopenaiartificial intelligenceChatGptgpt-4

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sysborg-chatgpt/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k108.5M887](/packages/laravel-socialite)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[laravel/boost

Laravel Boost accelerates AI-assisted development by providing the essential context and structure that AI needs to generate high-quality, Laravel-specific code.

3.5k21.5M601](/packages/laravel-boost)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)

PHPackages © 2026

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