PHPackages                             agave-api/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. [API Development](/categories/api)
4. /
5. agave-api/laravel-ai-bedrock

AbandonedArchivedLibrary[API Development](/categories/api)

agave-api/laravel-ai-bedrock
============================

AWS Bedrock provider for the Laravel AI SDK

19↓90%PHPCI failing

Since Apr 4Pushed 2mo agoCompare

[ Source](https://github.com/agave-api/laravel-ai-bedrock)[ Packagist](https://packagist.org/packages/agave-api/laravel-ai-bedrock)[ RSS](/packages/agave-api-laravel-ai-bedrock/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependenciesVersions (6)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 `agave-api/laravel-ai-bedrock`.

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

[](#requirements)

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

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

[](#installation)

```
composer require agave-api/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

23

—

LowBetter than 26% of packages

Maintenance57

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/027e98f2390b696a46a7605334b3082a895e444d88956cea04f4d162c6cee4a5?d=identicon)[TanAidan](/maintainers/TanAidan)

---

Top Contributors

[![wojt-janowski](https://avatars.githubusercontent.com/u/209190810?v=4)](https://github.com/wojt-janowski "wojt-janowski (6 commits)")[![liambenson](https://avatars.githubusercontent.com/u/42977911?v=4)](https://github.com/liambenson "liambenson (3 commits)")[![pooriaazimi](https://avatars.githubusercontent.com/u/814637?v=4)](https://github.com/pooriaazimi "pooriaazimi (1 commits)")[![TanAidan](https://avatars.githubusercontent.com/u/12576216?v=4)](https://github.com/TanAidan "TanAidan (1 commits)")

### Embed Badge

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

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

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93452.6k6](/packages/botman-driver-telegram)[pixelant/pxa-social-feed

Add Facebook, Instagram, and Twitter feeds to your site.

2349.3k](/packages/pixelant-pxa-social-feed)

PHPackages © 2026

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