Skip to content

Bedrock ​

AWS Bedrock access to hosted models (including Anthropic Claude and Amazon Titan/Nova families) through the AWS SDK instead of plain HTTPS calls. Use it when workloads must run inside AWS with IAM-based auth and AWS logging. There is no API key in this config: credentials come from the SDK's default chain (environment variables, shared config file, or instance role).

Capabilities ​

Text with streaming, image generation, embeddings, and reranking.

Configuration ​

Configure via environment variables. config/ai.php only forwards them with env() — set the values in .env or the host environment. Requires the suggested aws/aws-sdk-php dependency.

php
// In config/ai.php
return [
    'Ai' => [
        'providers' => [
            'bedrock' => [
                'className' => 'Crustum\Ai\Providers\BedrockProvider',
                'access_key_id' => env('AWS_ACCESS_KEY_ID'),
                'secret_access_key' => env('AWS_SECRET_ACCESS_KEY'),
                'region' => env('AWS_REGION', 'us-east-1'),
                'use_default_credential_provider' => true,
                'models' => [
                    'text' => [
                        'default' => env('BEDROCK_TEXT_MODEL', 'global.anthropic.claude-sonnet-5-5'),
                        'cheapest' => env('BEDROCK_TEXT_MODEL_CHEAPEST', 'global.anthropic.claude-haiku-4-5-20251001-v1:0'),
                        'smartest' => env('BEDROCK_TEXT_MODEL_SMARTEST', 'global.anthropic.claude-opus-5-5'),
                    ],
                    'embeddings' => [
                        'default' => env('BEDROCK_EMBEDDINGS_MODEL', 'amazon.titan-embed-text-v2:0'),
                        'dimensions' => (int)env('BEDROCK_EMBEDDINGS_DIMENSIONS', 1024),
                    ],
                    'image' => [
                        'default' => env('BEDROCK_IMAGE_MODEL', 'amazon.nova-canvas-v1:0'),
                    ],
                ],
            ],
        ],
    ],
];
Config keyEnv varPurpose
className—Provider class. Keep the default unless subclassing.
access_key_idAWS_ACCESS_KEY_IDStatic AWS key. Omit to use the SDK default chain (shared config, instance role).
secret_access_keyAWS_SECRET_ACCESS_KEYStatic AWS secret. Omit together with the key id when using IAM roles.
regionAWS_REGIONAWS region hosting the Bedrock models. Model availability is region-scoped.
use_default_credential_provider— (config only)true lets the SDK fall back to its default chain when no static keys are set. Set false to force static credentials.
assume_role.arn et al.— (config only)Optional STS assume-role block (arn, session_name, duration_seconds, external_id). Not in the default file; add when cross-account access is needed.
models.text.defaultBEDROCK_TEXT_MODELBedrock model id for normal text calls.
models.text.cheapestBEDROCK_TEXT_MODEL_CHEAPESTBudget model id.
models.text.smartestBEDROCK_TEXT_MODEL_SMARTESTFlagship model id.
models.embeddings.defaultBEDROCK_EMBEDDINGS_MODELEmbeddings model id.
models.embeddings.dimensionsBEDROCK_EMBEDDINGS_DIMENSIONSVector width of the embeddings model.
models.image.defaultBEDROCK_IMAGE_MODELImage model id.
models.reranking.defaultBEDROCK_RERANKING_MODELReranking model id (no env mapping in the default file; add one if you use rerank).
headers— (config only)Extra headers merged into SDK calls. Add as a plain array if needed.

Model selection priority per call: explicit model: argument wins, then the matching models.* value above, then the provider's built-in fallback.

Notes ​

Credentials come from the SDK's default chain (environment, shared config, or instance role). Calls go through the AWS SDK instead of plain HTTP, so raw HTTP replies are unavailable on responses.

See also ​

Released under the MIT License.