symfony/ai-bedrock-platform
AWS Bedrock bridge for Symfony AI. Invoke Bedrock foundation models (Claude, Llama, Nova, and more) via the Bedrock Runtime API, with helpers aligned to Bedrock request/response schemas for easy integration into Symfony apps.
ClientInterface, Message, Stream), which can be seamlessly integrated into Laravel via Symfony’s bridge packages (e.g., symfony/flex, symfony/console). Laravel’s service container and facades can wrap the Bedrock client, providing a clean API (e.g., Bedrock::invokeModel()) while hiding AWS SDK complexity.claude for premium users, llama for cost-sensitive workflows). This reduces coupling to specific models and simplifies future migrations.Response::json()) and Eloquent models, reducing manual parsing overhead.ListFoundationModels command (v0.7.0) can be extended into a Laravel Artisan command (e.g., php artisan bedrock:models), enabling devops-friendly model management.aws/aws-sdk-php integrations (e.g., fruitcake/laravel-aws) can handle credentials, regions, and retries. The package’s reliance on Bedrock’s Runtime API (InvokeModel) is well-supported by the SDK..env and config files can centralize Bedrock settings (e.g., BEDROCK_REGION, AWS_ACCESS_KEY_ID), while environment-based routing (e.g., staging → llama, prod → claude) can be implemented via service providers.InvalidArgumentException for string payloads (v0.6.0) aligns with Laravel’s type safety (e.g., Illuminate\Support\Str::of()), reducing runtime errors in request/response pipelines.ListFoundationModels feature can be cached in Laravel’s database or Redis, with a TTL-based refresh (e.g., hourly) to avoid API throttling.BedrockCostMiddleware) can log usage, while AWS Budgets can trigger alerts. A fallback to cheaper models (e.g., amazon.titan-text-lite) may be needed for high-volume features.Str::of($prompt)->encrypt()) and AWS KMS can help, but input validation (e.g., blocking PII) is essential.aws-sdk)?AppServiceProvider:
$this->app->bind(\Symfony\AiBedrock\BedrockClientInterface::class, function ($app) {
return new \Symfony\AiBedrock\BedrockClient(
$app['config']['bedrock.region'],
$app['config']['bedrock.credentials']
);
});
Bedrock::invoke('anthropic.claude-v2', $prompt)).config/bedrock.php:
'models' => [
'default' => 'anthropic.claude-v2',
'fallback' => 'amazon.titan-text-express',
'routing' => [
'premium_users' => 'anthropic.claude-v2',
'default' => 'meta.llama-2-70b',
],
],
'aws' => [
'region' => env('BEDROCK_REGION', 'us-east-1'),
'credentials' => env('AWS_CREDENTIALS'),
'max_retries' => 3,
],
.env) for secrets:
BEDROCK_REGION=us-east-1
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
$models = Cache::remember('bedrock.models', now()->addHours(1), function () {
return $this->bedrockClient->listFoundationModels();
});
Symfony\AI\ClientInterface to wrap the Bedrock client:
class BedrockClient implements ClientInterface
{
public function invoke(ModelInterface $model, Message ...$messages): Response
{
return $this->bedrockClient->invokeModel($model->getName(), $messages);
}
}
Message and Stream for structured input/output.composer require symfony/ai-bedrock-platform aws/aws-sdk-php.php artisan vendor:publish --provider="Symfony\AiBedrock\BedrockServiceProvider"..env and config/bedrock.php.Bedrock::invoke('anthropic.claude-v2', 'Hello')).How can I help you explore Laravel packages today?