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
=================================

Tiny Amazon Bedrock wrapper for Laravel

0.2.12(1mo ago)03.2k↑18.8%MITPHPPHP ^8.4CI passing

Since Nov 26Pushed 2mo agoCompare

[ 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 1mo ago

READMEChangelogDependencies (16)Versions (23)Used By (0)

Tiny Amazon Bedrock wrapper for Laravel
=======================================

[](#tiny-amazon-bedrock-wrapper-for-laravel)

[![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)

Overview
--------

[](#overview)

A lightweight Laravel package to easily interact with Amazon Bedrock, specifically for generating text.

- **Features**: Text Generation only.
- **Supported Model**: Anthropic Claude Haiku/Sonnet/Opus 4 and later.(Default: Sonnet 4.6)
- **Authentication**: Bedrock API Key only.
- **Cache Control**: Always enabled ephemeral cache at system prompt.
- **Minimal Dependencies**: No extra dependencies except Laravel framework.

We created our own package because `prism-php/bedrock` often doesn't support breaking changes in `prism-php/prism`. If you need more functionality than this package, please use [Prism](https://github.com/prism-php).

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

[](#requirements)

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

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

[](#installation)

```
composer require revolution/laravel-amazon-bedrock
```

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

[](#configuration)

Publishing the config file is optional. Everything can be set in `.env`.

```
AWS_BEDROCK_API_KEY=your_api_key
AWS_BEDROCK_MODEL=global.anthropic.claude-sonnet-4-5-20250929-v1:0
AWS_DEFAULT_REGION=us-east-1
```

Bedrock API key is obtained from the AWS Management Console.

Usage
-----

[](#usage)

Usage is almost the same, making it easy to return to Prism, but it doesn't have any other features.

```
use Revolution\Amazon\Bedrock\Facades\Bedrock;

$response = Bedrock::text()
                   ->using(Bedrock::KEY, config('bedrock.model'))
                   ->withSystemPrompt('You are a helpful assistant.')
                   ->withPrompt('Tell me a joke about programming.')
                   ->asText();

echo $response->text;
```

### Conversation History

[](#conversation-history)

For multi-turn conversations, use `withMessages()` to pass previous messages.

```
use Revolution\Amazon\Bedrock\Facades\Bedrock;
use Revolution\Amazon\Bedrock\ValueObjects\Messages\UserMessage;
use Revolution\Amazon\Bedrock\ValueObjects\Messages\AssistantMessage;

$response = Bedrock::text()
                   ->withSystemPrompt('You are a helpful assistant.')
                   ->withMessages([
                       new UserMessage('What is JSON?'),
                       new AssistantMessage('JSON is a lightweight data format...'),
                   ])
                   ->withPrompt('Can you show me an example?')
                   ->asText();

echo $response->text;
```

Example with Eloquent conversation history

```
use App\Models\Message;
use Revolution\Amazon\Bedrock\Facades\Bedrock;
use Revolution\Amazon\Bedrock\ValueObjects\Messages\UserMessage;
use Revolution\Amazon\Bedrock\ValueObjects\Messages\AssistantMessage;

$messages = Message::query()
    ->where('conversation_id', $conversationId)
    ->orderBy('created_at')
    ->get()
    ->map(fn (Message $message) => match ($message->role) {
        'user' => UserMessage::make($message->content),
        'assistant' => AssistantMessage::make($message->content),
    })
    ->all();

$response = Bedrock::text()
                   ->withSystemPrompt('You are a helpful assistant.')
                   ->withMessages($messages)
                   ->withPrompt($newUserMessage)
                   ->asText();
```

### Streaming

[](#streaming)

```
use Revolution\Amazon\Bedrock\Facades\Bedrock;

$stream = Bedrock::text()
                 ->using(Bedrock::KEY, config('bedrock.model'))
                 ->withSystemPrompt('You are a helpful assistant.')
                 ->withPrompt('Tell me a joke about programming.')
                 ->asStream();

foreach ($stream as $event) {
    if (data_get($event, 'type') === 'content_block_delta') {
        echo data_get($event, 'delta.text');
    }
}
```

Testing
-------

[](#testing)

```
use Revolution\Amazon\Bedrock\Facades\Bedrock;
use Revolution\Amazon\Bedrock\ValueObjects\Usage;
use Revolution\Amazon\Bedrock\Testing\TextResponseFake;

it('can generate text', function () {
    $fakeResponse = TextResponseFake::make()
        ->withText('Hello, I am Claude!')
        ->withUsage(new Usage(10, 20));

    // Set up the fake
    $fake = Bedrock::fake([$fakeResponse]);

    // Run your code
    $response = Bedrock::text()
        ->using(Bedrock::KEY, 'global.anthropic.claude-sonnet-4-5-20250929-v1:0')
        ->withPrompt('Who are you?')
        ->asText();

    // Make assertions
    expect($response->text)->toBe('Hello, I am Claude!');
});
```

### Streaming Testing

[](#streaming-testing)

```
   Bedrock::fake(streamResponses: [
       StreamResponseFake::make('Hello!'),
   ]);
   foreach (Bedrock::text()->withPrompt('Hi')->asStream() as $event) {
       //
   }

   // multiple chunks
   StreamResponseFake::make()->withChunks(['Hello', ' World']);
```

Laravel AI SDK Integration
--------------------------

[](#laravel-ai-sdk-integration)

- Experimental implementation.
- Support only text generation. No other features are supported.

This is an opt-in feature only enabled when the Laravel AI SDK is installed.

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

Add the following configuration to `config/ai.php`.

```
// config/ai.php
    'default' => 'bedrock-anthropic',

    'providers' => [
        'bedrock-anthropic' => [
            'driver' => 'bedrock-anthropic',
            'key' => '',
        ],
    ],
```

Usage with agent helper.

```
use function Laravel\Ai\agent;

$response = agent(
    instructions: 'You are an expert at software development.',
)->prompt('Tell me about Laravel');

echo $response->text;
```

Streaming

```
use Laravel\Ai\Streaming\Events\TextDelta;

use function Laravel\Ai\agent;

$stream = agent(
    instructions: 'You are an expert at software development.',
)->stream('Tell me about Laravel');

foreach ($stream as $event) {
    if ($event instanceof TextDelta) {
        echo $event->delta;
    }
}
```

License
-------

[](#license)

MIT

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance88

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

22

Last Release

52d ago

PHP version history (2 changes)0.1.0PHP ^8.3

0.2.0PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77618633?v=4)[Revolution](/maintainers/revolution)[@Revolution](https://github.com/Revolution)

---

Top Contributors

[![kawax](https://avatars.githubusercontent.com/u/1502086?v=4)](https://github.com/kawax "kawax (66 commits)")[![puklipo](https://avatars.githubusercontent.com/u/88759954?v=4)](https://github.com/puklipo "puklipo (4 commits)")

---

Tags

laravelamazon-bedrock

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/revolution-laravel-amazon-bedrock/health.svg)

```
[![Health](https://phpackages.com/badges/revolution-laravel-amazon-bedrock/health.svg)](https://phpackages.com/packages/revolution-laravel-amazon-bedrock)
```

###  Alternatives

[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k586.2k3](/packages/andreaselia-laravel-api-to-postman)[mollie/laravel-mollie

Mollie API client wrapper for Laravel &amp; Mollie Connect provider for Laravel Socialite

3624.1M28](/packages/mollie-laravel-mollie)[api-ecosystem-for-laravel/dingo-api

A RESTful API package for the Laravel and Lumen frameworks.

3121.5M10](/packages/api-ecosystem-for-laravel-dingo-api)[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[kirschbaum-development/laravel-openapi-validator

Automatic OpenAPI validation for Laravel HTTP tests

581.1M5](/packages/kirschbaum-development-laravel-openapi-validator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
