Download the PHP package descom/ai-core without Composer
On this page you can find all versions of the php package descom/ai-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package ai-core
Ai
Installation
Usage
BedrockClientConverse is the wrapper around AWS Bedrock's Converse API. The recommended way to use it is through the Agent abstraction; you can also instantiate the client directly when you need finer control over the message history.
1. Recommended flow — extend Agent
Define an agent by extending Descom\Ai\Bedrock\Converse\Agent and providing a model id, a system prompt and the list of tools (empty array if you don't use any):
Agent exposes three convenience helpers that build the Messages collection for you:
2. Direct use of BedrockClientConverse
When you need to build a custom message history (multi-turn conversation, mixed roles, replayed transcripts) instantiate the client directly with an Agent and call request():
3. Multi-modal message (image + text in a single turn)
A single message can carry several content items. Combine TextContent with ImageContent, DocumentContent or AudioContent, and choose BinarySource (raw bytes) or S3Source (objects stored in S3):
4. Tool calling
Define a tool by implementing Descom\Ai\Tools\ToolsContract:
Then expose it from your agent's tools() method. Each entry describes the JSON schema sent to Bedrock and the PHP class that handles invocations:
When the model returns a tool_use stop reason, BedrockClientConverse::request() automatically runs the tool, appends its result to the conversation and re-calls the model — your code only needs to read the final Response.
5. Inspecting the response
request() returns a Descom\Ai\Bedrock\Messages\Response\Response with typed accessors:
6. Error handling
Any AWS SDK exception raised during the underlying converse() call is wrapped in BedrockRequestException. The original exception is preserved as $previous, and the offending request payload is exposed on the payload property for debugging:
All versions of ai-core with dependencies
aws/aws-sdk-php Version ^3.300
illuminate/contracts Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0