Overview
revolution/laravel-amazon-bedrock is a driver that lets you use Amazon Bedrock through the Laravel AI SDK. You can access multiple Bedrock models through one Laravel AI SDK interface.⚠️ in this table means the feature is not available with only a Bedrock API key. It does not mean the feature itself is unsupported.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 is always enabled on system prompts via the Bedrock Converse API.
- 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
- PHP >= 8.3
- Laravel >= 12.x
Installation
1
Install the package
2
Publish AI SDK configuration
Configuration
Add theamazon-bedrock provider to config/ai.php. Switch your default providers to Bedrock if needed.
Option 1: Bedrock API key
Option 2: AWS IAM credentials (SigV4)
Use an AWS access key and secret key signed with Signature Version 4.Set
AWS_SESSION_TOKEN only when you use temporary credentials (STS).Option 3: Default AWS credential chain (IAM roles)
For EC2 instances, ECS tasks, Lambda functions, or any environment with IAM roles — omitkey and secret to use the default AWS credential provider chain.
~/.aws/credentials), ECS task roles, EC2 instance profiles, and more.
Optional config keys
Text generation
Agent class
Create an agent class using the Artisan command.Anonymous Agent
For quick interactions without a dedicated class, use theagent() helper.
Streaming
Tool use (Function Calling)
Define tools the model can invoke during generation.File attachments
Attach images, documents, audio, and video files to your prompts using theattachments parameter. The Bedrock Converse API handles the attachment blocks — actual format support varies by model (e.g., Anthropic Claude supports images and documents only).
Image, Document, and Audio (via Laravel\Ai\Files\*). Video attachments are supported through Illuminate\Http\UploadedFile.
Server-side file upload (
Document::fromPath()->put()) and reuse by ID (Document::fromId()) are not supported on Bedrock.Conversation history
Maintain multi-turn conversations by implementing theConversational interface in your agent class. The messages() method returns the previous conversation messages, which are automatically included in each prompt.
Automatic conversation storage with RemembersConversations
For fully automatic conversation persistence (no manual messages() implementation needed), use the RemembersConversations trait. This requires the AI SDK database tables — run php artisan vendor:publish --provider="Laravel\Ai\AiServiceProvider" && php artisan migrate first.
Structured output
Get structured (typed) responses from the model using theHasStructuredOutput interface.
output_structured_data) that forces the model to return data matching your schema. This approach is compatible with all models on Bedrock via the Converse API.
Converse API (all models)
All text generation and streaming is routed through the Bedrock Converse API, including Anthropic Claude models. This gives a unified interface to Anthropic Claude, Amazon Nova, Meta Llama, Mistral, Cohere, DeepSeek, and other models available on Bedrock.Provider options
To pass Bedrock-specific options such asanthropic_version, implement HasProviderOptions.
Agent configuration attributes
Configure text generation options using PHP attributes.Image generation
Generate images using Stability AI models (default) or Amazon Nova Canvas.us-west-2 region):
All Stability AI image models are available in
us-west-2 only. Configure AWS_DEFAULT_REGION=us-west-2 when using these models.Image editing with Stability AI
Stability AI Image Services editing models are also supported via theattachments() method. Pass an input image and use an editing model to transform it.
us-east-1, us-east-2, us-west-2):
Amazon Nova Canvas is also supported but is being deprecated by AWS.
Audio (TTS)
Generate speech audio from text using Amazon Polly.default-female → Ruth, default-male → Matthew (both support the generative engine).
Embeddings
Generate vector embeddings using Amazon Titan Embeddings V2.Cohere Embed models
Cohere Embed models are automatically detected and use a batch API — all inputs are sent in a single request instead of one request per input, making them more efficient for multiple texts.Cohere Embed models do not return token counts —
$response->tokens will always be 0.Reranking
Rerank documents by relevance to a query using Cohere Rerank 3.5 or Amazon Rerank 1.0.The reranking API uses the
bedrock-agent-runtime endpoint (not bedrock-runtime). Amazon Rerank 1.0 is not available in us-east-1 — use Cohere Rerank 3.5 in that region.Testing
The package supports the standard testing features of the AI SDK. Although not mentioned in the official documentation, when you use theagent() helper you can mock it with AnonymousAgent::fake() (or StructuredAnonymousAgent::fake() for structured output).
For the latest updates, see the GitHub repository.