PHPackages                             ernani-mac/open-ai - 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. ernani-mac/open-ai

ActiveLibrary[API Development](/categories/api)

ernani-mac/open-ai
==================

Component for using the OpenAI API and its models.

v1.0.1(1y ago)09MITPHPPHP &gt;=8.1

Since Jul 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ErnaniMac/open-ai)[ Packagist](https://packagist.org/packages/ernani-mac/open-ai)[ RSS](/packages/ernani-mac-open-ai/feed)WikiDiscussions origin Synced today

READMEChangelog (1)DependenciesVersions (3)Used By (0)

OpenAI chat
===========

[](#openai-chat)

[![Slim PHP](https://camo.githubusercontent.com/bbeaca4ecdd74d3fde840f711ebb8a5def2ff801187623f9bc365761b3b66f86/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2532333737374242342e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/bbeaca4ecdd74d3fde840f711ebb8a5def2ff801187623f9bc365761b3b66f86/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2532333737374242342e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d706870266c6f676f436f6c6f723d7768697465)

Component for using the OpenAI API and its models.

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

[](#requirements)

- PHP &gt;=8.1

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

[](#installation)

1. Add in your composer:

```
composer require ernani-mac/open-ai
```

How to use
----------

[](#how-to-use)

```

    use ErnaniMac\openai\src\Facade;

    class Terminal
    {
        public function chat($token, $url)
        {
            $chat = new Facade($token, $url);

            // OpenAI LLM model to use.
            $model = 'gpt-3.5-turbo';

            // Pre-configured how you want the AI ​​to interact with your questions.
            $system_content = 'A linguagem das perguntas é PHP. Sempre dê pelo menos um exemplo.';

            // Your question/message to AI.
            $user_content = 'Mostre me como criar um middleware sem usar bibliotecas.';

            // Maximum tokens per request counting with your question and the AI's answer.
            $max_tokens = 500;

            $data = [
                'model' => $model,
                'system_content' => $system_content,
                'user_content' => $user_content,
                'max_tokens' => $max_tokens
            ];

            return $chat->prompt($data);
        }
    }

    $terminal = new Terminal();

    try {

        $apiKey = 'YOUR_API_KEY';
        $base_url_openAI = 'https://api.openai.com/';

        $response = $terminal->chat($apiKey, $base_url_openAI);

        var_dump($response);

    } catch (Exception $e) {
        var_dump($e);
    }
```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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 ~1 days

Total

2

Last Release

709d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.4

v1.0.1PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/35916869?v=4)[Ernani da Silva Maciel](/maintainers/ErnaniMac)[@ErnaniMac](https://github.com/ErnaniMac)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/ernani-mac-open-ai/health.svg)

```
[![Health](https://phpackages.com/badges/ernani-mac-open-ai/health.svg)](https://phpackages.com/packages/ernani-mac-open-ai)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k12](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

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