Documentation Index
Fetch the complete documentation index at: https://mintlify.com/phpaisdk/core/llms.txt
Use this file to discover all available pages before exploring further.
aisdk/core is distributed through Packagist and installed with Composer. The core package contains no HTTP transport — you always pair it with at least one provider package that handles the actual API calls. This page walks you through a complete installation from scratch.
Installation Steps
Install the core package
Add This pulls in the contracts, fluent generation API, value objects, and all PSR dependencies listed below.
aisdk/core to your project using Composer:Install a provider package
Install the provider for whichever AI service you want to use. The OpenAI provider is shown here as the primary example:If you prefer Anthropic:
You can install multiple providers in the same project and switch between them per request by passing a different model instance to
->model().HTTP client auto-discovery
No additional HTTP client setup is required.
aisdk/core depends on guzzlehttp/guzzle and uses php-http/discovery to automatically locate a PSR-18-compatible HTTP client at runtime. Because Guzzle is already a required dependency, Psr18ClientDiscovery::find() resolves it without any manual wiring.If you want to supply your own PSR-18 client — for example to add middleware or use a mock in tests — see the Custom HTTP Client section below.Requirements
| Requirement | Version |
|---|---|
| PHP | ^8.3 |
guzzlehttp/guzzle | ^7.8 |
php-http/discovery | ^1.19 |
psr/container | ^2.0 |
psr/http-client | ^1.0 |
psr/http-factory | ^1.1 |
psr/http-message | ^2.0 |
psr/log | ^3.0 |
psr/simple-cache | ^3.0 |
Framework Integration
aisdk/core has no opinion about your application framework. It works in any PHP environment:
Laravel
Register
Generate::model(...) in a service provider’s boot() method. No additional service container binding is required.Symfony
Call
Generate::model(...) in a kernel event listener or compiler pass. The SDK’s SdkFactory accepts a PSR-11 ContainerInterface if you want tighter integration.Plain PHP
Call
Generate::model(...) anywhere before your first generation call — in index.php, a bootstrap file, or a CLI entry point.Custom HTTP Client
By default the SDK auto-discovers Guzzle viaphp-http/discovery. To override this — for example to inject a logger, add retry middleware, or use a test double — build a custom Sdk instance with SdkFactory and pass it to Generate::configure():