PHPackages                             prism-php/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. prism-php/bedrock

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

prism-php/bedrock
=================

A provider for Prism adding support for AWS Bedrock.

v1.8.0(4mo ago)35116.8k—5.5%17[2 issues](https://github.com/prism-php/bedrock/issues)[5 PRs](https://github.com/prism-php/bedrock/pulls)1MITPHPPHP ^8.2

Since Apr 20Pushed 4mo ago5 watchersCompare

[ Source](https://github.com/prism-php/bedrock)[ Packagist](https://packagist.org/packages/prism-php/bedrock)[ GitHub Sponsors](https://github.com/sixlive)[ RSS](/packages/prism-php-bedrock/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (17)Versions (11)Used By (1)

[![](assets/bedrock-banner.webp)](assets/bedrock-banner.webp)

 [ ![Total Downloads](https://camo.githubusercontent.com/9b097b8ae34a339118f030a2cd413310798502bf2a2e25cb1c51703fbd4b261d/68747470733a2f2f706f7365722e707567782e6f72672f707269736d2d7068702f626564726f636b2f642f746f74616c2e737667) ](https://packagist.org/packages/prism-php/bedrock) [ ![Latest Stable Version](https://camo.githubusercontent.com/c32fab12bc98fda0fc852937203028db50da817ad7cb0a4598b2658fb894a869/68747470733a2f2f706f7365722e707567782e6f72672f707269736d2d7068702f626564726f636b2f762f737461626c652e737667) ](https://packagist.org/packages/prism-php/bedrock) [ ![License](https://camo.githubusercontent.com/1457f496ef3e9098ca07ee6efadbb4cb354a21e6902b2cb160e21f1206ac17bd/68747470733a2f2f706f7365722e707567782e6f72672f707269736d2d7068702f626564726f636b2f6c6963656e73652e737667) ](https://packagist.org/packages/prism-php/bedrock)

Prism Bedrock
=============

[](#prism-bedrock)

Unlock the power of AWS Bedrock services in your Laravel applications with Prism Bedrock. This package provides a standalone Bedrock provider for the Prism PHP framework.

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

[](#installation)

```
composer require prism-php/bedrock
```

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

[](#configuration)

Add the following to your Prism configuration (`config/prism.php`):

```
'bedrock' => [ // Key should match Bedrock::KEY
    'region' => env('AWS_REGION', 'us-east-1'),

    // Set to true to ignore other auth configuration and use the AWS SDK default credential chain
    // read more at https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials_default_chain.html
    'use_default_credential_provider' => env('AWS_USE_DEFAULT_CREDENTIAL_PROVIDER', false),

    'api_key' => env('AWS_ACCESS_KEY_ID'), //  Ignored with `use_default_credential_provider` === true
    'api_secret' => env('AWS_SECRET_ACCESS_KEY'), //  Ignored with `use_default_credential_provider` === true
    'session_token' => env('AWS_SESSION_TOKEN'), // Only required for temporary credentials. Ignored with `use_default_credential_provider` === true
],
```

Usage
-----

[](#usage)

### Text Generation

[](#text-generation)

```
use Prism\Prism\Prism;
use Prism\Bedrock\Bedrock;

$response = Prism::text()
    ->using(Bedrock::KEY, 'anthropic.claude-3-sonnet-20240229-v1:0')
    ->withPrompt('Explain quantum computing in simple terms')
    ->asText();

echo $response->text;
```

### Structured Output (JSON)

[](#structured-output-json)

```
use Prism\Prism\Prism;
use Prism\Bedrock\Bedrock;
use Prism\Prism\Schema\ObjectSchema;
use Prism\Prism\Schema\StringSchema;
use Prism\Prism\Schema\ArraySchema;

$schema = new ObjectSchema(
    name: 'languages',
    description: 'Top programming languages',
    properties: [
        new ArraySchema(
            'languages',
            'List of programming languages',
            items: new ObjectSchema(
                name: 'language',
                description: 'Programming language details',
                properties: [
                    new StringSchema('name', 'The language name'),
                    new StringSchema('popularity', 'Popularity description'),
                ]
            )
        )
    ]
);

$response = Prism::structured()
    ->using(Bedrock::KEY, 'anthropic.claude-3-sonnet-20240229-v1:0')
    ->withSchema($schema)
    ->withPrompt('List the top 3 programming languages')
    ->asStructured();

// Access your structured data
$data = $response->structured;
```

### Embeddings (with Cohere models)

[](#embeddings-with-cohere-models)

```
use Prism\Prism\Prism;
use Prism\Bedrock\Bedrock;

$response = Prism::embeddings()
    ->using(Bedrock::KEY, 'cohere.embed-english-v3')
    ->fromArray(['The sky is blue', 'Water is wet'])
    ->asEmbeddings();

// Access the embeddings
$embeddings = $response->embeddings;
```

### Model names

[](#model-names)

Important

When using inference profiles via an ARN, you should urlencode the model name.

```
use Prism\Prism\Prism;
use Prism\Bedrock\Bedrock;

$response = Prism::text()
    ->using(Bedrock::KEY, urlencode('arn:aws:bedrock:us-east-1:999999999999:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0'))
    ->withPrompt('Explain quantum computing in simple terms')
    ->asText();
```

Supported API Schemas
---------------------

[](#supported-api-schemas)

AWS Bedrock supports several API schemas - some LLM vendor specific, some generic.

Prism Bedrock supports three of those API schemas:

- **Converse**: AWS's native interface for chat (default)\*
- **Anthropic**: For Claude models\*\*
- **Cohere**: For Cohere embeddings models

Each schema supports different capabilities:

SchemaTextStructuredEmbeddingsConverse✅✅❌Anthropic✅✅❌Cohere❌❌✅\* A unified interface for multiple providers. See [AWS documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-supported-models-features.html) for a list of supported models.

\*\* The Converse schema does not support Anthropic's native features (e.g. PDF vision analysis). This schema uses Anthropic's native schema and therefore allows use of Anthropic native features. Please note however that Bedrock's Anthropic schema does not yet have feature parity with Anthropic. Notably it does not support documents or citations, and only supports prompt caching for Claude Sonnet 3.7 and Claude Haiku 3.5. To use documents with Anthropic's models, use them via the Converse schema (though note that this not the same as using Anthropic's PDF vision directly).

Auto-resolution of API schemas
------------------------------

[](#auto-resolution-of-api-schemas)

Prism Bedrock resolves the most appropriate API schema from the model string. If it is unable to resolve a specific schema (e.g. anthropic for Anthropic), it will default to Converse.

Therefore if you use a model that is not supported by AWS Bedrock Converse, and does not have a specific Prism Bedrock implementation, your request will fail.

If you wish to force Prism Bedrock to use Converse instead of a vendor specific interface, you can do so with `withProviderOptions()`:

```
use Prism\Prism\Prism;
use Prism\Bedrock\Bedrock;
use Prism\Bedrock\Enums\BedrockSchema;

$response = Prism::text()
    ->using(Bedrock::KEY, 'anthropic.claude-3-sonnet-20240229-v1:0')
    ->withProviderOptions(['apiSchema' => BedrockSchema::Converse])
    ->withPrompt('Explain quantum computing in simple terms')
    ->asText();
```

Cache-Optimized Prompts
-----------------------

[](#cache-optimized-prompts)

For [supported models](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html), you can enable prompt caching to reduce latency and costs:

```
use Prism\Prism\Prism;
use Prism\Bedrock\Bedrock;
use Prism\Prism\ValueObjects\Messages\UserMessage;

$response = Prism::text()
    ->using(Bedrock::KEY, 'anthropic.claude-3-sonnet-20240229-v1:0')
    ->withMessages([
        (new UserMessage('Message with cache breakpoint'))->withProviderOptions(['cacheType' => 'ephemeral']),
        (new UserMessage('Message with another cache breakpoint'))->withProviderOptions(['cacheType' => 'ephemeral']),
        new UserMessage('Compare the last two messages.')
    ])
    ->asText();
```

Tip

Anthropic currently supports a cacheType of "ephemeral". Converse currently supports a cacheType of "default". It is possible that Anthropic and/or AWS may add additional types in the future.

Structured Adapted Support
--------------------------

[](#structured-adapted-support)

Both Anthropic and Converse Schemas do not support a native structured format.

Prism Bedrock has adapted support by appending a prompt asking the model to a response conforming to the schema you provide.

The performance of that prompt may vary by model. You can override it using `withProviderOptions()`:

```
use Prism\Prism\Prism;
use Prism\Bedrock\Bedrock;
use Prism\Prism\ValueObjects\Messages\UserMessage;

Prism::structured()
    ->withSchema($schema)
    ->using('bedrock', 'anthropic.claude-3-5-haiku-20241022-v1:0')
    ->withProviderOptions([
        // Override the default message of "Respond with ONLY JSON (i.e. not in backticks or a code block, with NO CONTENT outside the JSON) that matches the following schema:"
        'jsonModeMessage' => 'My custom message',
    ])
    ->withPrompt('My prompt')
    ->asStructured();
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

Authors
-------

[](#authors)

This library is created by [TJ Miller](https://tjmiller.me) with contributions from the [Open Source Community](https://github.com/echolabsdev/prism-bedrock/graphs/contributors).

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance73

Regular maintenance activity

Popularity47

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~28 days

Recently: every ~47 days

Total

10

Last Release

139d ago

PHP version history (2 changes)1.0.0PHP ^8.3

v1.3.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5108034?v=4)[TJ Miller](/maintainers/sixlive)[@sixlive](https://github.com/sixlive)

---

Top Contributors

[![ChrisB-TL](https://avatars.githubusercontent.com/u/101201552?v=4)](https://github.com/ChrisB-TL "ChrisB-TL (11 commits)")[![ejunker](https://avatars.githubusercontent.com/u/4758?v=4)](https://github.com/ejunker "ejunker (3 commits)")[![sixlive](https://avatars.githubusercontent.com/u/5108034?v=4)](https://github.com/sixlive "sixlive (3 commits)")[![james-astalty](https://avatars.githubusercontent.com/u/134993638?v=4)](https://github.com/james-astalty "james-astalty (1 commits)")[![mortenhauberg](https://avatars.githubusercontent.com/u/3660049?v=4)](https://github.com/mortenhauberg "mortenhauberg (1 commits)")[![pktharindu](https://avatars.githubusercontent.com/u/23132672?v=4)](https://github.com/pktharindu "pktharindu (1 commits)")[![rhysemmerson](https://avatars.githubusercontent.com/u/2549415?v=4)](https://github.com/rhysemmerson "rhysemmerson (1 commits)")[![FredrikPAC](https://avatars.githubusercontent.com/u/98091128?v=4)](https://github.com/FredrikPAC "FredrikPAC (1 commits)")

---

Tags

awsaws-bedrockprismphp

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/prism-php-bedrock/health.svg)

```
[![Health](https://phpackages.com/badges/prism-php-bedrock/health.svg)](https://phpackages.com/packages/prism-php-bedrock)
```

###  Alternatives

[wireui/wireui

TallStack components

1.8k1.3M16](/packages/wireui-wireui)[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4205.3M84](/packages/livewire-volt)[prism-php/relay

A Prism tool for interacting with MCP servers

15236.1k3](/packages/prism-php-relay)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)

PHPackages © 2026

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