Symfony AI is a set of components that integrate AI capabilities into PHP applications. This package comprises several lower- and higher-level components, along with their respective integration bundles. Before you get too excited, these AI components are currently marked as experimental, but you can start diving into the examples and demos:
- Platform: A unified interface to various AI platforms like OpenAI, Anthropic, Azure, Google, and more.
- Agent: Framework for building AI agents that can interact with users and perform tasks.
- Store: Data storage abstraction with indexing and retrieval for AI applications.
- MCP SDK: SDK for Model Context Protocol enabling communication between AI agents and tools.
Here's a basic usage example from the GitHub repo's agent component documentation:
use Symfony\AI\Agent\Agent;use Symfony\AI\Platform\Bridge\OpenAI\GPT;use Symfony\AI\Platform\Bridge\OpenAI\PlatformFactory;use Symfony\AI\Platform\Message\Message;use Symfony\AI\Platform\Message\MessageBag; $platform = PlatformFactory::create($apiKey);$model = new GPT(GPT::GPT_4O_MINI); $agent = new Agent($platform, $model);$messages = new MessageBag( Message::forSystem('You are a helpful chatbot answering questions about LLM agent.'), Message::ofUser('Hello, how are you?'),);$response = $agent->call($messages); echo $response->getContent(); // "I'm fine, thank you. How can I help you today?"
Learn More
The Symfony AI repository contains various examples that demonstrate the use of AI components to help you get started. The src folder of the repo breaks things down into subfolders for the individual components and bundles. Each subfolder contains documentation and a README to help you get started with individual components.
Check out the symfony/ai repository to learn more and experiment with these components.