Share
Embed
Unveil Symfonyย AI
July 2025, the Symfony AI was launched as an initiative, just like Symfony UX, to help developers integrate AI into their apps with ready-to-use components and bundles.
In this talk, letโs discover Symfony AIโs origins, explore its components, and learn how to use them with any AI platform. Weโll also cover how to get started using it in your PHP apps and contribute to the project!
Mathieu Santostefano
April 17, 2026
Transcript
182 slides
-
Mathieu Santostefano Tech Expert SensioLabs Symfony Core Team Member Clever
Cloud Ambassador @welcomattic.com @welcomattic Hello! -
๐ Announced July 2025 ๐ฆ Mono-repository symfony/ai โจ Symfony Standards
Following Symfony best practices Initiative ` ` 4 -
๐ Announced July 2025 ๐ฆ Mono-repository symfony/ai โจ Symfony Standards
Following Symfony best practices ๐งช Experimental Active development, v0.5 tagged last week Initiative ` ` 4 -
๐ Enable AI Features in PHP applications ๐ง Not only
LLMs Complete AI ecosystem integration Main Goals 5 -
๐ Enable AI Features in PHP applications ๐ง Not only
LLMs Complete AI ecosystem integration ๐ฆ PHP Components Set Modular and reusable Main Goals 5 -
๐ Enable AI Features in PHP applications ๐ง Not only
LLMs Complete AI ecosystem integration ๐ฆ PHP Components Set Modular and reusable ๐ Vendor Agnostic Works with multiple AI providers Main Goals 5 -
โญ 80+ packages across 4 sub-projects ๐ฅ 100+ contributors from
the community Stats 6 -
โญ 80+ packages across 4 sub-projects ๐ฅ 100+ contributors from
the community ๐ป 2600+ commits since launch Stats 6 -
โญ 80+ packages across 4 sub-projects ๐ฅ 100+ contributors from
the community ๐ป 2600+ commits since launch ๐ 25+ Platform Bridges for AI providers Stats 6 -
โญ 80+ packages across 4 sub-projects ๐ฅ 100+ contributors from
the community ๐ป 2600+ commits since launch ๐ 25+ Platform Bridges for AI providers ๐ 20+ Store Bridges for vector databases Stats 6 -
โญ 80+ packages across 4 sub-projects ๐ฅ 100+ contributors from
the community ๐ป 2600+ commits since launch ๐ 25+ Platform Bridges for AI providers ๐ 20+ Store Bridges for vector databases ๐ ๏ธ 10+ Tools executable by AI agents Stats 6 -
๐ Abstraction layer for AI Platforms: "where models run" ๐ฏ
Central Interface for Model Inference Platform Component 9 -
๐ Abstraction layer for AI Platforms: "where models run" ๐ฏ
Central Interface for Model Inference ๐ Bridges to connect 25+ AI Platforms Platform Component 9 -
๐ Abstraction layer for AI Platforms: "where models run" ๐ฏ
Central Interface for Model Inference ๐ Bridges to connect 25+ AI Platforms ๐จ Multi-modal compatibility (text, image, audio, PDF) Platform Component 9 -
๐ Abstraction layer for AI Platforms: "where models run" ๐ฏ
Central Interface for Model Inference ๐ Bridges to connect 25+ AI Platforms ๐จ Multi-modal compatibility (text, image, audio, PDF) ๐ก Event system to hook into the lifecycle Platform Component 9 -
๐ Abstraction layer for AI Platforms: "where models run" ๐ฏ
Central Interface for Model Inference ๐ Bridges to connect 25+ AI Platforms ๐จ Multi-modal compatibility (text, image, audio, PDF) ๐ก Event system to hook into the lifecycle Platform Component composer require symfony/ai-platform 9 -
(aka "run a prompt on a model") Model Inference use
Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory; use Symfony\AI\Platform\Message\{Message, MessageBag}; $platform = PlatformFactory::create($apiKey); $input = new MessageBag( Message::forSystem('You are a pirate and you write funny.'), Message::ofUser('What is the Symfony framework?'), ); $result = $platform->invoke('gpt-5-mini', $input); echo $result->asText(); 11 -
(aka "run a prompt on a model") Model Inference use
Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory; use Symfony\AI\Platform\Message\{Message, MessageBag}; $platform = PlatformFactory::create($apiKey); $input = new MessageBag( Message::forSystem('You are a pirate and you write funny.'), Message::ofUser('What is the Symfony framework?'), ); $result = $platform->invoke('gpt-5-mini', $input); echo $result->asText(); 11 -
(aka "run a prompt on a model") Model Inference $platform
= PlatformFactory::create($apiKey); use Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory; use Symfony\AI\Platform\Message\{Message, MessageBag}; $input = new MessageBag( Message::forSystem('You are a pirate and you write funny.'), Message::ofUser('What is the Symfony framework?'), ); $result = $platform->invoke('gpt-5-mini', $input); echo $result->asText(); 11 -
(aka "run a prompt on a model") Model Inference $input
= new MessageBag( Message::forSystem('You are a pirate and you write funny.'), Message::ofUser('What is the Symfony framework?'), ); use Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory; use Symfony\AI\Platform\Message\{Message, MessageBag}; $platform = PlatformFactory::create($apiKey); $result = $platform->invoke('gpt-5-mini', $input); echo $result->asText(); 11 -
(aka "run a prompt on a model") Model Inference $result
= $platform->invoke('gpt-5-mini', $input); use Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory; use Symfony\AI\Platform\Message\{Message, MessageBag}; $platform = PlatformFactory::create($apiKey); $input = new MessageBag( Message::forSystem('You are a pirate and you write funny.'), Message::ofUser('What is the Symfony framework?'), ); echo $result->asText(); 11 -
(aka "run a prompt on a model") Model Inference echo
$result->asText(); use Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory; use Symfony\AI\Platform\Message\{Message, MessageBag}; $platform = PlatformFactory::create($apiKey); $input = new MessageBag( Message::forSystem('You are a pirate and you write funny.'), Message::ofUser('What is the Symfony framework?'), ); $result = $platform->invoke('gpt-5-mini', $input); 11 -
OpenAI Platform / GPT 5 mini Model use Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory; $result
= $platform->invoke('gpt-5-mini', $input); use Symfony\AI\Platform\Message\{Message, MessageBag}; $platform = PlatformFactory::create($apiKey); $input = new MessageBag( Message::forSystem('You are a pirate and you write funny.'), Message::ofUser('What is the Symfony framework?'), ); echo $result->asText(); 12 -
Anthropic Platform / Claude Sonnet 4.5 Model use Symfony\AI\Platform\Bridge\Anthropic\PlatformFactory; $result
= $platform->invoke('claude-sonnet-4-5-20250929', $input); use Symfony\AI\Platform\Message\{Message, MessageBag}; $platform = PlatformFactory::create($apiKey); $input = new MessageBag( Message::forSystem('You are a pirate and you write funny.'), Message::ofUser('What is the Symfony framework?'), ); echo $result->asText(); 13 -
Google Gemini Platform / Gemini 3 Pro Model use Symfony\AI\Platform\Bridge\Gemini\PlatformFactory;
$result = $platform->invoke('gemini-3-pro', $input); use Symfony\AI\Platform\Message\{Message, MessageBag}; $platform = PlatformFactory::create($apiKey); $input = new MessageBag( Message::forSystem('You are a pirate and you write funny.'), Message::ofUser('What is the Symfony framework?'), ); echo $result->asText(); 14 -
Mistral Platform / Mistral Large Model use Symfony\AI\Platform\Bridge\Mistral\PlatformFactory; $result =
$platform->invoke('mistral-large-latest', $input); use Symfony\AI\Platform\Message\{Message, MessageBag}; $platform = PlatformFactory::create($apiKey); $input = new MessageBag( Message::forSystem('You are a pirate and you write funny.'), Message::ofUser('What is the Symfony framework?'), ); echo $result->asText(); 15 -
(to handle response token per token) Streaming $input = new
MessageBag( Message::forSystem('You are a pirate and you write funny.'), Message::ofUser('What is the Symfony framework?'), ); $result = $platform->invoke('mistral-large-latest', $input, [ 'stream' => true, ]); foreach ($result->asStream() as $word) { echo $word; } 16 -
Multi-modal: Process audio files Audio Input ๐ต $input = new
MessageBag( Message::ofUser( 'Describe the audio file.', Audio::fromDataUrl('data:audio/mpeg;base64,/9j/4AAQ...'), ), ); $result = $platform->invoke('gemini-2.5-flash', $input); echo $result->asText(); 17 -
Multi-modal: Analyze images Image Input ๐ผ๏ธ $input = new MessageBag(
Message::ofUser( 'What is visible on the image?', new ImageUrl('https://example.org/elephant.jpg'), ), ); $result = $platform->invoke('gemini-2.5-flash', $input); echo $result->asText(); 18 -
Multi-modal: Extract from documents PDF Input ๐ $input = new
MessageBag( Message::ofUser( 'Describe the content of the PDF file.', Document::fromFile('/path/to/document.pdf'), ), ); $result = $platform->invoke('gemini-2.5-flash', $input); echo $result->asText(); 19 -
(to manipulate output programmatically) Structured Output ๐ $input = new
MessageBag( Message::forSystem('Help users as math tutor, step by step.'), Message::ofUser('how can I solve 8x + 7 = -23'), ); $result = $platform->invoke('mistral-small-latest', $messages, [ 'response_format' => MathReasoning::class, ]); echo $result->asObject(); 20 -
(to transform content into mathematical vectors) Embedded Models ๐ข $result
= $platform->invoke('text-embedding-3-small', $text); echo $result->asVector(); // array of floats 22 -
(to transform content into mathematical vectors) โจ Perfect for semantic
search and RAG (Retrieval-Augmented Generation) applications Embedded Models ๐ข $result = $platform->invoke('text-embedding-3-small', $text); echo $result->asVector(); // array of floats 22 -
(trigger different tasks like NLP, Computer Vision, Robotics, โฆ) Hugging
Face Integration ๐ค use Symfony\AI\Platform\Bridge\HuggingFace\PlatformFactory; use Symfony\AI\Platform\Bridge\HuggingFace\Task; $platform = PlatformFactory::create($apiKey); $result = $platform->invoke('facebook/detr-resnet-50', $image, [ 'task' => Task::OBJECT_DETECTION, ]); echo $result->asObject(); // image classification result 23 -
(trigger different tasks like NLP, Computer Vision, Robotics, โฆ) Hugging
Face Integration ๐ค use Symfony\AI\Platform\Bridge\HuggingFace\PlatformFactory; use Symfony\AI\Platform\Bridge\HuggingFace\Task; $platform = PlatformFactory::create($apiKey); $result = $platform->invoke('facebook/detr-resnet-50', $image, [ 'task' => Task::OBJECT_DETECTION, ]); echo $result->asObject(); // image classification result 23 -
(trigger different tasks like NLP, Computer Vision, Robotics, โฆ) Hugging
Face Integration ๐ค $platform = PlatformFactory::create($apiKey); $result = $platform->invoke('facebook/detr-resnet-50', $image, [ 'task' => Task::OBJECT_DETECTION, ]); use Symfony\AI\Platform\Bridge\HuggingFace\PlatformFactory; use Symfony\AI\Platform\Bridge\HuggingFace\Task; echo $result->asObject(); // image classification result 23 -
(trigger different tasks like NLP, Computer Vision, Robotics, โฆ) Hugging
Face Integration ๐ค echo $result->asObject(); // image classification result use Symfony\AI\Platform\Bridge\HuggingFace\PlatformFactory; use Symfony\AI\Platform\Bridge\HuggingFace\Task; $platform = PlatformFactory::create($apiKey); $result = $platform->invoke('facebook/detr-resnet-50', $image, [ 'task' => Task::OBJECT_DETECTION, ]); 23 -
(trigger different tasks like NLP, Computer Vision, Robotics, โฆ) ๐
Integration with Hugging Faceโs Inference Hub API - Access thousands of open-source models Hugging Face Integration ๐ค echo $result->asObject(); // image classification result use Symfony\AI\Platform\Bridge\HuggingFace\PlatformFactory; use Symfony\AI\Platform\Bridge\HuggingFace\Task; $platform = PlatformFactory::create($apiKey); $result = $platform->invoke('facebook/detr-resnet-50', $image, [ 'task' => Task::OBJECT_DETECTION, ]); 23 -
Native Platforms Run providerโs models on providerโs infrastructure Anthropic Cartesia
Decart DeepSeek ElevenLabs Gemini Meta Mistral OpenAI Perplexity Voyage 25+ Platform Bridges available 24 -
Model Runner Platforms (Model-as-a-Service) Run models on other cloud infrastructure
AI/ML API Albert Azure AI Bedrock Cerebras HuggingFace Replicate OpenRouter Scaleway AI VertexAI 25+ Platform Bridges available 25 -
Self-Hosted Platforms Run models on your own infrastructure Ollama Docker
Model Runner LiteLLM LM Studio 25+ Platform Bridges available 26 -
๐ค Multi-step Interaction with AI Models ๐งฉ Combination of Components:
Platform & Models Messages / Prompts as Context Memory for conversations Tools for external actions Event-driven workflows Agent Component 28 -
๐ค Multi-step Interaction with AI Models ๐งฉ Combination of Components:
Platform & Models Messages / Prompts as Context Memory for conversations Tools for external actions Event-driven workflows ๐๏ธ Various Architectures From static workflows to autonomous orchestration Agent Component 28 -
๐ค Multi-step Interaction with AI Models ๐งฉ Combination of Components:
Platform & Models Messages / Prompts as Context Memory for conversations Tools for external actions Event-driven workflows ๐๏ธ Various Architectures From static workflows to autonomous orchestration Agent Component composer require symfony/ai-agent 28 -
1. Agent provides Tools to the Model Exposed to Model
as JSON Schema definition Tool Calling Flow ๐ง 30 -
1. Agent provides Tools to the Model Exposed to Model
as JSON Schema definition 2. Model invokes Tools by name with arguments Intermediate step in the conversation flow Tool Calling Flow ๐ง 30 -
1. Agent provides Tools to the Model Exposed to Model
as JSON Schema definition 2. Model invokes Tools by name with arguments Intermediate step in the conversation flow 3. Tool execution by the Agent Run PHP Code, run a CLI, call an API, etc. Tool Calling Flow ๐ง 30 -
1. Agent provides Tools to the Model Exposed to Model
as JSON Schema definition 2. Model invokes Tools by name with arguments Intermediate step in the conversation flow 3. Tool execution by the Agent Run PHP Code, run a CLI, call an API, etc. 4. Result sent back to the Model Model uses result to continue conversation Tool Calling Flow ๐ง 30 -
1. Agent provides Tools to the Model Exposed to Model
as JSON Schema definition 2. Model invokes Tools by name with arguments Intermediate step in the conversation flow 3. Tool execution by the Agent Run PHP Code, run a CLI, call an API, etc. 4. Result sent back to the Model Model uses result to continue conversation 5. Instrumentation throughout the process Log and analyze all Tool calls and results Tool Calling Flow ๐ง 30 -
Tool Calling Example use Symfony\AI\Agent\Toolbox\Attribute\AsTool; use Symfony\Component\Clock\ClockInterface; #[AsTool('cookbook_create_recipe', 'Creates a
new recipe in the cookbook.')] final readonly class CookbookCreateRecipe { public function __construct( private EntityManagerInterface $em, ) {} public function __invoke(Recipe $recipe): string { // validate & persist recipe ... return 'Recipe created successfully!'; } } 32 -
Tool Calling Example #[AsTool('cookbook_create_recipe', 'Creates a new recipe in the
cookbook.')] use Symfony\AI\Agent\Toolbox\Attribute\AsTool; use Symfony\Component\Clock\ClockInterface; final readonly class CookbookCreateRecipe { public function __construct( private EntityManagerInterface $em, ) {} public function __invoke(Recipe $recipe): string { // validate & persist recipe ... return 'Recipe created successfully!'; } } 32 -
Tool Calling Example final readonly class CookbookCreateRecipe use Symfony\AI\Agent\Toolbox\Attribute\AsTool; use
Symfony\Component\Clock\ClockInterface; #[AsTool('cookbook_create_recipe', 'Creates a new recipe in the cookbook.')] { public function __construct( private EntityManagerInterface $em, ) {} public function __invoke(Recipe $recipe): string { // validate & persist recipe ... return 'Recipe created successfully!'; } } 32 -
Tool Calling Example public function __construct( private EntityManagerInterface $em, )
{} use Symfony\AI\Agent\Toolbox\Attribute\AsTool; use Symfony\Component\Clock\ClockInterface; #[AsTool('cookbook_create_recipe', 'Creates a new recipe in the cookbook.')] final readonly class CookbookCreateRecipe { public function __invoke(Recipe $recipe): string { // validate & persist recipe ... return 'Recipe created successfully!'; } } 32 -
Tool Calling Example public function __invoke(Recipe $recipe): string { //
validate & persist recipe ... return 'Recipe created successfully!'; } use Symfony\AI\Agent\Toolbox\Attribute\AsTool; use Symfony\Component\Clock\ClockInterface; #[AsTool('cookbook_create_recipe', 'Creates a new recipe in the cookbook.')] final readonly class CookbookCreateRecipe { public function __construct( private EntityManagerInterface $em, ) {} } 32 -
10+ Tool Bridges available Brave Clock Firecrawl Mapbox OpenMeteo Scraper
Serpapi Tavily Wikipedia YouTube Agent Tool Bridges ๐ ๏ธ 33 -
๐ Open Standard by Anthropic (Nov 2024) ๐ Universal Adapter
for AI like USB-C for devices MCP 36 -
๐ Open Standard by Anthropic (Nov 2024) ๐ Universal Adapter
for AI like USB-C for devices ๐ค Standardized Integration between LLMs and external tools MCP 36 -
๐ Open Standard by Anthropic (Nov 2024) ๐ Universal Adapter
for AI like USB-C for devices ๐ค Standardized Integration between LLMs and external tools ๐ข Industry Adoption OpenAI, Google, Anthropic, Mistral MCP 36 -
๐ Open Standard by Anthropic (Nov 2024) ๐ Universal Adapter
for AI like USB-C for devices ๐ค Standardized Integration between LLMs and external tools ๐ข Industry Adoption OpenAI, Google, Anthropic, Mistral ๐ง Expose Capabilities Tools, Resources, Prompts MCP 36 -
MCP Server Capabilities Capability Description Tools Functions the model can
invoke (API calls, DB queries) Resources Data sources the model can read (files, configs) Prompts Pre-defined prompt templates for common tasks MCP Architecture 38 -
๐ฆ Framework-agnostic Works with any PHP project ๐ท๏ธ PHP 8
Attributes #[McpTool] , #[McpResource] , # [McpPrompt] Official PHP SDK ` ` ` ` ` ` 39 -
๐ฆ Framework-agnostic Works with any PHP project ๐ท๏ธ PHP 8
Attributes #[McpTool] , #[McpResource] , # [McpPrompt] ๐ Auto-discovery Scans directories for MCP elements Official PHP SDK ` ` ` ` ` ` 39 -
๐ฆ Framework-agnostic Works with any PHP project ๐ท๏ธ PHP 8
Attributes #[McpTool] , #[McpResource] , # [McpPrompt] ๐ Auto-discovery Scans directories for MCP elements ๐ Transport options STDIO and Streamable HTTP support Official PHP SDK ` ` ` ` ` ` 39 -
๐ฆ Framework-agnostic Works with any PHP project ๐ท๏ธ PHP 8
Attributes #[McpTool] , #[McpResource] , # [McpPrompt] ๐ Auto-discovery Scans directories for MCP elements ๐ Transport options STDIO and Streamable HTTP support GitHub: github.com/modelcontextprotocol/php-sdk Official PHP SDK ` ` ` ` ` ` composer require mcp/sdk 39 -
Creating an MCP Server (STDIO Transport) #!/usr/bin/env php <?php require_once
__DIR__ . '/vendor/autoload.php'; use Mcp\Server; use Mcp\Server\Transport\StdioTransport; $server = Server::builder() ->setServerInfo('Calculator Server', '1.0.0') ->setDiscovery(__DIR__, ['.']) ->build(); $transport = new StdioTransport(); $server->run($transport); 40 -
Creating an MCP Server (STDIO Transport) use Mcp\Server; use Mcp\Server\Transport\StdioTransport;
#!/usr/bin/env php <?php require_once __DIR__ . '/vendor/autoload.php'; $server = Server::builder() ->setServerInfo('Calculator Server', '1.0.0') ->setDiscovery(__DIR__, ['.']) ->build(); $transport = new StdioTransport(); $server->run($transport); 40 -
Creating an MCP Server (STDIO Transport) $server = Server::builder() ->setServerInfo('Calculator
Server', '1.0.0') ->setDiscovery(__DIR__, ['.']) ->build(); #!/usr/bin/env php <?php require_once __DIR__ . '/vendor/autoload.php'; use Mcp\Server; use Mcp\Server\Transport\StdioTransport; $transport = new StdioTransport(); $server->run($transport); 40 -
Creating an MCP Server (STDIO Transport) $transport = new StdioTransport();
$server->run($transport); #!/usr/bin/env php <?php require_once __DIR__ . '/vendor/autoload.php'; use Mcp\Server; use Mcp\Server\Transport\StdioTransport; $server = Server::builder() ->setServerInfo('Calculator Server', '1.0.0') ->setDiscovery(__DIR__, ['.']) ->build(); 40 -
Creating an MCP Server (STDIO Transport) $transport = new StdioTransport();
$server->run($transport); #!/usr/bin/env php <?php require_once __DIR__ . '/vendor/autoload.php'; use Mcp\Server; use Mcp\Server\Transport\StdioTransport; $server = Server::builder() ->setServerInfo('Calculator Server', '1.0.0') ->setDiscovery(__DIR__, ['.']) ->build(); 40 -
Creating Tools (Code that model can invoke) use Mcp\Capability\Attribute\McpTool; class
WeatherTools { #[McpTool(name: 'get_weather', description: 'Get current weather for a city')] public function getWeather(string $city): array { // Call weather API... return ['condition' => $condition, 'temperature' => $temperature]; } } 41 -
Creating Tools (Code that model can invoke) use Mcp\Capability\Attribute\McpTool; class
WeatherTools { #[McpTool(name: 'get_weather', description: 'Get current weather for a city')] public function getWeather(string $city): array { // Call weather API... return ['condition' => $condition, 'temperature' => $temperature]; } } 41 -
Creating Tools (Code that model can invoke) class WeatherTools use
Mcp\Capability\Attribute\McpTool; { #[McpTool(name: 'get_weather', description: 'Get current weather for a city')] public function getWeather(string $city): array { // Call weather API... return ['condition' => $condition, 'temperature' => $temperature]; } } 41 -
Creating Tools (Code that model can invoke) #[McpTool(name: 'get_weather', description:
'Get current weather for a city')] use Mcp\Capability\Attribute\McpTool; class WeatherTools { public function getWeather(string $city): array { // Call weather API... return ['condition' => $condition, 'temperature' => $temperature]; } } 41 -
Creating Tools (Code that model can invoke) #[McpTool(name: 'get_weather', description:
'Get current weather for a city')] public function getWeather(string $city): array { // Call weather API... return ['condition' => $condition, 'temperature' => $temperature]; } } use Mcp\Capability\Attribute\McpTool; class WeatherTools { 41 -
โ The model can now call get_weather with a city
name and receive structured data back Creating Tools (Code that model can invoke) #[McpTool(name: 'get_weather', description: 'Get current weather for a city')] public function getWeather(string $city): array { // Call weather API... return ['condition' => $condition, 'temperature' => $temperature]; } } use Mcp\Capability\Attribute\McpTool; class WeatherTools { ` ` 41 -
Creating Resources (Data the model can read) use Mcp\Capability\Attribute\McpResource; class
ConfigResources { #[McpResource(uri: 'config://app/settings', name: 'App Settings')] public function getSettings(): array { return [ 'app_name' => 'My Application', 'version' => '2.0.0', ]; } } 42 -
Creating Resources (Data the model can read) use Mcp\Capability\Attribute\McpResource; class
ConfigResources { #[McpResource(uri: 'config://app/settings', name: 'App Settings')] public function getSettings(): array { return [ 'app_name' => 'My Application', 'version' => '2.0.0', ]; } } 42 -
Creating Resources (Data the model can read) class ConfigResources use
Mcp\Capability\Attribute\McpResource; { #[McpResource(uri: 'config://app/settings', name: 'App Settings')] public function getSettings(): array { return [ 'app_name' => 'My Application', 'version' => '2.0.0', ]; } } 42 -
Creating Resources (Data the model can read) #[McpResource(uri: 'config://app/settings', name:
'App Settings')] use Mcp\Capability\Attribute\McpResource; class ConfigResources { public function getSettings(): array { return [ 'app_name' => 'My Application', 'version' => '2.0.0', ]; } } 42 -
Creating Resources (Data the model can read) #[McpResource(uri: 'config://app/settings', name:
'App Settings')] public function getSettings(): array { return [ 'app_name' => 'My Application', 'version' => '2.0.0', ]; } } use Mcp\Capability\Attribute\McpResource; class ConfigResources { 42 -
๐ Resources use URI schemes - the model reads config://app/settings
to get app configuration Creating Resources (Data the model can read) #[McpResource(uri: 'config://app/settings', name: 'App Settings')] public function getSettings(): array { return [ 'app_name' => 'My Application', 'version' => '2.0.0', ]; } } use Mcp\Capability\Attribute\McpResource; class ConfigResources { ` ` 42 -
Resource Templates (Dynamic resources) use Mcp\Capability\Attribute\McpResourceTemplate; class UserResources { #[McpResourceTemplate(uriTemplate:
'user://{id}/profile', name: 'User Profile')] public function getUserProfile(int $id): array { // Fetch user from database... return ['name' => $user->getName(), 'email' => $user->getEmail()]; } } 43 -
Resource Templates (Dynamic resources) use Mcp\Capability\Attribute\McpResourceTemplate; class UserResources { #[McpResourceTemplate(uriTemplate:
'user://{id}/profile', name: 'User Profile')] public function getUserProfile(int $id): array { // Fetch user from database... return ['name' => $user->getName(), 'email' => $user->getEmail()]; } } 43 -
Resource Templates (Dynamic resources) class UserResources use Mcp\Capability\Attribute\McpResourceTemplate; { #[McpResourceTemplate(uriTemplate:
'user://{id}/profile', name: 'User Profile')] public function getUserProfile(int $id): array { // Fetch user from database... return ['name' => $user->getName(), 'email' => $user->getEmail()]; } } 43 -
Resource Templates (Dynamic resources) #[McpResourceTemplate(uriTemplate: 'user://{id}/profile', name: 'User Profile')] use
Mcp\Capability\Attribute\McpResourceTemplate; class UserResources { public function getUserProfile(int $id): array { // Fetch user from database... return ['name' => $user->getName(), 'email' => $user->getEmail()]; } } 43 -
Resource Templates (Dynamic resources) #[McpResourceTemplate(uriTemplate: 'user://{id}/profile', name: 'User Profile')] public
function getUserProfile(int $id): array { // Fetch user from database... return ['name' => $user->getName(), 'email' => $user->getEmail()]; } } use Mcp\Capability\Attribute\McpResourceTemplate; class UserResources { 43 -
๐ Uses RFC 6570 URI Template syntax - model requests
user://42/profile to get user #42 Resource Templates (Dynamic resources) #[McpResourceTemplate(uriTemplate: 'user://{id}/profile', name: 'User Profile')] public function getUserProfile(int $id): array { // Fetch user from database... return ['name' => $user->getName(), 'email' => $user->getEmail()]; } } use Mcp\Capability\Attribute\McpResourceTemplate; class UserResources { ` ` 43 -
Creating Prompts templates use Mcp\Capability\Attribute\McpPrompt; class PromptTemplates { #[McpPrompt(name: 'code_review',
description: 'Review code for best practices')] public function codeReviewPrompt(string $language, string $code): array { return ['messages' => [ ['role' => 'user', 'content' => "Review this {$language} code:\n\n{$code}"] ]]; } } 44 -
Creating Prompts templates use Mcp\Capability\Attribute\McpPrompt; class PromptTemplates { #[McpPrompt(name: 'code_review',
description: 'Review code for best practices')] public function codeReviewPrompt(string $language, string $code): array { return ['messages' => [ ['role' => 'user', 'content' => "Review this {$language} code:\n\n{$code}"] ]]; } } 44 -
Creating Prompts templates class PromptTemplates use Mcp\Capability\Attribute\McpPrompt; { #[McpPrompt(name: 'code_review',
description: 'Review code for best practices')] public function codeReviewPrompt(string $language, string $code): array { return ['messages' => [ ['role' => 'user', 'content' => "Review this {$language} code:\n\n{$code}"] ]]; } } 44 -
Creating Prompts templates #[McpPrompt(name: 'code_review', description: 'Review code for best
practices')] use Mcp\Capability\Attribute\McpPrompt; class PromptTemplates { public function codeReviewPrompt(string $language, string $code): array { return ['messages' => [ ['role' => 'user', 'content' => "Review this {$language} code:\n\n{$code}"] ]]; } } 44 -
Creating Prompts templates #[McpPrompt(name: 'code_review', description: 'Review code for best
practices')] public function codeReviewPrompt(string $language, string $code): array { return ['messages' => [ ['role' => 'user', 'content' => "Review this {$language} code:\n\n{$code}"] ]]; } } use Mcp\Capability\Attribute\McpPrompt; class PromptTemplates { 44 -
๐ Prompts provide reusable templates - clients can request code_review
with parameters Creating Prompts templates #[McpPrompt(name: 'code_review', description: 'Review code for best practices')] public function codeReviewPrompt(string $language, string $code): array { return ['messages' => [ ['role' => 'user', 'content' => "Review this {$language} code:\n\n{$code}"] ]]; } } use Mcp\Capability\Attribute\McpPrompt; class PromptTemplates { ` ` 44 -
Complete Server Example // autoloader require, use statements... class Calculator
{ #[McpTool(name: 'add', description: 'Add two numbers')] public function add(int $a, int $b): int { return $a + $b; } #[McpTool(name: 'multiply', description: 'Multiply two numbers')] public function multiply(int $a, int $b): int { return $a * $b; } } Server::make() ->withServerInfo('Calculator', '1.0.0') ->withDiscovery(__DIR__, ['.']) ->build() ->connect(new StdioTransport()); 45 -
Complete Server Example // autoloader require, use statements... class Calculator
{ #[McpTool(name: 'add', description: 'Add two numbers')] public function add(int $a, int $b): int { return $a + $b; } #[McpTool(name: 'multiply', description: 'Multiply two numbers')] public function multiply(int $a, int $b): int { return $a * $b; } } Server::make() ->withServerInfo('Calculator', '1.0.0') ->withDiscovery(__DIR__, ['.']) ->build() ->connect(new StdioTransport()); 45 -
Complete Server Example Server::make() ->withServerInfo('Calculator', '1.0.0') ->withDiscovery(__DIR__, ['.']) ->build() ->connect(new
StdioTransport()); // autoloader require, use statements... class Calculator { #[McpTool(name: 'add', description: 'Add two numbers')] public function add(int $a, int $b): int { return $a + $b; } #[McpTool(name: 'multiply', description: 'Multiply two numbers')] public function multiply(int $a, int $b): int { return $a * $b; } } 45 -
๐ฌ Build Chats with Agents ๐๏ธ Built on top of
Agent component: ๐ง With memory using dedicated Store Bridges Chat Component 48 -
๐ฌ Build Chats with Agents ๐๏ธ Built on top of
Agent component: ๐ง With memory using dedicated Store Bridges Cache Cloudflare KV Doctrine DBAL Meilisearch MongoDB Redis Session SurrealDB Pogocache Chat Component 48 -
๐ฌ Build Chats with Agents ๐๏ธ Built on top of
Agent component: ๐ง With memory using dedicated Store Bridges Cache Cloudflare KV Doctrine DBAL Meilisearch MongoDB Redis Session SurrealDB Pogocache Chat Component composer require symfony/ai-chat 48 -
Basic Usage use Symfony\AI\Agent\Agent; use Symfony\AI\Chat\{Chat, InMemory\Store as InMemoryStore}; use
Symfony\AI\Platform\{Bridge\Mistral\PlatformFactory, Message\Message}; $platform = PlatformFactory::create($apiKey); $connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true]); $store = new DoctrineDbalMessageStore('symfony', $connection); $store->setup(); $chat = new Chat(new Agent($platform, 'mistral-small-latest'), $store); $messages = new MessageBag(Message::forSystem('You are a helpful assistant. You only answe $chat->initiate($messages); $chat->submit(Message::ofUser('My name is Mathieu.')); $message = $chat->submit(Message::ofUser('What is my name?')); echo $message->getContent().\PHP_EOL; // "Your name is Mathieu." 49 -
Basic Usage $connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true]);
use Symfony\AI\Agent\Agent; use Symfony\AI\Chat\{Chat, InMemory\Store as InMemoryStore}; use Symfony\AI\Platform\{Bridge\Mistral\PlatformFactory, Message\Message}; $platform = PlatformFactory::create($apiKey); $store = new DoctrineDbalMessageStore('symfony', $connection); $store->setup(); $chat = new Chat(new Agent($platform, 'mistral-small-latest'), $store); $messages = new MessageBag(Message::forSystem('You are a helpful assistant. You only answe $chat->initiate($messages); $chat->submit(Message::ofUser('My name is Mathieu.')); $message = $chat->submit(Message::ofUser('What is my name?')); echo $message->getContent().\PHP_EOL; // "Your name is Mathieu." 49 -
Basic Usage use Symfony\AI\Agent\Agent; use Symfony\AI\Chat\{Chat, InMemory\Store as InMemoryStore}; use
Symfony\AI\Platform\{Bridge\Mistral\PlatformFactory, Message\Message}; $platform = PlatformFactory::create($apiKey); $connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true]); $store = new DoctrineDbalMessageStore('symfony', $connection); $store->setup(); $chat = new Chat(new Agent($platform, 'mistral-small-latest'), $store); $messages = new MessageBag(Message::forSystem('You are a helpful assistant. You only answe $chat->initiate($messages); $chat->submit(Message::ofUser('My name is Mathieu.')); $message = $chat->submit(Message::ofUser('What is my name?')); echo $message->getContent().\PHP_EOL; // "Your name is Mathieu." 49 -
Basic Usage $store->setup(); use Symfony\AI\Agent\Agent; use Symfony\AI\Chat\{Chat, InMemory\Store as InMemoryStore};
use Symfony\AI\Platform\{Bridge\Mistral\PlatformFactory, Message\Message}; $platform = PlatformFactory::create($apiKey); $connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true]); $store = new DoctrineDbalMessageStore('symfony', $connection); $chat = new Chat(new Agent($platform, 'mistral-small-latest'), $store); $messages = new MessageBag(Message::forSystem('You are a helpful assistant. You only answe $chat->initiate($messages); $chat->submit(Message::ofUser('My name is Mathieu.')); $message = $chat->submit(Message::ofUser('What is my name?')); echo $message->getContent().\PHP_EOL; // "Your name is Mathieu." 49 -
Basic Usage $messages = new MessageBag(Message::forSystem('You are a helpful assistant.
You only answe $chat->initiate($messages); use Symfony\AI\Agent\Agent; use Symfony\AI\Chat\{Chat, InMemory\Store as InMemoryStore}; use Symfony\AI\Platform\{Bridge\Mistral\PlatformFactory, Message\Message}; $platform = PlatformFactory::create($apiKey); $connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true]); $store = new DoctrineDbalMessageStore('symfony', $connection); $store->setup(); $chat = new Chat(new Agent($platform, 'mistral-small-latest'), $store); $chat->submit(Message::ofUser('My name is Mathieu.')); $message = $chat->submit(Message::ofUser('What is my name?')); echo $message->getContent().\PHP_EOL; // "Your name is Mathieu." 49 -
Basic Usage $chat->submit(Message::ofUser('My name is Mathieu.')); $message = $chat->submit(Message::ofUser('What is
my name?')); echo $message->getContent().\PHP_EOL; // "Your name is Mathieu." use Symfony\AI\Agent\Agent; use Symfony\AI\Chat\{Chat, InMemory\Store as InMemoryStore}; use Symfony\AI\Platform\{Bridge\Mistral\PlatformFactory, Message\Message}; $platform = PlatformFactory::create($apiKey); $connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true]); $store = new DoctrineDbalMessageStore('symfony', $connection); $store->setup(); $chat = new Chat(new Agent($platform, 'mistral-small-latest'), $store); $messages = new MessageBag(Message::forSystem('You are a helpful assistant. You only answe $chat->initiate($messages); 49 -
๐ฅช Vector Store Abstraction Layer ๐ Lifecycle Management ๐ Adding
& Querying for Documents Store Component 52 -
๐ฅช Vector Store Abstraction Layer ๐ Lifecycle Management ๐ Adding
& Querying for Documents ๐ Document Indexing Pipeline ๐ Loading ๐ Filtering ๐ญ Transforming ๐งฎ Vectorizing Store Component 52 -
๐ฅช Vector Store Abstraction Layer ๐ Lifecycle Management ๐ Adding
& Querying for Documents ๐ Document Indexing Pipeline ๐ Loading ๐ Filtering ๐ญ Transforming ๐งฎ Vectorizing Store Component composer require symfony/ai-store 52 -
Achieve semantic search. Vectorizing a user prompt and searching for
similar documents in a vector database. Then, LLM can infer based on those private documents. ๐ Load โ ๐ Filter โ ๐ญ Transform โ ๐งฎ Vectorize โ ๐ฅ Store Store Component 53 -
18+ Store Bridges available Azure Search ChromaDB Clickhouse CloudFlare Vectorize
Manticore MariaDB Meilisearch Milvus MongoDB Neo4J OpenSearch Pinecone PostgreSQL (pgvector) Qdrant Redis Supabase SurrealDB Typesense Store Bridges ๐ฅ 54 -
Or use the Symfony Flex alias: AI Bundle Installation composer
require symfony/ai-bundle composer require ai 56 -
Or use the Symfony Flex alias: โจ Seamlessly integrates Platform,
Store, and Agent components into Symfony applications AI Bundle Installation composer require symfony/ai-bundle composer require ai 56 -
Bundle Configuration # config/packages/ai.yaml ai: platform: openai: # or anthropic,
mistral, huggingface api_key: '%env(OPENAI_API_KEY)%' agent: default: model: 'gpt-5-mini' prompt: 'You are a pirate and you write funny.' # more options ... store: chroma_db: symfonyblog: collection: 'symfony_blog' # multi_agent, indexer, vectorizer ... 57 -
Bundle Configuration platform: openai: # or anthropic, mistral, huggingface api_key:
'%env(OPENAI_API_KEY)%' # config/packages/ai.yaml ai: agent: default: model: 'gpt-5-mini' prompt: 'You are a pirate and you write funny.' # more options ... store: chroma_db: symfonyblog: collection: 'symfony_blog' # multi_agent, indexer, vectorizer ... 57 -
Bundle Configuration agent: default: model: 'gpt-5-mini' prompt: 'You are a
pirate and you write funny.' # more options ... # config/packages/ai.yaml ai: platform: openai: # or anthropic, mistral, huggingface api_key: '%env(OPENAI_API_KEY)%' store: chroma_db: symfonyblog: collection: 'symfony_blog' # multi_agent, indexer, vectorizer ... 57 -
Bundle Configuration store: chroma_db: symfonyblog: collection: 'symfony_blog' # config/packages/ai.yaml ai:
platform: openai: # or anthropic, mistral, huggingface api_key: '%env(OPENAI_API_KEY)%' agent: default: model: 'gpt-5-mini' prompt: 'You are a pirate and you write funny.' # more options ... # multi_agent, indexer, vectorizer ... 57 -
Bundle Configuration # multi_agent, indexer, vectorizer ... # config/packages/ai.yaml ai:
platform: openai: # or anthropic, mistral, huggingface api_key: '%env(OPENAI_API_KEY)%' agent: default: model: 'gpt-5-mini' prompt: 'You are a pirate and you write funny.' # more options ... store: chroma_db: symfonyblog: collection: 'symfony_blog' 57 -
Subagent as Tool # config/packages/ai.yaml ai: # Platform Configuration ...
agent: researcher: model: 'gpt-4o' prompt: 'You do heavy research.' smalltalker: model: 'gpt-4o-mini' tools: # Agent as tool ๐คฏ - agent: 'researcher' name: 'research_topic' description: 'Does research on a given topic.' 58 -
Platform calls (input, output) Tools calls (parameters, results) Metadata (consumed
tokens, remaining tokens) ๐งโ๐ง Profiler 59 -
Platform calls (input, output) Tools calls (parameters, results) Metadata (consumed
tokens, remaining tokens) MCP Panel (tools, resources, prompts) ๐งโ๐ง Profiler 59 -
Stabilization, code harmonization across components 1.0 release - github.com/symfony/ai/issues/1301 Feature
depth Symfony AI Roadmap 62 -
Stabilization, code harmonization across components 1.0 release - github.com/symfony/ai/issues/1301 Feature
depth Collaborations Symfony AI Roadmap 62 -
Stabilization, code harmonization across components 1.0 release - github.com/symfony/ai/issues/1301 Feature
depth Collaborations Follow emerging standards Symfony AI Roadmap 62 -
Join the club of contributors & users! Made with contrib.rocks.
What are your plans for Symfony AI? 63 -
1. Checkout symfony/ai repository 2. Explore examples/ and demo/ directories
How to? ` ` ` ` ` ` 64 -
1. Checkout symfony/ai repository 2. Explore examples/ and demo/ directories
3. Build your first feature and give feedback How to? ` ` ` ` ` ` 64 -
1. Checkout symfony/ai repository 2. Explore examples/ and demo/ directories
3. Build your first feature and give feedback 4. AGENTS.md and CLAUDE.md files are provided to allow you working with AI agents! How to? ` ` ` ` ` ` ` ` ` ` 64