PHPackages                             revolution/laravel-amazon-bedrock - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. revolution/laravel-amazon-bedrock

ActiveLibrary[API Development](/categories/api)

revolution/laravel-amazon-bedrock
=================================

Amazon Bedrock driver for for Laravel AI SDK

0.8.0(3d ago)05.6k↑29%1MITPHPPHP ^8.3CI passing

Since Nov 26Pushed 1w ago1 watchersCompare

[ Source](https://github.com/invokable/laravel-amazon-bedrock)[ Packagist](https://packagist.org/packages/revolution/laravel-amazon-bedrock)[ GitHub Sponsors](https://github.com/invokable)[ RSS](/packages/revolution-laravel-amazon-bedrock/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (40)Versions (45)Used By (0)

Amazon Bedrock driver for Laravel AI SDK
========================================

[](#amazon-bedrock-driver-for-laravel-ai-sdk)

[![Maintainability](https://camo.githubusercontent.com/047525d254b8f8de849389d5da6350ef6cfa1bec7ea20c7e5153ef8eb0e2059d/68747470733a2f2f716c74792e73682f67682f696e766f6b61626c652f70726f6a656374732f6c61726176656c2d616d617a6f6e2d626564726f636b2f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/invokable/projects/laravel-amazon-bedrock)[![Code Coverage](https://camo.githubusercontent.com/e6fb0d455718fa1138df98a1049df6209ccc27c521bde3418211fc5c22096a00/68747470733a2f2f716c74792e73682f67682f696e766f6b61626c652f70726f6a656374732f6c61726176656c2d616d617a6f6e2d626564726f636b2f636f7665726167652e737667)](https://qlty.sh/gh/invokable/projects/laravel-amazon-bedrock)[![Ask DeepWiki](https://camo.githubusercontent.com/0f5ae213ac378635adeb5d7f13cef055ad2f7d9a47b36de7b1c67dbe09f609ca/68747470733a2f2f6465657077696b692e636f6d2f62616467652e737667)](https://deepwiki.com/invokable/laravel-amazon-bedrock)

Docs: [English](https://kawax.biz/en/packages/laravel-amazon-bedrock) [Japanese](https://kawax.biz/jp/packages/laravel-amazon-bedrock)

Overview
--------

[](#overview)

An Amazon Bedrock driver for the [Laravel AI SDK](https://laravel.com/docs/ai-sdk), enabling text generation, streaming, tool use (function calling), structured output, file attachments, embeddings, image generation, audio (TTS), and reranking via models on AWS Bedrock.

FeatureAPI keySupported ModelsText, Streaming✅Anthropic Claude, Amazon Nova, and most Bedrock models (all via Converse API)Tool Use✅Structured Output✅File Attachments✅Image, document, audio, and video attachments via Converse API (model support varies)Images✅Stability AI models (default), Amazon Nova Canvas (deprecated).Audio(TTS)⚠️Amazon Polly (generative, neural, long-form, standard engines)Transcription(STT)❌Not supportedEmbeddings✅Amazon Titan Embeddings V2 (default), Cohere Embed English/Multilingual V3, Cohere Embed V4 (batch support).Reranking⚠️Cohere Rerank 3.5, Amazon Rerank 1.0Files✅️Local file attachments supported via text generation; server-side upload and `fromId()` not supported> \[!INFO\] ⚠️ in this table means the feature is not available with only a Bedrock API key. It does not mean the feature itself is unsupported.

> \[!INFO\] Laravel AI SDK v0.6.3 added official Bedrock support for Text, Image, and Embeddings using a Bedrock API key. This package continues to be published because it also supports Audio (TTS via Amazon Polly) and Reranking — features not available through the official integration.

- **Authentication**: Bedrock API key, AWS IAM credentials (SigV4), or default AWS credential chain (IAM roles, instance profiles, etc.).
- **Failover**: Supports the AI SDK's multi-provider failover. Rate limit (429), overload (503, 529), and credit errors are mapped to failoverable exceptions.
- **Cache Control**: Ephemeral cache always enabled on system prompts via the [Bedrock Converse API](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference.html).
- **Unified API**: All models — Anthropic Claude, Amazon Nova, Meta Llama, Mistral, and more — are routed through the Bedrock Converse API for a consistent interface.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.3
- Laravel &gt;= 12.x

Installation
------------

[](#installation)

```
composer require revolution/laravel-amazon-bedrock
php artisan vendor:publish --provider="Laravel\Ai\AiServiceProvider"
```

Configuration
-------------

[](#configuration)

Add the `amazon-bedrock` driver to `config/ai.php`:

### Option 1: Bedrock API Key

[](#option-1-bedrock-api-key)

```
// config/ai.php
'default' => 'amazon-bedrock',
'default_for_images' => 'amazon-bedrock',
'default_for_audio' => 'amazon-bedrock',
'default_for_embeddings' => 'amazon-bedrock',
'default_for_reranking' => 'amazon-bedrock',

'providers' => [
    'amazon-bedrock' => [
        'driver' => 'amazon-bedrock',
        'key'    => env('AWS_BEDROCK_API_KEY', ''),
        'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
    ],
],
```

```
AWS_BEDROCK_API_KEY=your_api_key
AWS_DEFAULT_REGION=us-east-1
```

The Bedrock API key is obtained from the AWS Management Console.

Warning

The Bedrock API key can only be used with the Bedrock Runtime API. It cannot be used with `bedrock-agent-runtime` (reranking) or Amazon Polly (audio/TTS). Use SigV4 or the default AWS credential chain for these features.

### Option 2: AWS IAM Credentials (SigV4)

[](#option-2-aws-iam-credentials-sigv4)

Use AWS access key and secret key with [Signature Version 4](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html) signing:

```
// config/ai.php
'providers' => [
    'amazon-bedrock' => [
        'driver' => 'amazon-bedrock',
        'key'    => env('AWS_ACCESS_KEY_ID'),
        'secret' => env('AWS_SECRET_ACCESS_KEY'),
        'token'  => env('AWS_SESSION_TOKEN'),  // optional, for temporary credentials
        'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
    ],
],
```

```
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=wJalr...
AWS_SESSION_TOKEN=         # optional, for STS temporary credentials
AWS_DEFAULT_REGION=us-east-1
```

### Option 3: Default AWS Credential Chain (IAM Roles)

[](#option-3-default-aws-credential-chain-iam-roles)

For EC2 instances, ECS tasks, Lambda functions, or any environment with IAM roles — omit `key` and `secret` to use the [default AWS credential provider chain](https://docs.aws.amazon.com/sdkref/latest/guide/standardized-credentials.html):

```
// config/ai.php
'providers' => [
    'amazon-bedrock' => [
        'driver' => 'amazon-bedrock',
        'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
    ],
],
```

```
AWS_DEFAULT_REGION=us-east-1
```

The default credential chain automatically resolves credentials from environment variables, shared credentials files (`~/.aws/credentials`), ECS task roles, EC2 instance profiles, and more.

### Optional config keys

[](#optional-config-keys)

KeyDescriptionDefault`secret`AWS secret access key (SigV4)—`token`AWS session token (SigV4)—`timeout`HTTP request timeout in seconds30`max_tokens`Default max tokens per request8096`models.text.default`Default text model`global.anthropic.claude-sonnet-4-6``models.text.cheapest`Cheapest text model`global.anthropic.claude-haiku-4-5-20251001-v1:0``models.text.smartest`Smartest text model`global.anthropic.claude-opus-4-8``models.embeddings.default`Default embeddings model`amazon.titan-embed-text-v2:0``models.embeddings.dimensions`Default embedding dimensions`1024``models.image.default`Default image model`stability.stable-image-core-v1:1``models.audio.default`Default audio (TTS) engine`generative``models.reranking.default`Default reranking model`cohere.rerank-v3-5:0`Text Generation
---------------

[](#text-generation)

### Agent Class

[](#agent-class)

Create an agent class using the Artisan command:

```
php artisan make:agent BedrockAgent
```

```
