Download the PHP package revolution/laravel-amazon-bedrock without Composer

On this page you can find all versions of the php package revolution/laravel-amazon-bedrock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-amazon-bedrock

Amazon Bedrock driver for Laravel AI SDK

Maintainability Code Coverage Ask DeepWiki

Docs: English Japanese

[!CAUTION] With the release of the Laravel AI SDK v1.0, the official SDK is now sufficient for Bedrock, so this package is being discontinued.

Overview

An Amazon Bedrock driver for the Laravel AI SDK, enabling text generation, streaming, tool use (function calling), structured output, file attachments, embeddings, image generation, audio (TTS), and reranking via models on AWS Bedrock.

Feature API key Supported Models
Text, Streaming ✅ Anthropic Claude, Amazon Nova, and most Bedrock models (all via Converse API)
Tool Use ✅
Structured Output ✅
File Attachments ✅ Image, document, audio, and video attachments via Converse API (model support varies)
Images ✅ Stability AI models (default), Amazon Nova Canvas (deprecated).
Audio(TTS) ⚠️ Amazon Polly (generative, neural, long-form, standard engines)
Transcription(STT) ❌ Not supported
Embeddings ✅ Amazon Titan Embeddings V2 (default), Cohere Embed English/Multilingual V3, Cohere Embed V4 (batch support).
Reranking ⚠️ Cohere Rerank 3.5, Amazon Rerank 1.0
Files ✅️ Local file attachments supported via text generation; server-side upload and fromId() not supported

[!NOTE] ⚠️ in this table means the feature is not available with only a Bedrock API key. It does not mean the feature itself is unsupported.

[!NOTE] 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.

Requirements

Installation

Configuration

Add the amazon-bedrock driver to config/ai.php:

Option 1: Bedrock API Key

The Bedrock API key is obtained from the AWS Management Console.

[!WARNING] The Bedrock API key can only be used with the Bedrock Runtime API. It cannot be used with bedrock-agent-runtime (reranking) or Amazon Polly (audio/TTS). Use SigV4 or the default AWS credential chain for these features.

Option 2: AWS IAM Credentials (SigV4)

Use AWS access key and secret key with Signature Version 4 signing:

Option 3: Default AWS Credential Chain (IAM Roles)

For EC2 instances, ECS tasks, Lambda functions, or any environment with IAM roles — omit key and secret to use the default AWS credential provider chain:

The default credential chain automatically resolves credentials from environment variables, shared credentials files (~/.aws/credentials), ECS task roles, EC2 instance profiles, and more.

Optional config keys

Key Description Default
secret AWS secret access key (SigV4) —
token AWS session token (SigV4) —
timeout HTTP request timeout in seconds 30
max_tokens Default max tokens per request 8096
models.text.default Default text model global.anthropic.claude-sonnet-5
models.text.cheapest Cheapest text model global.anthropic.claude-haiku-4-5-20251001-v1:0
models.text.smartest Smartest text model global.anthropic.claude-opus-5
models.embeddings.default Default embeddings model amazon.titan-embed-text-v2:0
models.embeddings.dimensions Default embedding dimensions 1024
models.image.default Default image model stability.stable-image-core-v1:1
models.audio.default Default audio (TTS) engine generative
models.reranking.default Default reranking model cohere.rerank-v3-5:0

Text Generation

Agent Class

Create an agent class using the Artisan command:

Anonymous Agent

For quick interactions without a dedicated class:

Streaming

Or iterate through the events manually:

Tool Use (Function Calling)

Define tools that Claude can invoke during generation:

Use the tool with an agent:

Or with an anonymous agent:

Tool calls also work with streaming — the SDK automatically executes tool calls and continues the conversation until the model produces a final text response.

File Attachments

Attach images, documents, audio, and video files to your prompts using the attachments parameter. The Bedrock Converse API handles the attachment blocks — actual format support varies by model (e.g., Anthropic Claude supports images and documents only).

Supported attachment types: Image, Document, Audio (via Laravel\Ai\Files\*). Video attachments are supported through Illuminate\Http\UploadedFile.

[!NOTE] 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 the Conversational interface in your agent class. The messages() method should return the previous conversation messages, which will be 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.

Start a new conversation for a user:

Continue an existing conversation:

The Bedrock driver automatically includes conversation history in Bedrock Converse API requests, so all supported models benefit from multi-turn conversation context.

Structured Output

Get structured (typed) responses from Claude using the HasStructuredOutput interface:

Or with an anonymous structured agent:

Under the hood, the driver creates a synthetic tool (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.

Streaming, tool use, structured output, and file attachments work with models that support those features. See the Bedrock supported models table for feature availability per model.

Provider Options

To pass Bedrock-specific options such as anthropic_version, implement HasProviderOptions:

Supported provider options:

Option Description Default
top_k Top-K sampling parameter —
top_p Top-P (nucleus) sampling parameter —
additionalModelRequestFields Converse API additional model parameters —

Agent Configuration

Configure text generation options using PHP attributes:

Image Generation

Generate images using Stability AI models (default) or Amazon Nova Canvas:

Available Stability AI models (all require us-west-2 region):

[!NOTE] 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 the attachments() method. Pass an input image and use an editing model to transform it:

Available Stability AI editing models (all available in us-east-1, us-east-2, us-west-2):

Model ID Description
stability.stable-image-inpaint-v1:0 Inpaint — fill/replace selected areas
stability.stable-outpaint-v1:0 Outpaint — expand the image beyond its borders
stability.stable-image-erase-object-v1:0 Erase — remove objects from an image
stability.stable-image-remove-background-v1:0 Remove background
stability.stable-image-search-replace-v1:0 Search and Replace — replace a described object
stability.stable-image-search-recolor-v1:0 Search and Recolor — change an object's color
stability.stable-image-style-guide-v1:0 Style Guide — apply a style reference image
stability.stable-style-transfer-v1:0 Style Transfer — transfer an art style
stability.stable-image-control-sketch-v1:0 Control Sketch — generate from a sketch
stability.stable-image-control-structure-v1:0 Control Structure — follow a structural guide
stability.stable-creative-upscale-v1:0 Creative Upscale — upscale with reimagining
stability.stable-conservative-upscale-v1:0 Conservative Upscale — upscale preserving detail
stability.stable-fast-upscale-v1:0 Fast Upscale — lightweight 4× upscaling

Amazon Nova Canvas is also supported but is being deprecated by AWS:

Audio (TTS)

Generate speech audio from text using Amazon Polly:

Use male or female voice:

Use a specific Polly voice:

Store the generated audio:

Specify a different engine (model):

Default voices: default-female → Ruth, default-male → Matthew (both support the generative engine).

[!WARNING] Amazon Polly is a separate AWS service from Bedrock. The Bedrock API key (bearer token) cannot be used with Polly. Use AWS IAM credentials (SigV4) or the default AWS credential chain instead.

Embeddings

Generate vector embeddings using Amazon Titan Embeddings V2:

Specify custom dimensions (256, 512, or 1024 for Titan Embeddings V2):

Use a custom model:

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.

Note: Cohere Embed models do not return token counts — $response->tokens will always be 0. Titan Embeddings uses one HTTP request per input, while Cohere models batch all inputs into a single request.

Reranking

Rerank documents by relevance to a query using Cohere Rerank 3.5 or Amazon Rerank 1.0:

Use a custom model:

Note: 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

Supports the standard testing features of the AI SDK.

Although not mentioned in the official documentation, when using the agent() helper, you can mock it with AnonymousAgent::fake() or StructuredAnonymousAgent::fake().

License

MIT


All versions of laravel-amazon-bedrock with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/support Version ^12.0||^13.0
laravel/ai Version ^0.11
aws/aws-sdk-php Version ^3.369
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package revolution/laravel-amazon-bedrock contains the following files

Loading the files please wait ...