1. Go to this page and download the library: Download aisdk/bedrock library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aisdk / bedrock example snippets
use AiSdk\Bedrock;
use AiSdk\Generate;
$result = Generate::text()
->model(Bedrock::model('anthropic.claude-3-5-sonnet-20240620-v1:0'))
->prompt('Explain closures in PHP.')
->run();
echo $result->text;
foreach (Generate::text('Tell me a story.')->model(Bedrock::model('anthropic.claude-3-haiku-20240307-v1:0'))->stream()->chunks() as $chunk) {
echo $chunk;
}
$image = Generate::image('A studio product photograph')
->model(Bedrock::model('amazon.nova-canvas-v1:0'))
->aspectRatio('16:9')
->run();
use AiSdk\Reasoning;
$result = Generate::text('Explain the tradeoff.')
->model(Bedrock::model('anthropic.claude-3-7-sonnet-20250219-v1:0'))
->reasoning(Reasoning::budget(2048))
->run();
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.