PHPackages                             clinically/laravel-ai-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. clinically/laravel-ai-bedrock

ActiveLibrary

clinically/laravel-ai-bedrock
=============================

AWS Bedrock provider for the Laravel AI SDK

v0.1.0(1mo ago)015↑2900%MITPHPPHP ^8.4

Since Mar 24Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/clinically-au/laravel-ai-bedrock)[ Packagist](https://packagist.org/packages/clinically/laravel-ai-bedrock)[ RSS](/packages/clinically-laravel-ai-bedrock/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Laravel AI Bedrock Provider
===========================

[](#laravel-ai-bedrock-provider)

AWS Bedrock provider for the [Laravel AI SDK](https://github.com/laravel/ai).

This package adds first-class AWS Bedrock support to the Laravel AI SDK, allowing you to use Bedrock-hosted models (Claude, Titan, etc.) with Laravel's agent system, embeddings, and streaming APIs.

Why this package exists
-----------------------

[](#why-this-package-exists)

The official `laravel/ai` SDK does not include a Bedrock provider, and the upstream `prism-php/bedrock` package is missing streaming support and has unresolved bugs. This package:

1. Bridges `laravel/ai` and AWS Bedrock via `clinically/prism-bedrock`
2. Uses [`clinically/prism-bedrock`](https://github.com/clinically-au/prism-bedrock), a fork of `prism-php/bedrock` that adds:
    - **Streaming support** for both Converse and Anthropic schemas (tool calling included)
    - **ToolChoiceMap fix** for invalid payloads in both schemas

These fixes have been submitted upstream. Once merged, this package will switch back to the official `prism-php/bedrock`.

> **Note:** This package was previously published as `wojt-janowski/laravel-ai-bedrock`. If you're migrating, update your `composer.json` to use `clinically/laravel-ai-bedrock`.

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

[](#requirements)

- PHP 8.4+
- Laravel 12+
- `laravel/ai` ^0.3
- `clinically/prism-bedrock`

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

[](#installation)

```
composer require clinically/laravel-ai-bedrock
```

The service provider is auto-discovered via Laravel's package discovery.

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

[](#configuration)

### Environment Variables

[](#environment-variables)

Add these to your `.env`:

```
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
AWS_BEDROCK_REGION=us-east-1
```

Optional:

```
AWS_SESSION_TOKEN=your-session-token
AWS_BEDROCK_MAX_TOKENS=16384
AWS_BEDROCK_TEXT_MODEL=anthropic.claude-sonnet-4-5-20250929-v1:0
AWS_BEDROCK_CHEAPEST_MODEL=anthropic.claude-haiku-4-5-20251001-v1:0
AWS_BEDROCK_SMARTEST_MODEL=anthropic.claude-opus-4-6-v1:0
AWS_BEDROCK_EMBEDDINGS_MODEL=amazon.titan-embed-text-v2:0
AWS_BEDROCK_EMBEDDINGS_DIMENSIONS=1024
```

### Provider Registration

[](#provider-registration)

Add the Bedrock provider to your `config/ai.php`:

```
'providers' => [
    'bedrock' => [
        'driver' => 'bedrock',
        'access_key' => env('AWS_ACCESS_KEY_ID'),
        'secret_key' => env('AWS_SECRET_ACCESS_KEY'),
        'session_token' => env('AWS_SESSION_TOKEN'),
        'region' => env('AWS_BEDROCK_REGION', env('AWS_DEFAULT_REGION', 'us-east-1')),
        'max_tokens' => env('AWS_BEDROCK_MAX_TOKENS', 16_384),
        'models' => [
            'text' => [
                'default' => env('AWS_BEDROCK_TEXT_MODEL', 'anthropic.claude-sonnet-4-5-20250929-v1:0'),
                'cheapest' => env('AWS_BEDROCK_CHEAPEST_MODEL', 'anthropic.claude-haiku-4-5-20251001-v1:0'),
                'smartest' => env('AWS_BEDROCK_SMARTEST_MODEL', 'anthropic.claude-opus-4-6-v1:0'),
            ],
            'embeddings' => [
                'default' => env('AWS_BEDROCK_EMBEDDINGS_MODEL', 'amazon.titan-embed-text-v2:0'),
                'dimensions' => env('AWS_BEDROCK_EMBEDDINGS_DIMENSIONS', 1024),
            ],
        ],
    ],
],
```

If no provider config is defined in `config/ai.php`, the package merges sensible defaults automatically.

Usage
-----

[](#usage)

### With Agents (Attribute-based)

[](#with-agents-attribute-based)

```
use Laravel\Ai\Attributes\Agent;

#[Agent(
    model: 'anthropic.claude-sonnet-4-5-20250929-v1:0',
    provider: 'bedrock',
)]
class MyAgent extends \Laravel\Ai\Agent
{
    // ...
}
```

### With Agents (Inline)

[](#with-agents-inline)

```
use Laravel\Ai\Ai;

$provider = Ai::textProvider('bedrock');
```

### Embeddings

[](#embeddings)

```
use Laravel\Ai\Ai;

$provider = Ai::embeddingProvider('bedrock');

$response = $provider->embeddings(['Hello world']);
```

AWS Credential Provider Chain
-----------------------------

[](#aws-credential-provider-chain)

When no explicit `access_key` and `secret_key` are configured, the package automatically uses the AWS default credential provider chain. This supports:

- Environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`)
- Shared credentials file (`~/.aws/credentials`)
- IAM instance profiles (EC2)
- ECS task roles
- Web identity tokens (EKS)

This is the recommended approach for production deployments on AWS infrastructure.

How It Works
------------

[](#how-it-works)

The Laravel AI SDK's `PrismGateway` uses a hard-coded `match` statement for provider routing that doesn't include Bedrock. This package:

1. Extends `PrismGateway` with `BedrockPrismGateway` to handle the `'bedrock'` driver
2. Registers the Bedrock driver via `Ai::extend()` using this custom gateway
3. Maps AWS credentials to the format expected by `clinically/prism-bedrock`

Credits
-------

[](#credits)

This package was inspired by [PR #134](https://github.com/laravel/ai/pull/134) on `laravel/ai` by **Mohit Kumar** ([@mohitky2018](https://github.com/mohitky2018)), which implemented Bedrock support directly in the SDK. This package extracts that concept into a standalone Composer package.

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance90

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

49d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f2ea2e401c2f1f18cafc42d8fb98305ae3575db1fb25455af1c3156d0e79f90e?d=identicon)[wojt-janowski](/maintainers/wojt-janowski)

---

Top Contributors

[![wojt-janowski](https://avatars.githubusercontent.com/u/209190810?v=4)](https://github.com/wojt-janowski "wojt-janowski (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/clinically-laravel-ai-bedrock/health.svg)

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

###  Alternatives

[bagisto/bagisto

Bagisto Laravel E-Commerce

26.2k161.6k7](/packages/bagisto-bagisto)[unopim/unopim

UnoPim Laravel PIM

9.4k1.8k](/packages/unopim-unopim)[openclassify/openclassify

The skeleton application for the Laravel framework.

2992.5k](/packages/openclassify-openclassify)

PHPackages © 2026

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