Repository navigation
Description
Summary
laravel/ai (tested with v0.11.2) declares aws/aws-sdk-php: ^3.369.1 under require in vendor/laravel/ai/composer.json:
"require": {
"php": "^8.3",
"aws/aws-sdk-php": "^3.369.1",
"illuminate/console": "^12.0|^13.0",
...
},
"suggest": {
"laravel/mcp": "Required to use MCP client tools or MCP server tools with Laravel AI agents."
}The AWS SDK is only needed for a single optional driver — Bedrock — but Composer forces it on every consumer, even when they only use openai, gemini, anthropic, ollama, etc. It should be demoted to suggest, following the existing precedent for the optional laravel/mcp integration.
Evidence / Analysis
-
Only Bedrock touches
Aws\classes. Full-text search insidevendor/laravel/ai/src:src/Gateway/Bedrock/Concerns/CreatesBedrockClient.php:use Aws\BedrockRuntime\BedrockRuntimeClient; use Aws\Credentials\AssumeRoleCredentialProvider; use Aws\Credentials\CredentialProvider; use Aws\Middleware; use Aws\Sts\StsClient;
src/Gateway/Bedrock/BedrockException.php:use Aws\BedrockRuntime\Exception\BedrockRuntimeException;
src/Providers/BedrockProvider.php,src/Gateway/Bedrock/BedrockTextGateway.php,BedrockImageGateway.php,BedrockRerankingGateway.php— only wire the gateways above.- No other provider/gateway (
OpenAI,Gemini,Anthropic,Groq,Xai,Ollama,Mistral,DeepSeek,VoyageAI,Cohere,ElevenLabs,Jina) referencesAws\.
-
Usage is lazy, not eager.
AiManager::createBedrockDriver()only instantiatesBedrockProviderwhen thebedrockconnection is resolved.BedrockRuntimeClient/StsClientare only constructed insideCreatesBedrockClient::createBedrockClient()/createStsClient()at request time. If the app never selects thebedrockdriver, the SDK classes are never loaded. -
Precedent already exists in the same
composer.json.laravel/mcpis correctly placed undersuggest:"suggest": { "laravel/mcp": "Required to use MCP client tools or MCP server tools with Laravel AI agents." }
AWS SDK deserves identical treatment:
Required to use the Bedrock driver.
Impact
- Install bloat:
aws/aws-sdk-php(~tens of MB, hundreds of service clients, e.g.vendor/awsin this checkout) is downloaded for 100% of users but used by a minority (Bedrock-only). - Larger attack / audit surface and slower
composer install/update, CI, Docker builds. - Version conflicts: apps that pin AWS SDK differently (or use a hardened/forked SDK, or want no AWS code at all) are forced into
^3.369.1. - Conceptual inconsistency: 16+ HTTP-based providers in
config/ai.phpwork with plain HTTP (Guzzle/Laravel HTTP client) and need no extra SDK; onlybedrockneeds SigV4/STS/Bearer helpers from the SDK. - Shared-hosting / offline penalty: relevant for downstream distributions such as OpenSID that target village servers with limited bandwidth/disk.
Expected Behavior
Move the dependency to suggest:
"require": {
"php": "^8.3",
"illuminate/console": "^12.0|^13.0",
...
},
"suggest": {
"aws/aws-sdk-php": "Required to use the AWS Bedrock driver (^3.369.1).",
"laravel/mcp": "Required to use MCP client tools or MCP server tools with Laravel AI agents."
}And fail gracefully with an actionable message when Bedrock is requested without the SDK, e.g. in CreatesBedrockClient or AiManager::createBedrockDriver():
if (! class_exists(\Aws\BedrockRuntime\BedrockRuntimeClient::class)) {
throw new \RuntimeException(
'The AWS Bedrock driver requires [aws/aws-sdk-php]. Install it via: composer require aws/aws-sdk-php:^3.369.1'
);
}This mirrors how Laravel ecosystem packages (Cashier, Scout drivers, Socialite providers, Notification channels) handle optional SDKs.
Proposed Fix (upstream laravel/ai)
- Remove
"aws/aws-sdk-php": "^3.369.1"fromrequire. - Add
"aws/aws-sdk-php": "Required to use the Bedrock AI provider."tosuggest. - Add
class_existsguard +RuntimeException/AiExceptionwith install hint inCreatesBedrockClient::createBedrockClient()(and optionallycreateStsClient()). - Document in README / https://laravel.com/docs/ai-sdk that Bedrock needs
composer require aws/aws-sdk-php. - Optional: add CI matrix job testing
--no-suggest/ without AWS SDK to prove non-Bedrock drivers still work.
Workaround (downstream, until fixed upstream)
No clean workaround — require is transitive and cannot be skipped. Options are all undesirable:
- Accept the bloat (
composer require laravel/aialways bringsaws/aws-sdk-php). - Fork
laravel/aiand strip the requirement (maintenance burden). - Post-install removal hacks (breaks autoloader / integrity checks).
Environment
laravel/ai:v0.11.2(vendor/laravel/ai/composer.json,composer.lock:3126)- Transitive:
aws/aws-sdk-php:3.395.2(composer.lock:944) - Downstream:
opendesa/opensid(composer.json:30), PHP^8.4, Laravel^13.8 - Config under test:
vendor/laravel/ai/config/ai.php(providers.bedrock, lines 71–85)
Checklist
- Verified
use Aws\only appears inGateway/Bedrock/*(2 files) via codebase search. - Verified Bedrock client creation is lazy (
AiManager::createBedrockDriver,CreatesBedrockClienttrait). - Verified existing
suggestprecedent (laravel/mcp) in samecomposer.json. - Upstream fix: move
aws/aws-sdk-phpfromrequire→suggest+ runtime guard. - Docs update for Bedrock installation step.
Activity
github-actions commentedon Sep 15, 2026
Thank you for reporting this issue!
As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub.
If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team.
Thank you!
Mohammad-Ranjbar commentedon Sep 15, 2026
Hi, I’d like to work on this.
To keep the change focused, I plan to move
aws/aws-sdk-phpout of the production requirements, add it as a development dependency and Composer suggestion, add an actionable failure when the Bedrock driver is used without the SDK, and cover that behavior with a regression test.Would you prefer the Bedrock installation documentation update in the same pull request?
nunomaduro commentedon Sep 16, 2026
just raised this discussion with @pushpak1300, we will came back to you on this.