{"id":28443746,"url":"https://github.com/prism-php/bedrock","last_synced_at":"2025-06-29T14:31:45.014Z","repository":{"id":288939944,"uuid":"926721714","full_name":"prism-php/bedrock","owner":"prism-php","description":"AWS Bedrock provider for Prism","archived":false,"fork":false,"pushed_at":"2025-06-24T18:57:09.000Z","size":220,"stargazers_count":17,"open_issues_count":5,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-24T19:58:07.673Z","etag":null,"topics":["aws","aws-bedrock","prismphp"],"latest_commit_sha":null,"homepage":"https://prismphp.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prism-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"sixlive"}},"created_at":"2025-02-03T18:44:34.000Z","updated_at":"2025-06-24T18:56:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"4cc242ae-a612-4f57-9dbc-fd1bb9106635","html_url":"https://github.com/prism-php/bedrock","commit_stats":null,"previous_names":["prism-php/bedrock"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/prism-php/bedrock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prism-php%2Fbedrock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prism-php%2Fbedrock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prism-php%2Fbedrock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prism-php%2Fbedrock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prism-php","download_url":"https://codeload.github.com/prism-php/bedrock/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prism-php%2Fbedrock/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262608793,"owners_count":23336566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-bedrock","prismphp"],"created_at":"2025-06-06T08:08:35.221Z","updated_at":"2025-06-29T14:31:44.998Z","avatar_url":"https://github.com/prism-php.png","language":"PHP","funding_links":["https://github.com/sponsors/sixlive"],"categories":[],"sub_categories":[],"readme":"![](assets/bedrock-banner.webp)\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/prism-php/bedrock\"\u003e\n        \u003cimg src=\"https://poser.pugx.org/prism-php/bedrock/d/total.svg\" alt=\"Total Downloads\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/prism-php/bedrock\"\u003e\n        \u003cimg src=\"https://poser.pugx.org/prism-php/bedrock/v/stable.svg\" alt=\"Latest Stable Version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/prism-php/bedrock\"\u003e\n        \u003cimg src=\"https://poser.pugx.org/prism-php/bedrock/license.svg\" alt=\"License\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n# Prism Bedrock\n\nUnlock the power of AWS Bedrock services in your Laravel applications with Prism Bedrock. This package provides a standalone Bedrock provider for the Prism PHP framework.\n\n## Installation\n\n```bash\ncomposer require prism-php/bedrock\n```\n\n## Configuration\n\nAdd the following to your Prism configuration (`config/prism.php`):\n\n```php\n'bedrock' =\u003e [ // Key should match Bedrock::KEY\n    'region' =\u003e env('AWS_REGION', 'us-east-1'),\n\n    // Set to true to ignore other auth configuration and use the AWS SDK default credential chain\n    // read more at https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials_default_chain.html\n    'use_default_credential_provider' =\u003e env('AWS_USE_DEFAULT_CREDENTIAL_PROVIDER', false), \n\n    'api_key' =\u003e env('AWS_ACCESS_KEY_ID'), //  Ignored with `use_default_credential_provider` === true\n    'api_secret' =\u003e env('AWS_SECRET_ACCESS_KEY'), //  Ignored with `use_default_credential_provider` === true\n    'session_token' =\u003e env('AWS_SESSION_TOKEN'), // Only required for temporary credentials. Ignored with `use_default_credential_provider` === true\n],\n```\n\n## Usage\n\n### Text Generation\n\n```php\nuse Prism\\Prism\\Prism;\nuse Prism\\Bedrock\\Bedrock;\n\n$response = Prism::text()\n    -\u003eusing(Bedrock::KEY, 'anthropic.claude-3-sonnet-20240229-v1:0')\n    -\u003ewithPrompt('Explain quantum computing in simple terms')\n    -\u003easText();\n\necho $response-\u003etext;\n```\n\n### Structured Output (JSON)\n\n```php\nuse Prism\\Prism\\Prism;\nuse Prism\\Bedrock\\Bedrock;\nuse Prism\\Prism\\Schema\\ObjectSchema;\nuse Prism\\Prism\\Schema\\StringSchema;\nuse Prism\\Prism\\Schema\\ArraySchema;\n\n$schema = new ObjectSchema(\n    name: 'languages',\n    description: 'Top programming languages',\n    properties: [\n        new ArraySchema(\n            'languages',\n            'List of programming languages',\n            items: new ObjectSchema(\n                name: 'language',\n                description: 'Programming language details',\n                properties: [\n                    new StringSchema('name', 'The language name'),\n                    new StringSchema('popularity', 'Popularity description'),\n                ]\n            )\n        )\n    ]\n);\n\n$response = Prism::structured()\n    -\u003eusing(Bedrock::KEY, 'anthropic.claude-3-sonnet-20240229-v1:0')\n    -\u003ewithSchema($schema)\n    -\u003ewithPrompt('List the top 3 programming languages')\n    -\u003easStructured();\n\n// Access your structured data\n$data = $response-\u003estructured;\n```\n\n### Embeddings (with Cohere models)\n\n```php\nuse Prism\\Prism\\Prism;\nuse Prism\\Bedrock\\Bedrock;\n\n$response = Prism::embeddings()\n    -\u003eusing(Bedrock::KEY, 'cohere.embed-english-v3')\n    -\u003efromArray(['The sky is blue', 'Water is wet'])\n    -\u003easEmbeddings();\n\n// Access the embeddings\n$embeddings = $response-\u003eembeddings;\n```\n\n### Model names\n\n\u003e [!IMPORTANT]\n\u003e When using inference profiles via an ARN, you should urlencode the model name.\n\n```php\nuse Prism\\Prism\\Prism;\nuse Prism\\Bedrock\\Bedrock;\n\n$response = Prism::text()\n    -\u003eusing(Bedrock::KEY, urlencode('arn:aws:bedrock:us-east-1:999999999999:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0'))\n    -\u003ewithPrompt('Explain quantum computing in simple terms')\n    -\u003easText();\n```\n\n## Supported API Schemas\n\nAWS Bedrock supports several API schemas - some LLM vendor specific, some generic.\n\nPrism Bedrock supports three of those API schemas:\n\n- **Converse**: AWS's native interface for chat (default)*\n- **Anthropic**: For Claude models**\n- **Cohere**: For Cohere embeddings models\n\nEach schema supports different capabilities:\n\n| Schema | Text | Structured | Embeddings |\n|--------|:----:|:----------:|:----------:|\n| Converse | ✅ | ✅ | ❌ |\n| Anthropic | ✅ | ✅ | ❌ |\n| Cohere | ❌ | ❌ | ✅ |\n\n\\* A unified interface for multiple providers. See [AWS documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-supported-models-features.html) for a list of supported models.\n\n\\*\\* The Converse schema does not support Anthropic's native features (e.g. PDF vision analysis). This schema uses Anthropic's native schema and therefore allows use of Anthropic native features. Please note however that Bedrock's Anthropic schema does not yet have feature parity with Anthropic. Notably it does not support documents or citations, and only supports prompt caching for Claude Sonnet 3.7 and Claude Haiku 3.5. To use documents with Anthropic's models, use them via the Converse schema (though note that this not the same as using Anthropic's PDF vision directly).\n\n## Auto-resolution of API schemas\n\nPrism Bedrock resolves the most appropriate API schema from the model string. If it is unable to resolve a specific schema (e.g. anthropic for Anthropic), it will default to Converse.\n\nTherefore if you use a model that is not supported by AWS Bedrock Converse, and does not have a specific Prism Bedrock implementation, your request will fail.\n\nIf you wish to force Prism Bedrock to use Converse instead of a vendor specific interface, you can do so with `withProviderOptions()`:\n\n```php\nuse Prism\\Prism\\Prism;\nuse Prism\\Bedrock\\Bedrock;\nuse Prism\\Bedrock\\Enums\\BedrockSchema;\n\n$response = Prism::text()\n    -\u003eusing(Bedrock::KEY, 'anthropic.claude-3-sonnet-20240229-v1:0')\n    -\u003ewithProviderOptions(['apiSchema' =\u003e BedrockSchema::Converse])\n    -\u003ewithPrompt('Explain quantum computing in simple terms')\n    -\u003easText();\n\n```\n\n## Cache-Optimized Prompts\n\nFor [supported models](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html), you can enable prompt caching to reduce latency and costs:\n\n```php\nuse Prism\\Prism\\Prism;\nuse Prism\\Bedrock\\Bedrock;\nuse Prism\\Prism\\ValueObjects\\Messages\\UserMessage;\n\n$response = Prism::text()\n    -\u003eusing(Bedrock::KEY, 'anthropic.claude-3-sonnet-20240229-v1:0')\n    -\u003ewithMessages([\n        (new UserMessage('Message with cache breakpoint'))-\u003ewithProviderOptions(['cacheType' =\u003e 'ephemeral']),\n        (new UserMessage('Message with another cache breakpoint'))-\u003ewithProviderOptions(['cacheType' =\u003e 'ephemeral']),\n        new UserMessage('Compare the last two messages.')\n    ])\n    -\u003easText();\n```\n\n\u003e [!TIP]\n\u003e Anthropic currently supports a cacheType of \"ephemeral\". Converse currently supports a cacheType of \"default\". It is possible that Anthropic and/or AWS may add additional types in the future.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n\n## Authors\n\nThis library is created by [TJ Miller](https://tjmiller.me) with contributions from the [Open Source Community](https://github.com/echolabsdev/prism-bedrock/graphs/contributors).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprism-php%2Fbedrock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprism-php%2Fbedrock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprism-php%2Fbedrock/lists"}