PHPackages                             khaiphan/openai-auth - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. khaiphan/openai-auth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

khaiphan/openai-auth
====================

A PHP library for authenticating with OpenAI

4211PHP

Since Jun 2Pushed 2y ago2 watchersCompare

[ Source](https://github.com/piscesCat/OpenAI-Auth-PHP)[ Packagist](https://packagist.org/packages/khaiphan/openai-auth)[ RSS](/packages/khaiphan-openai-auth/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

OpenAIAuth
----------

[](#openaiauth)

OpenAIAuth is a Composer package that allows you to authenticate with OpenAI/ChatGPT using PHP code.

Languages
---------

[](#languages)

- [Tiếng Việt](README_vi.md)
- [English](README.md)

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

[](#installation)

Requires a minimum PHP version of 7.2

Use [Composer](https://getcomposer.org) to install the package.

Run the following command in the terminal:

```
composer require khaiphan/openai-auth:dev-main

```

Usage
-----

[](#usage)

1. First, include the autoloader in your PHP code:

```
require 'vendor/autoload.php';
```

2. Next, create an instance of the `Auth0` class and provide your OpenAI username and password:

```
use KhaiPhan\OpenAi\Auth;

$OpenAIAuth = new Auth('OpenAI_username', 'OpenAI_password');
```

3. Then, call the `auth()` method to authenticate and obtain the access token:

```
$auth = $OpenAIAuth->auth();
```

4. You can access the access token through the `$auth['access_token']` variable. For example:

```
$accessToken = $auth['access_token'];
echo $accessToken;
```

Make sure to replace `'OpenAI_username'` and `'OpenAI_password'` with your actual authentication credentials.

License
-------

[](#license)

This package is open source and available under the [MIT License](https://opensource.org/licenses/MIT).

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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