OpenAI PHP for Laravel is a Laravel integration package that allows you to interact with the OpenAI API from within Laravel applications.
The package solves the problem of integrating OpenAI API calls into Laravel projects by providing a Laravel facade and configuration system. It wraps the framework-agnostic OpenAI PHP client and adds Laravel-specific conveniences like environment variable configuration, a publishable config file, and facade-based access to API methods.
Developers building Laravel applications that need to call OpenAI endpoints should choose this package. It suits any Laravel project requiring chat completions, embeddings, or other OpenAI capabilities. The package requires PHP 8.2 or higher. For framework-agnostic PHP projects not using Laravel, the underlying openai-php/client library is available as an alternative. The tool includes built-in testing support through a fake() method on the facade, allowing you to mock API responses and verify that expected requests were sent during testing.
The project maintains active test coverage with continuous integration checks. Documentation is kept minimal in the repository itself, with usage examples and detailed testing patterns delegated to the underlying client library repository. Configuration is straightforward and environment-variable driven, with an install command that scaffolds the necessary config file and .env entries.