Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Symfony Laravel Package

openai-php/symfony

Symfony bundle for the OpenAI PHP client, making it easy to integrate GPT models, chat completions, embeddings, and other OpenAI API features into Symfony apps with simple configuration and dependency injection.

View on GitHub
Deep Wiki
Context7

⚡️ OpenAI PHP for Symfony is a supercharged PHP API client that allows you to interact with OpenAI API

Frequently asked questions about Symfony
Does openai-php/symfony work with Laravel?
No. openai-php/symfony is a Symfony bundle that registers the framework-agnostic openai-php/client in Symfony's dependency injection container, and there is no supported path to load it inside a Laravel application. For Laravel you should install openai-php/client directly and bind it as a singleton in a service provider, or use openai-php/laravel if you want first-party Laravel wiring. In a Laravel codebase the bundle's Symfony service configuration layer is pure dead weight.
What is the difference between openai-php/symfony and openai-php/client?
openai-php/client is the framework-agnostic API client that contains all the actual OpenAI logic, while openai-php/symfony is a thin bundle that wires that client into the Symfony container and exposes configuration. The bundle ships in lockstep with the client, so most bundle releases simply track a client release. If you are not building on Symfony, the bundle adds little beyond container registration.
How do I install openai-php/symfony?
Install it with Composer using composer require openai-php/symfony, which pulls in the matching openai-php/client version. You then enable the bundle in your Symfony bundle configuration and supply an API key. The client needs a PSR-18 and PSR-17 implementation, so confirm an HTTP client such as Symfony HttpClient or Guzzle is present, and check the release's composer.json for the exact PHP and Symfony constraints since both artifacts are pre-1.0.
How do I configure the OpenAI API key for this Symfony bundle?
Configuration comes through the bundle's config tree and is normally fed by an environment variable such as OPENAI_API_KEY so the secret never lands in version control. Set it in your local .env file and in the real environment configuration for staging and production. Avoid hardcoding the key into config files that are committed to the repository.
What OpenAI features can I use with openai-php/symfony?
Because the bundle wraps openai-php/client, you get the client's full surface: chat completions, embeddings, image generation, audio transcription, moderation, and file operations. Streaming responses are handled through the client's stream API. Feature availability depends entirely on the underlying client version, so check the client changelog for the version you have locked.
How do I inject the OpenAI client into a Symfony service?
The bundle registers the client as a container service, so you can autowire it into your controllers and services through constructor injection. Prefer hiding it behind your own application interface rather than type-hinting the third-party class everywhere, which keeps the client version an implementation detail. That abstraction also makes swapping in a fake during tests trivial.
How do I test OpenAI calls without hitting the real API?
Put the client behind an application-owned interface and inject a test double in your unit tests. For integration coverage you can point the client at a mock PSR-18 transport instead of the real HTTP layer. Keep at least one gated smoke test that performs a real completion call so upstream breaking changes surface quickly.
Is openai-php/symfony stable enough for production?
Both the bundle and the underlying client are pre-1.0, which under semver means minor releases are allowed to break compatibility. The risk is manageable because the client is a thin typed layer over HTTPS, but only if you pin versions with a committed lockfile. Do not float a caret constraint on 0.x in production without the lock, and budget a recurring dependency review slot.
Why does openai-php/symfony release a new version every time the client does?
The bundle declares a constraint on openai-php/client and must widen it whenever the client ships a new minor, which is why the version numbers move together. A release like 0.19.0 that only bumps the constraint to ^0.19.0 adds no new bundle API surface, config keys, or deprecations. The change you actually need to review is the client's own changelog between the two versions.
What should a Laravel team use instead of this Symfony bundle?
Use openai-php/client directly, bound as a singleton in a service provider and hidden behind your own interface, so the client version stays an implementation detail. Alternatively adopt openai-php/laravel if you want first-party Laravel configuration and facade-style wiring. Either way, commit a lockfile and gate upgrades on a smoke test that exercises one real completion call.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager