From 67b1d695476ba27343875219682da46404eb2f24 Mon Sep 17 00:00:00 2001 From: Sandro Gehri Date: Fri, 7 Jun 2024 22:33:57 +0200 Subject: [PATCH 01/41] Docs: remove assistants v2 hint from README.md --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 601927f..57cc5a8 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,6 @@ > **Note:** This repository contains the integration code of the **OpenAI PHP** for Laravel. 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. -> **Looking for Assistants v2 support?** -> -> Check out the [0.10.x](https://github.com/openai-php/laravel/releases/tag/v0.10.0-beta.1) release (beta) ## Get Started From 6a1eb8a28a5a4d6e21f0dacd95c47b8c7354cb35 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 22 Aug 2024 09:24:00 +0100 Subject: [PATCH 02/41] Bumps dependencies --- composer.json | 14 +++++++------- src/Testing/OpenAIFake.php | 4 +--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index ea90647..e5aa128 100644 --- a/composer.json +++ b/composer.json @@ -11,16 +11,16 @@ ], "require": { "php": "^8.1.0", - "guzzlehttp/guzzle": "^7.8.1", - "laravel/framework": "^9.46.0|^10.34.2|^11.0", + "guzzlehttp/guzzle": "^7.9.2", + "laravel/framework": "^9.46.0|^10.34.2|^11.21", "openai-php/client": "^v0.10.1" }, "require-dev": { - "laravel/pint": "^1.13.6", - "pestphp/pest": "^2.27.0", - "pestphp/pest-plugin-arch": "^2.4.1", - "phpstan/phpstan": "^1.10.47", - "symfony/var-dumper": "^6.4.0|^7.0.1" + "laravel/pint": "^1.17.2", + "pestphp/pest": "^2.35.1", + "pestphp/pest-plugin-arch": "^2.7.0", + "phpstan/phpstan": "^1.11.11", + "symfony/var-dumper": "^6.4.0|^7.1.3" }, "autoload": { "psr-4": { diff --git a/src/Testing/OpenAIFake.php b/src/Testing/OpenAIFake.php index a4e2eb2..9ac5b3b 100644 --- a/src/Testing/OpenAIFake.php +++ b/src/Testing/OpenAIFake.php @@ -4,6 +4,4 @@ use OpenAI\Testing\ClientFake; -class OpenAIFake extends ClientFake -{ -} +class OpenAIFake extends ClientFake {} From 9ab6ae5d5fd10c51d8513e97a8dd9bce81b1d5c2 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 19 Sep 2024 22:19:52 +0100 Subject: [PATCH 03/41] chore: bumps dependencies --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index e5aa128..b58816e 100644 --- a/composer.json +++ b/composer.json @@ -12,15 +12,15 @@ "require": { "php": "^8.1.0", "guzzlehttp/guzzle": "^7.9.2", - "laravel/framework": "^9.46.0|^10.34.2|^11.21", + "laravel/framework": "^9.46.0|^10.34.2|^11.23.5", "openai-php/client": "^v0.10.1" }, "require-dev": { - "laravel/pint": "^1.17.2", + "laravel/pint": "^1.17.3", "pestphp/pest": "^2.35.1", "pestphp/pest-plugin-arch": "^2.7.0", - "phpstan/phpstan": "^1.11.11", - "symfony/var-dumper": "^6.4.0|^7.1.3" + "phpstan/phpstan": "^1.12.4", + "symfony/var-dumper": "^6.4.0|^7.1.4" }, "autoload": { "psr-4": { From 24815ef1bda71cc0715f7aefe4506e77329e560f Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Thu, 17 Oct 2024 21:34:07 +0100 Subject: [PATCH 04/41] feat: adds php 8.4 support --- .github/workflows/tests.yml | 2 +- composer.json | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 15f7f29..92da102 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,7 +9,7 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.1, 8.2, 8.3] + php: [8.1, 8.2, 8.3, 8.4] laravel: [11.*, 10.*, 9.*] dependency-version: [prefer-lowest, prefer-stable] exclude: diff --git a/composer.json b/composer.json index b58816e..1c015a5 100644 --- a/composer.json +++ b/composer.json @@ -13,12 +13,12 @@ "php": "^8.1.0", "guzzlehttp/guzzle": "^7.9.2", "laravel/framework": "^9.46.0|^10.34.2|^11.23.5", - "openai-php/client": "^v0.10.1" + "openai-php/client": "^0.10.2" }, "require-dev": { "laravel/pint": "^1.17.3", - "pestphp/pest": "^2.35.1", - "pestphp/pest-plugin-arch": "^2.7.0", + "pestphp/pest": "^2.35.1|^3.0.0", + "pestphp/pest-plugin-arch": "^2.7.0|^3.0.0", "phpstan/phpstan": "^1.12.4", "symfony/var-dumper": "^6.4.0|^7.1.4" }, @@ -51,7 +51,6 @@ }, "scripts": { "lint": "pint -v", - "refactor": "rector --debug", "test:lint": "pint --test -v", "test:types": "phpstan analyse --ansi", "test:unit": "pest --colors=always", From 166cc2286671f466ca8171af47f6f665968643fa Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 27 Oct 2024 08:45:27 -0400 Subject: [PATCH 05/41] chore: bumps dependencies --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 1c015a5..4caa56a 100644 --- a/composer.json +++ b/composer.json @@ -12,15 +12,15 @@ "require": { "php": "^8.1.0", "guzzlehttp/guzzle": "^7.9.2", - "laravel/framework": "^9.46.0|^10.34.2|^11.23.5", + "laravel/framework": "^9.46.0|^10.34.2|^11.29.0", "openai-php/client": "^0.10.2" }, "require-dev": { - "laravel/pint": "^1.17.3", - "pestphp/pest": "^2.35.1|^3.0.0", + "laravel/pint": "^1.18.1", + "pestphp/pest": "^2.35.1|^3.5.0", "pestphp/pest-plugin-arch": "^2.7.0|^3.0.0", - "phpstan/phpstan": "^1.12.4", - "symfony/var-dumper": "^6.4.0|^7.1.4" + "phpstan/phpstan": "^1.12.7", + "symfony/var-dumper": "^6.4.0|^7.1.5" }, "autoload": { "psr-4": { From e23884109a923630996ab6ea552a2282031e8f1f Mon Sep 17 00:00:00 2001 From: Marlon Basten <31259698+marlonbasten@users.noreply.github.com> Date: Mon, 24 Feb 2025 17:47:46 +0100 Subject: [PATCH 06/41] Made compatible with Laravel 12 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4caa56a..979b08e 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "require": { "php": "^8.1.0", "guzzlehttp/guzzle": "^7.9.2", - "laravel/framework": "^9.46.0|^10.34.2|^11.29.0", + "laravel/framework": "^9.46.0|^10.34.2|^11.29.0|^12.0", "openai-php/client": "^0.10.2" }, "require-dev": { From 03d50e87cdf0aa13203ce8b9f371db7b86dfc919 Mon Sep 17 00:00:00 2001 From: Sandro Gehri Date: Mon, 24 Feb 2025 18:36:34 +0100 Subject: [PATCH 07/41] Fix tests for Laravel 12 --- tests/ServiceProvider.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/ServiceProvider.php b/tests/ServiceProvider.php index cae4dd5..122058a 100644 --- a/tests/ServiceProvider.php +++ b/tests/ServiceProvider.php @@ -42,6 +42,8 @@ $app->bind('config', fn () => new Repository([])); (new ServiceProvider($app))->register(); + + $app->get(Client::class); })->throws( ApiKeyIsMissing::class, 'The OpenAI API Key is missing. Please publish the [openai.php] configuration file and set the [api_key].', From 7ba487faf81a8728937e5091292d2af28e732d2c Mon Sep 17 00:00:00 2001 From: Sandro Gehri Date: Mon, 24 Feb 2025 18:36:45 +0100 Subject: [PATCH 08/41] Run CI tests against Laravel 12 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 92da102..5190b1a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: matrix: os: [ubuntu-latest] php: [8.1, 8.2, 8.3, 8.4] - laravel: [11.*, 10.*, 9.*] + laravel: [12.*, 11.*, 10.*, 9.*] dependency-version: [prefer-lowest, prefer-stable] exclude: - php: 8.1 From 8596fbd961fae6d5b935d40072082a175b1dd9a3 Mon Sep 17 00:00:00 2001 From: Sandro Gehri Date: Mon, 24 Feb 2025 18:41:59 +0100 Subject: [PATCH 09/41] Do not run tests against PHP 8.1 with Laravel 12 --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5190b1a..ad2d98d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,6 +15,8 @@ jobs: exclude: - php: 8.1 laravel: 11.* + - php: 8.2 + laravel: 11.* name: Tests P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} steps: From 70169a6ee0f0f7aabdb4e60048a26bcc2886091d Mon Sep 17 00:00:00 2001 From: Sandro Gehri Date: Mon, 24 Feb 2025 18:46:52 +0100 Subject: [PATCH 10/41] Do not run tests against PHP 8.1 with Laravel 12 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ad2d98d..a52f83a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: exclude: - php: 8.1 laravel: 11.* - - php: 8.2 + - php: 8.1 laravel: 11.* name: Tests P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} From 98b7817c6dca4a7b55981479f3dc13fdcfaa3805 Mon Sep 17 00:00:00 2001 From: Sandro Gehri Date: Mon, 24 Feb 2025 18:48:45 +0100 Subject: [PATCH 11/41] Do not run tests against PHP 8.1 with Laravel 12 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a52f83a..62e9c44 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: - php: 8.1 laravel: 11.* - php: 8.1 - laravel: 11.* + laravel: 12.* name: Tests P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} steps: From a8a22abe4b20832ef07671570cf18b430244591f Mon Sep 17 00:00:00 2001 From: Sandro Gehri Date: Mon, 24 Feb 2025 18:51:15 +0100 Subject: [PATCH 12/41] Run formats CI pipeline on PHP 8.4 --- .github/workflows/formats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/formats.yml b/.github/workflows/formats.yml index 5974f60..42836fe 100644 --- a/.github/workflows/formats.yml +++ b/.github/workflows/formats.yml @@ -10,8 +10,8 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.2] - dependency-version: [prefer-lowest, prefer-stable] + php: [8.4] + dependency-version: [prefer-stable] name: Formats P${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} From 4c8ae8b2c25a05c4a0d2a1b45c787bf160269044 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Wed, 19 Mar 2025 11:58:50 -0400 Subject: [PATCH 13/41] fix: update to latest github action versions --- .github/workflows/formats.yml | 4 ++-- .github/workflows/tests.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/formats.yml b/.github/workflows/formats.yml index 42836fe..54c5f01 100644 --- a/.github/workflows/formats.yml +++ b/.github/workflows/formats.yml @@ -18,10 +18,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Cache dependencies - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ~/.composer/cache/files key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 62e9c44..b616542 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,10 +22,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Cache dependencies - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ~/.composer/cache/files key: dependencies-php-${{ matrix.php }}-L${{ matrix.laravel }}-${{ matrix.dependency-version }}-composer-${{ hashFiles('composer.json') }} From 08062b9c612e58ba3de4d7c5c3ac5ef18e93b868 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Wed, 19 Mar 2025 11:59:02 -0400 Subject: [PATCH 14/41] feat: opt into Dependabot for GitHub Action health --- .github/dependabot.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..ca79ca5 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly From f03e46868aee138fa9db9a2369e07bcc49309d3c Mon Sep 17 00:00:00 2001 From: Abdelmjid Saber <87904671+megoxv@users.noreply.github.com> Date: Fri, 4 Apr 2025 21:29:16 +0200 Subject: [PATCH 15/41] docs: Correct OpenAI API link in README.md from broken beta subdomain (#141) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 57cc5a8..6d0f477 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@

------ -**OpenAI PHP** for Laravel 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: +**OpenAI PHP** for Laravel is a community-maintained PHP API client that allows you to interact with the [Open AI API](https://platform.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)** From 7c9a79f5e441d6e435a46028bfa49ba254d6cfee Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Fri, 4 Apr 2025 14:12:27 -0700 Subject: [PATCH 16/41] docs: moves to 4o-mini model in README.md examples (#123) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6d0f477..4e68322 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Finally, you may use the `OpenAI` facade to access the OpenAI API: use OpenAI\Laravel\Facades\OpenAI; $result = OpenAI::chat()->create([ - 'model' => 'gpt-3.5-turbo', + 'model' => 'gpt-4o-mini', 'messages' => [ ['role' => 'user', 'content' => 'Hello!'], ], @@ -107,7 +107,7 @@ OpenAI::fake([ ]); $completion = OpenAI::completions()->create([ - 'model' => 'gpt-3.5-turbo-instruct', + 'model' => 'gpt-4o-mini', 'prompt' => 'PHP is ', ]); @@ -120,7 +120,7 @@ After the requests have been sent there are various methods to ensure that the e // assert completion create request was sent OpenAI::assertSent(Completions::class, function (string $method, array $parameters): bool { return $method === 'create' && - $parameters['model'] === 'gpt-3.5-turbo-instruct' && + $parameters['model'] === 'gpt-4o-mini' && $parameters['prompt'] === 'PHP is '; }); ``` From 955d1326c5bf0c48d1148c33f5b1d1e7b0abe6a1 Mon Sep 17 00:00:00 2001 From: EverForge <113529280+BadJacky@users.noreply.github.com> Date: Sun, 6 Apr 2025 02:13:52 +0800 Subject: [PATCH 17/41] fix: add fineTuning method to OpenAI facade (#125) --- src/Facades/OpenAI.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Facades/OpenAI.php b/src/Facades/OpenAI.php index 19be0c5..7ad1b02 100644 --- a/src/Facades/OpenAI.php +++ b/src/Facades/OpenAI.php @@ -19,6 +19,7 @@ * @method static \OpenAI\Resources\Edits edits() * @method static \OpenAI\Resources\Files files() * @method static \OpenAI\Resources\FineTunes fineTunes() + * @method static \OpenAI\Resources\FineTuning fineTuning() * @method static \OpenAI\Resources\Images images() * @method static \OpenAI\Resources\Models models() * @method static \OpenAI\Resources\Moderations moderations() From 2b982d2d0b255a98d6ccb2af376952b1d5d18a6a Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Mon, 7 Apr 2025 20:33:07 -0400 Subject: [PATCH 18/41] build: remove prestissimo (unneeded in composer: v2) (#145) --- .github/workflows/formats.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/formats.yml b/.github/workflows/formats.yml index 54c5f01..9ceeb95 100644 --- a/.github/workflows/formats.yml +++ b/.github/workflows/formats.yml @@ -31,7 +31,6 @@ jobs: with: php-version: ${{ matrix.php }} extensions: dom, mbstring, zip - tools: prestissimo coverage: pcov - name: Install Composer dependencies From 589cf3ad3f71457c87fa26168deb6a2bc51999c0 Mon Sep 17 00:00:00 2001 From: Peter Ramsing Date: Mon, 7 Apr 2025 17:36:17 -0700 Subject: [PATCH 19/41] build: Adds PR template per contributing guidelines (#124) * Adds PR template per contributing guidelines * chore: remove pest notation --- .github/PULL_REQUEST_TEMPLATE.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..5d59bb0 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,17 @@ + + +### What: + +- [ ] Bug Fix +- [ ] New Feature +- [ ] Docs + +### Description: + + + +### Related: + + From b52db71f8fe66c06518f77cc44905cdf21520d2e Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Mon, 7 Apr 2025 20:59:02 -0400 Subject: [PATCH 20/41] Adds ability to configure Project & Base URL via env (#144) * Simplify support for Project-based auth * feat: add env config for base url * fix: correct crash if .env|.env.example missing * chore: typo on docblock --------- Co-authored-by: Evosite <60429439+evosite-ltd@users.noreply.github.com> --- README.md | 17 +++++++++++++++++ config/openai.php | 21 +++++++++++++++++++++ src/Commands/InstallCommand.php | 9 +++++++++ src/ServiceProvider.php | 17 ++++++++++++++--- 4 files changed, 61 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4e68322..8e5143c 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,23 @@ OPENAI_API_KEY= OPENAI_ORGANIZATION= ``` +### OpenAI Project + +For implementations that require a project ID, you can specify +the OpenAI project ID in your environment variables. + +```env +OPENAI_PROJECT=proj_... +``` + +### OpenAI API Base URL + +The base URL for the OpenAI API. By default, this is set to `api.openai.com/v1`. + +```env +OPENAI_BASE_URL= +``` + ### Request Timeout The timeout may be used to specify the maximum number of seconds to wait diff --git a/config/openai.php b/config/openai.php index 67806b4..ebf66eb 100644 --- a/config/openai.php +++ b/config/openai.php @@ -15,6 +15,27 @@ 'api_key' => env('OPENAI_API_KEY'), 'organization' => env('OPENAI_ORGANIZATION'), + /* + |-------------------------------------------------------------------------- + | OpenAI API Project + |-------------------------------------------------------------------------- + | + | Here you may specify your OpenAI API project. This is used optionally in + | situations where you are using a legacy user API key and need association + | with a project. This is not required for the newer API keys. + */ + 'project' => env('OPENAI_PROJECT'), + + /* + |-------------------------------------------------------------------------- + | OpenAI Base URL + |-------------------------------------------------------------------------- + | + | Here you may specify your OpenAI API base URL used to make requests. This + | is needed if using a custom API endpoint. Defaults to: api.openai.com/v1 + */ + 'base_uri' => env('OPENAI_BASE_URL'), + /* |-------------------------------------------------------------------------- | Request Timeout diff --git a/src/Commands/InstallCommand.php b/src/Commands/InstallCommand.php index fb26c62..7bd4a06 100644 --- a/src/Commands/InstallCommand.php +++ b/src/Commands/InstallCommand.php @@ -78,6 +78,15 @@ private function copyConfig(): void private function addEnvKeys(string $envFile): void { + if (! is_writable(base_path($envFile))) { + View::render('components.two-column-detail', [ + 'left' => $envFile, + 'right' => 'File is not writable.', + ]); + + return; + } + $fileContent = file_get_contents(base_path($envFile)); if ($fileContent === false) { diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index a6e6808..410fd98 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -25,17 +25,28 @@ public function register(): void $this->app->singleton(ClientContract::class, static function (): Client { $apiKey = config('openai.api_key'); $organization = config('openai.organization'); + $project = config('openai.project'); + $baseUri = config('openai.base_uri'); if (! is_string($apiKey) || ($organization !== null && ! is_string($organization))) { throw ApiKeyIsMissing::create(); } - return OpenAI::factory() + $client = OpenAI::factory() ->withApiKey($apiKey) ->withOrganization($organization) ->withHttpHeader('OpenAI-Beta', 'assistants=v2') - ->withHttpClient(new \GuzzleHttp\Client(['timeout' => config('openai.request_timeout', 30)])) - ->make(); + ->withHttpClient(new \GuzzleHttp\Client(['timeout' => config('openai.request_timeout', 30)])); + + if (is_string($project)) { + $client->withProject($project); + } + + if (is_string($baseUri)) { + $client->withBaseUri($baseUri); + } + + return $client->make(); }); $this->app->alias(ClientContract::class, 'openai'); From 9b76175cde5053e8eadbc6638a45c864bcf8ed26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Marmillod?= <9134609+fredmarmillod@users.noreply.github.com> Date: Fri, 18 Apr 2025 15:13:19 +0200 Subject: [PATCH 21/41] build: update openai-php/client dependency to version 0.10.3 in composer.json (#148) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 979b08e..bcba6f8 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "php": "^8.1.0", "guzzlehttp/guzzle": "^7.9.2", "laravel/framework": "^9.46.0|^10.34.2|^11.29.0|^12.0", - "openai-php/client": "^0.10.2" + "openai-php/client": "^0.10.3" }, "require-dev": { "laravel/pint": "^1.18.1", From 1eb355d3a9b03fa6340467b4a1a9683a6181e5a3 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 4 May 2025 14:41:59 +0100 Subject: [PATCH 22/41] chore: bumps dependencies --- .github/workflows/formats.yml | 2 +- .github/workflows/tests.yml | 19 ++++++++++++------- .gitignore | 1 + composer.json | 18 +++++++++--------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.github/workflows/formats.yml b/.github/workflows/formats.yml index 9ceeb95..ab7c16a 100644 --- a/.github/workflows/formats.yml +++ b/.github/workflows/formats.yml @@ -10,7 +10,7 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.4] + php: [8.2] dependency-version: [prefer-stable] name: Formats P${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b616542..56c8159 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,16 +9,15 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.1, 8.2, 8.3, 8.4] - laravel: [12.*, 11.*, 10.*, 9.*] + php: [8.2, 8.3, 8.4] + laravel: [12.*] + pest: [3, 4] dependency-version: [prefer-lowest, prefer-stable] exclude: - - php: 8.1 - laravel: 11.* - - php: 8.1 - laravel: 12.* + - php: 8.2 + pest: 4 - name: Tests P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} + name: Tests P${{ matrix.php }} - P${{ matrix.pest }} - L${{ matrix.laravel }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} steps: - name: Checkout @@ -37,6 +36,12 @@ jobs: extensions: dom, mbstring, zip coverage: none + - name: Require Pest Version + run: > + composer require + "pestphp/pest:${{ matrix.pest }}" + --no-interaction --no-update + - name: Require Laravel Version run: > composer require diff --git a/.gitignore b/.gitignore index 8e954e3..6cbd5a4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /vendor/ *.swp *.swo +.idea/ diff --git a/composer.json b/composer.json index bcba6f8..6203758 100644 --- a/composer.json +++ b/composer.json @@ -10,17 +10,17 @@ } ], "require": { - "php": "^8.1.0", - "guzzlehttp/guzzle": "^7.9.2", - "laravel/framework": "^9.46.0|^10.34.2|^11.29.0|^12.0", - "openai-php/client": "^0.10.3" + "php": "^8.2.0", + "guzzlehttp/guzzle": "^7.9.3", + "laravel/framework": "^12.12", + "openai-php/client": "^0.11.0" }, "require-dev": { - "laravel/pint": "^1.18.1", - "pestphp/pest": "^2.35.1|^3.5.0", - "pestphp/pest-plugin-arch": "^2.7.0|^3.0.0", - "phpstan/phpstan": "^1.12.7", - "symfony/var-dumper": "^6.4.0|^7.1.5" + "laravel/pint": "^1.22.0", + "pestphp/pest": "^3.8.2|^4.0.0", + "pestphp/pest-plugin-arch": "^3.1.1|^4.0.0", + "phpstan/phpstan": "^1.12.25", + "symfony/var-dumper": "^7.2.6" }, "autoload": { "psr-4": { From 184a4c23721233b11730cb7097bb2813b7638e9e Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 4 May 2025 14:45:33 +0100 Subject: [PATCH 23/41] chore: bumps dependencies --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 56c8159..8cc2517 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -40,13 +40,13 @@ jobs: run: > composer require "pestphp/pest:${{ matrix.pest }}" - --no-interaction --no-update + --no-interaction --no-update --with-all-dependencies - name: Require Laravel Version run: > composer require "laravel/framework:${{ matrix.laravel }}" - --no-interaction --no-update + --no-interaction --no-update --with-all-dependencies - name: Install Composer dependencies run: composer update --${{ matrix.dependency-version }} --no-interaction --prefer-dist From 4de20c010ad83144a2bcb0c2d1a554f99730a054 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 4 May 2025 14:53:15 +0100 Subject: [PATCH 24/41] chore: bumps dependencies --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8cc2517..bd48e7c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: matrix: os: [ubuntu-latest] php: [8.2, 8.3, 8.4] - laravel: [12.*] + laravel: [12] pest: [3, 4] dependency-version: [prefer-lowest, prefer-stable] exclude: @@ -39,13 +39,13 @@ jobs: - name: Require Pest Version run: > composer require - "pestphp/pest:${{ matrix.pest }}" + "pestphp/pest:^${{ matrix.pest }}" --no-interaction --no-update --with-all-dependencies - name: Require Laravel Version run: > composer require - "laravel/framework:${{ matrix.laravel }}" + "laravel/framework:^${{ matrix.laravel }}" --no-interaction --no-update --with-all-dependencies - name: Install Composer dependencies From 79958886d6da28501202563d52b93a29f72f8ad5 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Sun, 4 May 2025 14:56:25 +0100 Subject: [PATCH 25/41] chore: uses 0.12 of the client --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6203758..5c1a174 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "php": "^8.2.0", "guzzlehttp/guzzle": "^7.9.3", "laravel/framework": "^12.12", - "openai-php/client": "^0.11.0" + "openai-php/client": "^0.12.0" }, "require-dev": { "laravel/pint": "^1.22.0", From 97a115797261ea4ac8b567036e5c2dbcee9c2b3a Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Sun, 4 May 2025 19:34:58 -0400 Subject: [PATCH 26/41] docs: add release notes for 0.11 and 0.12 (#150) --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 64cd014..32a8063 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## v0.12.0 (2025-05-04) +### Added +- Add facade for `fineTuning` ([#125](https://github.com/openai-php/laravel/pull/125)) +- Make base url configurable ([#144](https://github.com/openai-php/laravel/pull/144)) + +### Changed +- Changed underlying `openai/client` package version from 0.11.0 to 0.12.0 + +### Removed +- Removed support for PHP 8.1 + +## v0.11.0 (2025-02-24) +### Added +- Add support for Laravel 12 ([#137](https://github.com/openai-php/laravel/pull/137)) + ## v0.10.1 (2024-06-06) ### Changed - Changed underlying `openai/client` package version from 0.9.1 to v0.10.1 From 1b3a9a64ab8cdb16a0c3b15b7d8352fd333b62bf Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Sun, 4 May 2025 19:37:44 -0400 Subject: [PATCH 27/41] docs: update readme for php8.2 requirement (#151) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e5143c..f68de3e 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ ## Get Started -> **Requires [PHP 8.1+](https://php.net/releases/)** +> **Requires [PHP 8.2+](https://www.php.net/releases/)** First, install OpenAI via the [Composer](https://getcomposer.org/) package manager: From 92b2412fdf42c85245e8137ad82158ca647394bd Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Wed, 14 May 2025 13:27:18 -0400 Subject: [PATCH 28/41] build: restore Laravel 11 support (#152) * build: restore Laravel 11 support * test: assert on L11 also in suite --- .github/workflows/tests.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bd48e7c..7ab8996 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: matrix: os: [ubuntu-latest] php: [8.2, 8.3, 8.4] - laravel: [12] + laravel: [11, 12] pest: [3, 4] dependency-version: [prefer-lowest, prefer-stable] exclude: diff --git a/composer.json b/composer.json index 5c1a174..4660d1b 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "require": { "php": "^8.2.0", "guzzlehttp/guzzle": "^7.9.3", - "laravel/framework": "^12.12", + "laravel/framework": "^11.29|^12.12", "openai-php/client": "^0.12.0" }, "require-dev": { From fd959b415f7544c864fa03d789d496b0015596f3 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Wed, 14 May 2025 17:52:39 -0400 Subject: [PATCH 29/41] feat: add Responses API to Facade + bump openai-php/client version (#147) * feat: add Responses API to Facade * chore: uses 0.13 of the client --- composer.json | 2 +- src/Facades/OpenAI.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4660d1b..0a47652 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "php": "^8.2.0", "guzzlehttp/guzzle": "^7.9.3", "laravel/framework": "^11.29|^12.12", - "openai-php/client": "^0.12.0" + "openai-php/client": "^0.13.0" }, "require-dev": { "laravel/pint": "^1.22.0", diff --git a/src/Facades/OpenAI.php b/src/Facades/OpenAI.php index 7ad1b02..94c69a4 100644 --- a/src/Facades/OpenAI.php +++ b/src/Facades/OpenAI.php @@ -23,6 +23,7 @@ * @method static \OpenAI\Resources\Images images() * @method static \OpenAI\Resources\Models models() * @method static \OpenAI\Resources\Moderations moderations() + * @method static \OpenAI\Resources\Responses responses() * @method static \OpenAI\Resources\Threads threads() * @method static \OpenAI\Resources\VectorStores vectorStores() */ From a06af65a4a5cacceea9778d2228c73e72de0a9e2 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Wed, 14 May 2025 18:07:36 -0400 Subject: [PATCH 30/41] release: v0.13.0 (#153) --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32a8063..cd1c04c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## v0.13.0 (2025-05-14) +### Added +- Add facade for `responses` ([#147](https://github.com/openai-php/laravel/pull/147)) + +### Changed +- Changed underlying `openai/client` package version from 0.12.0 to 0.13.0 +- Restored Laravel 11 support. + ## v0.12.0 (2025-05-04) ### Added - Add facade for `fineTuning` ([#125](https://github.com/openai-php/laravel/pull/125)) From d8d092cba515aa0d9f1f9ded40ecd713bbc8461f Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Tue, 24 Jun 2025 06:54:04 -0400 Subject: [PATCH 31/41] feat(meta): Add support for 0.14.0 of client + realtime facade. (#156) * build: move to minimum 0.14.0 of client * feat: add realtime facade --- composer.json | 2 +- src/Facades/OpenAI.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0a47652..60cd36b 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "php": "^8.2.0", "guzzlehttp/guzzle": "^7.9.3", "laravel/framework": "^11.29|^12.12", - "openai-php/client": "^0.13.0" + "openai-php/client": "^0.14.0" }, "require-dev": { "laravel/pint": "^1.22.0", diff --git a/src/Facades/OpenAI.php b/src/Facades/OpenAI.php index 94c69a4..09f6aaf 100644 --- a/src/Facades/OpenAI.php +++ b/src/Facades/OpenAI.php @@ -23,6 +23,7 @@ * @method static \OpenAI\Resources\Images images() * @method static \OpenAI\Resources\Models models() * @method static \OpenAI\Resources\Moderations moderations() + * @method static \OpenAI\Resources\Realtime realtime() * @method static \OpenAI\Resources\Responses responses() * @method static \OpenAI\Resources\Threads threads() * @method static \OpenAI\Resources\VectorStores vectorStores() From cee51d2502c1ff50580269db5a773cd84be76066 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Tue, 24 Jun 2025 06:56:22 -0400 Subject: [PATCH 32/41] release: v0.14.0 (#157) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd1c04c..37da658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## v0.14.0 (2025-06-24) +### Added +- Add facade for `realtime`. ([#156](https://github.com/openai-php/laravel/pull/156)) + +### Changed +- Changed underlying `openai/client` package version from 0.13.0 to 0.14.0 + ## v0.13.0 (2025-05-14) ### Added - Add facade for `responses` ([#147](https://github.com/openai-php/laravel/pull/147)) From 70ec1da271a316e095a03c61e1c43beb779707b3 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Mon, 4 Aug 2025 13:52:10 -0400 Subject: [PATCH 33/41] feat(meta): Add support for 0.15.0 of client + container facade. (#161) * feat: add containers api to facade * chore: request at least v0.15.0 of client --- composer.json | 2 +- src/Facades/OpenAI.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 60cd36b..491a619 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "php": "^8.2.0", "guzzlehttp/guzzle": "^7.9.3", "laravel/framework": "^11.29|^12.12", - "openai-php/client": "^0.14.0" + "openai-php/client": "^0.15.0" }, "require-dev": { "laravel/pint": "^1.22.0", diff --git a/src/Facades/OpenAI.php b/src/Facades/OpenAI.php index 09f6aaf..cdc2921 100644 --- a/src/Facades/OpenAI.php +++ b/src/Facades/OpenAI.php @@ -15,6 +15,7 @@ * @method static \OpenAI\Resources\Batches batches() * @method static \OpenAI\Resources\Chat chat() * @method static \OpenAI\Resources\Completions completions() + * @method static \OpenAI\Resources\Containers containers() * @method static \OpenAI\Resources\Embeddings embeddings() * @method static \OpenAI\Resources\Edits edits() * @method static \OpenAI\Resources\Files files() From 399f6f4cc1cb218d175128a456857e878f91117d Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Mon, 4 Aug 2025 13:56:40 -0400 Subject: [PATCH 34/41] release: v0.15.0 (#162) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37da658..4361b87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## v0.15.0 (2025-08-04) +### Added +- Add facade for `containers`. ([#161](https://github.com/openai-php/laravel/pull/161)) + +### Changed +- Changed underlying `openai/client` package version from 0.14.0 to 0.15.0 + ## v0.14.0 (2025-06-24) ### Added - Add facade for `realtime`. ([#156](https://github.com/openai-php/laravel/pull/156)) From 98fb53b2891caacccf46bc0fb824cf8408353800 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 16:33:54 -0400 Subject: [PATCH 35/41] build(deps): bump actions/checkout from 4 to 5 (#163) Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/formats.yml | 2 +- .github/workflows/tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/formats.yml b/.github/workflows/formats.yml index ab7c16a..50b36af 100644 --- a/.github/workflows/formats.yml +++ b/.github/workflows/formats.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Cache dependencies uses: actions/cache@v4 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7ab8996..4937678 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,7 +21,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Cache dependencies uses: actions/cache@v4 From 2350b464b9ac4a80933352c8984f0ce1c9fbab11 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Tue, 26 Aug 2025 08:34:53 -0400 Subject: [PATCH 36/41] feat(meta): Add support for 0.16.0 of client (#165) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 491a619..39309d3 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "php": "^8.2.0", "guzzlehttp/guzzle": "^7.9.3", "laravel/framework": "^11.29|^12.12", - "openai-php/client": "^0.15.0" + "openai-php/client": "^0.16.0" }, "require-dev": { "laravel/pint": "^1.22.0", From 0af3c787af03f1aaac02f7c8cd6a917dbfd3fd32 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Tue, 26 Aug 2025 08:38:12 -0400 Subject: [PATCH 37/41] release: v0.16.0 (#166) --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4361b87..687f8b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## v0.16.0 (2025-08-26) +### Changed + - Changed underlying `openai/client` package version from 0.15.0 to 0.16.0 + - HTTP 429 now throw a `RateLimitException` instead of a generic `ErrorException` + ## v0.15.0 (2025-08-04) ### Added - Add facade for `containers`. ([#161](https://github.com/openai-php/laravel/pull/161)) From 8d6dedd3077110e85f6174cb1469fca8c4532a3a Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Tue, 26 Aug 2025 08:45:52 -0400 Subject: [PATCH 38/41] docs: migrate readme to responses api --- README.md | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index f68de3e..37f3557 100644 --- a/README.md +++ b/README.md @@ -46,14 +46,12 @@ Finally, you may use the `OpenAI` facade to access the OpenAI API: ```php use OpenAI\Laravel\Facades\OpenAI; -$result = OpenAI::chat()->create([ - 'model' => 'gpt-4o-mini', - 'messages' => [ - ['role' => 'user', 'content' => 'Hello!'], - ], +$result = OpenAI::responses()->create([ + 'model' => 'gpt-5', + 'input' => 'Hello!', ]); -echo $result->choices[0]->message->content; // Hello! How can I assist you today? +echo $response->outputText; // Hello! How can I assist you today? ``` ## Configuration @@ -111,7 +109,7 @@ All responses are having a `fake()` method that allows you to easily create a re ```php use OpenAI\Laravel\Facades\OpenAI; -use OpenAI\Responses\Completions\CreateResponse; +use OpenAI\Responses\Responses\CreateResponse; OpenAI::fake([ CreateResponse::fake([ @@ -123,21 +121,21 @@ OpenAI::fake([ ]), ]); -$completion = OpenAI::completions()->create([ - 'model' => 'gpt-4o-mini', - 'prompt' => 'PHP is ', +$response = OpenAI::responses()->create([ + 'model' => 'gpt-5', + 'input' => 'PHP is ', ]); -expect($completion['choices'][0]['text'])->toBe('awesome!'); +expect($response->outputText)->toBe('awesome!'); ``` After the requests have been sent there are various methods to ensure that the expected requests were sent: ```php // assert completion create request was sent -OpenAI::assertSent(Completions::class, function (string $method, array $parameters): bool { +OpenAI::assertSent(Responses::class, function (string $method, array $parameters): bool { return $method === 'create' && - $parameters['model'] === 'gpt-4o-mini' && + $parameters['model'] === 'gpt-5' && $parameters['prompt'] === 'PHP is '; }); ``` From 088626820bff8436321e6b8b2e50828fed1e3dbb Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Wed, 27 Aug 2025 06:06:50 -0400 Subject: [PATCH 39/41] build(meta): upgrade to phpstan v2 (#168) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 39309d3..ffa6c11 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "laravel/pint": "^1.22.0", "pestphp/pest": "^3.8.2|^4.0.0", "pestphp/pest-plugin-arch": "^3.1.1|^4.0.0", - "phpstan/phpstan": "^1.12.25", + "phpstan/phpstan": "^2.1", "symfony/var-dumper": "^7.2.6" }, "autoload": { From 802080ce55f9f33d7fdd75d81795f152e89e64eb Mon Sep 17 00:00:00 2001 From: Hijen EL Khalifi Date: Thu, 28 Aug 2025 14:47:45 +0100 Subject: [PATCH 40/41] docs(meta): correct README for wrong intermediate variable in example (#169) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37f3557..d452d93 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Finally, you may use the `OpenAI` facade to access the OpenAI API: ```php use OpenAI\Laravel\Facades\OpenAI; -$result = OpenAI::responses()->create([ +$response = OpenAI::responses()->create([ 'model' => 'gpt-5', 'input' => 'Hello!', ]); From d60f0a07c2d3b7bed8940e3633b9328386ec4195 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Thu, 4 Sep 2025 11:27:02 -0400 Subject: [PATCH 41/41] feat(meta): Add support for 0.16.1 of client (#171) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ffa6c11..40ba5ce 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "php": "^8.2.0", "guzzlehttp/guzzle": "^7.9.3", "laravel/framework": "^11.29|^12.12", - "openai-php/client": "^0.16.0" + "openai-php/client": "^0.16.1" }, "require-dev": { "laravel/pint": "^1.22.0",