PHPackages                             openai-php/symfony - 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. openai-php/symfony

ActiveSymfony-bundle[API Development](/categories/api)

openai-php/symfony
==================

Symfony Bundle for OpenAI

v0.19.0(3mo ago)215715.5k—0%313MITPHPPHP ^8.2.0CI passing

Since Mar 9Pushed 2mo ago12 watchersCompare

[ Source](https://github.com/openai-php/symfony)[ Packagist](https://packagist.org/packages/openai-php/symfony)[ Fund](https://www.paypal.com/paypalme/enunomaduro)[ GitHub Sponsors](https://github.com/nunomaduro)[ RSS](/packages/openai-php-symfony/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (13)Versions (20)Used By (3)

 [![GitHub Workflow Status (master)](https://camo.githubusercontent.com/147949a29fd456df415b7410785cc3dcf482f413829b5f4bf1c377f554a6dd78/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6f70656e61692d7068702f73796d666f6e792f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d726f756e642d737175617265)](https://github.com/openai-php/symfony/actions) [![Total Downloads](https://camo.githubusercontent.com/9510ab01037ce065c002f96d7e61736f2f120ad562013d635b362622681e5d09/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f70656e61692d7068702f73796d666f6e79)](https://packagist.org/packages/openai-php/symfony) [![Latest Version](https://camo.githubusercontent.com/6daf6cd3bcbc1c76407363b7912bc81d210e3dc956ff2776f3dbb74f42553bb1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f70656e61692d7068702f73796d666f6e79)](https://packagist.org/packages/openai-php/symfony) [![License](https://camo.githubusercontent.com/36b31c2d1dcdb5fabbc74a72447fdac3bf628511ddb6cd75b1568627dfd9c4fe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f70656e61692d7068702f73796d666f6e79)](https://packagist.org/packages/openai-php/symfony)

---

**OpenAI PHP** for Symfony is a community-maintained PHP API client that allows you to interact with the [Open AI API](https://beta.openai.com/docs/api-reference/introduction). If you or your business relies on this package, it's important to support the developers who have contributed their time and effort to create and maintain this valuable tool:

- Nuno Maduro: **[github.com/sponsors/nunomaduro](https://github.com/sponsors/nunomaduro)**
- Sandro Gehri: **[github.com/sponsors/gehrisandro](https://github.com/sponsors/gehrisandro)**

> **Note:** This repository contains the integration code of the **OpenAI PHP** for Symfony. If you want to use the **OpenAI PHP** client in a framework-agnostic way, take a look at the [openai-php/client](https://github.com/openai-php/client) repository.

Get Started
-----------

[](#get-started)

> **Requires [PHP 8.1+](https://php.net/releases/)**

First, install OpenAI via the [Composer](https://getcomposer.org/) package manager:

```
composer require openai-php/symfony
```

Next, register the bundle in your `config/bundles.php`:

```
return [
    // ...
    OpenAI\Symfony\OpenAIBundle::class => ['all' => true],
]
```

This will create a `.env` configuration file in your project, which you can modify to your needs using environment variables:

```
OPENAI_API_KEY=sk-...
OPENAI_ORGANIZATION=...
```

For more configuration options, take a look at the [Configuration Reference](#configuration-reference).

Finally, you may use the `openai` service to access the OpenAI API:

```
$result = $container->get('openai')->completions()->create([
    'model' => 'gpt-4o-mini',
    'prompt' => 'PHP is',
]);

echo $result['choices'][0]['text']; // an open-source, widely-used, server-side scripting language.
```

Usage
-----

[](#usage)

For usage examples, take a look at the [openai-php/client](https://github.com/openai-php/client) repository.

Configuration Reference
-----------------------

[](#configuration-reference)

The bundle provides the following configuration options, which you can set in your `config/packages/openai.yaml` file:

```
openai:
    api_key: '%env(OPENAI_API_KEY)%' # Your OpenAI API key (required)
    organization: '%env(OPENAI_ORGANIZATION)%' # Your OpenAI organization ID (optional)
    project: 'proj_...' # The project ID (optional)
    base_uri: 'api.openai.com/v1' # The base URI for the OpenAI API (optional)
```

---

OpenAI PHP for Symfony is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.

###  Health Score

60

—

FairBetter than 99% of packages

Maintenance85

Actively maintained with recent releases

Popularity57

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~33 days

Total

18

Last Release

96d ago

PHP version history (2 changes)v0.3.5PHP ^8.1.0

v0.12.0PHP ^8.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/86cfef5c1f5195df1a9db17a5f8ecb34455e1f0133a725de9acf7f2fb26ac6a1?d=identicon)[nunomaduro](/maintainers/nunomaduro)

---

Top Contributors

[![GromNaN](https://avatars.githubusercontent.com/u/400034?v=4)](https://github.com/GromNaN "GromNaN (25 commits)")[![nunomaduro](https://avatars.githubusercontent.com/u/5457236?v=4)](https://github.com/nunomaduro "nunomaduro (20 commits)")[![annuh](https://avatars.githubusercontent.com/u/2487949?v=4)](https://github.com/annuh "annuh (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![dmytrome](https://avatars.githubusercontent.com/u/6862373?v=4)](https://github.com/dmytrome "dmytrome (4 commits)")[![hmoreau](https://avatars.githubusercontent.com/u/1233146?v=4)](https://github.com/hmoreau "hmoreau (4 commits)")[![iBotPeaches](https://avatars.githubusercontent.com/u/611784?v=4)](https://github.com/iBotPeaches "iBotPeaches (2 commits)")[![slim-dg9](https://avatars.githubusercontent.com/u/122024497?v=4)](https://github.com/slim-dg9 "slim-dg9 (1 commits)")[![DylanDelobel](https://avatars.githubusercontent.com/u/5182186?v=4)](https://github.com/DylanDelobel "DylanDelobel (1 commits)")[![frithjof](https://avatars.githubusercontent.com/u/1432985?v=4)](https://github.com/frithjof "frithjof (1 commits)")[![juukie](https://avatars.githubusercontent.com/u/2678657?v=4)](https://github.com/juukie "juukie (1 commits)")[![princeaden1](https://avatars.githubusercontent.com/u/14006504?v=4)](https://github.com/princeaden1 "princeaden1 (1 commits)")[![3qdev](https://avatars.githubusercontent.com/u/21038186?v=4)](https://github.com/3qdev "3qdev (1 commits)")

---

Tags

clientopen-aisymfonyphpapiclientsymfonysdklanguageprocessingnaturalcodexGPT-3openaidall-e

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k22.6M232](/packages/openai-php-client)[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[google-gemini-php/symfony

Symfony Bundle for Gemini

149.4k1](/packages/google-gemini-php-symfony)

PHPackages © 2026

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