https://github.com/aysnc-labs/wordpress-php-ai-client-bedrock
AWS Bedrock provider for the WordPress PHP AI Client SDK.
https://github.com/aysnc-labs/wordpress-php-ai-client-bedrock
ai aws-bedrock php wordpress
Last synced: 2 months ago
JSON representation
AWS Bedrock provider for the WordPress PHP AI Client SDK.
- Host: GitHub
- URL: https://github.com/aysnc-labs/wordpress-php-ai-client-bedrock
- Owner: Aysnc-Labs
- License: mit
- Created: 2026-01-31T06:39:26.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-01-31T08:20:55.000Z (5 months ago)
- Last Synced: 2026-04-10T22:15:50.548Z (3 months ago)
- Topics: ai, aws-bedrock, php, wordpress
- Language: PHP
- Homepage: https://packagist.org/packages/aysnc/wordpress-php-ai-client-bedrock
- Size: 51.8 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP AI Client AWS Bedrock Provider


AWS Bedrock provider for the [WordPress PHP AI Client](https://github.com/WordPress/php-ai-client) SDK.
This package was [originally contributed](https://github.com/WordPress/php-ai-client/pull/181) to the core PHP AI Client repository. The WordPress team is [decoupling all providers](https://github.com/WordPress/php-ai-client/pull/181#issuecomment-2915891498) into standalone packages ahead of WordPress 7.0 core integration, so this provider is maintained here as an independent Composer library.
## Requirements
- PHP 8.3+
- [wordpress/php-ai-client](https://github.com/WordPress/php-ai-client) ^0.4
## Installation
```bash
composer require aysnc/wordpress-php-ai-client-bedrock
```
## Configuration
Set the following environment variables:
| Variable | Required | Description |
|----------|----------|-------------|
| `AWS_BEDROCK_API_KEY` | Yes | Bearer token for Bedrock API authentication |
| `AWS_BEDROCK_REGION` | No | AWS region (defaults to `AWS_DEFAULT_REGION`, then `us-east-1`) |
| `AWS_DEFAULT_REGION` | No | Fallback AWS region |
## Usage
### Register the Provider
```php
use WordPress\AiClient\AiClient;
use Aysnc\WordPress\PhpAiClientBedrock\AwsBedrockProvider;
AiClient::defaultRegistry()->registerProvider( AwsBedrockProvider::class );
```
### Generate Text
```php
$text = AiClient::prompt( 'Explain quantum computing in simple terms.' )
->usingModel( AwsBedrockProvider::model( 'anthropic.claude-3-5-sonnet-20241022-v2:0' ) )
->usingMaxTokens( 1000 )
->generateText();
echo $text;
```
### Full Result with Metadata
```php
$result = AiClient::prompt( 'Explain quantum computing in simple terms.' )
->usingModel( AwsBedrockProvider::model( 'anthropic.claude-3-5-sonnet-20241022-v2:0' ) )
->usingMaxTokens( 1000 )
->generateTextResult();
echo $result->toText();
echo $result->getTokenUsage()->getTotalTokens();
```
### With Configuration
```php
$result = AiClient::prompt( 'Hello' )
->usingModel( AwsBedrockProvider::model( 'anthropic.claude-3-5-sonnet-20241022-v2:0' ) )
->usingSystemInstruction( 'You are a helpful assistant.' )
->usingMaxTokens( 1000 )
->usingTemperature( 0.7 )
->generateTextResult();
```
### Custom Region
Set the `AWS_BEDROCK_REGION` environment variable, or fall back to `AWS_DEFAULT_REGION`:
```bash
export AWS_BEDROCK_REGION="eu-west-1"
```