Download the PHP package johannes85/ai-bundle without Composer
On this page you can find all versions of the php package johannes85/ai-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download johannes85/ai-bundle
More information about johannes85/ai-bundle
Files in johannes85/ai-bundle
Package ai-bundle
Short Description Adds AI support to Symfony. Allows easy calling of LLMs like Ollama, OpenAI, GoogleAI, MistralAI, Anthropic, DeepSeek. It also adds an MCP server and client.
License MIT
Informations about the package ai-bundle
Symfony AI Bundle
This PHP Symfony bundle allows to call LLM backends like OpenAI, Ollama etc. in a generic and simple way.
It also provides an MCP client and server with tool calling capabilities. This allows you to easily expose your Symfony services as MCP tools or call MCP tools provided by an MCP server.
The following backends are supported:
| Backend | Text generation | Image processing | Tool calling | MCP Tool calling | Info |
|---|---|---|---|---|---|
| OpenAI | ✅ | ✅ | ✅ | ✅ | https://openai.com/ |
| Ollama | ✅ | ✅ | ✅*1 | ✅ | https://ollama.ai/ |
| GoogleAI | ✅ | ✅ | ✅ | ✅ | https://ai.google.dev |
| Anthropic | ✅ | ✅ | ✅ | ✅ | https://www.anthropic.com/ |
| Mistral AI | ✅ | ✅ | ✅ | ✅ | https://mistral.ai/ |
| DeepSeek | ✅ | ❌ | ✅ | ✅ | https://www.deepseek.com/ |
The OpenAI endpoint URL can be changed so it is possible to access different backends with an OpenAI compatible API.
But be aware that not all features are supported by all backends.
=> Feedack regarding the compatibility of the different backends is welcome.
- *1: Tool choice settings other than ToolChoice::AUTO aren't supported by Ollama.
Requirements
- PHP >=8.2
Features
Backend independent generating:
Image processing:
Persistent message history:
See example:
The following store backends are supported:
- PSR-6 compatible file cache:
Support for structured responses with deserialization in an object instance:
More information about how to define the schema of the response data type can be found in the Schema Generator documentation.
Tool calling support
More information about how to define the schema of the tool callback function be found in the Schema Generator documentation.
MCP tool calling
Calling tools provided by an MCP server via the stdio and Streamable HTTP transport is supported.
See the MCP Client documentation for more information.
MCP server
The MCP server allows to expose service methods as MCP tools via Streamable HTTP transport. It can be used to create a custom MCP server that can be called by LLMs or other clients.
See the MCP Server documentation for more information.
Usage
Configure LLM backend instances
To use a specific backend as a service, it has to be registered in the bundle config:
In this example, the following services will be registered:
- ai_bundle.llm.open_ai
- ai_bundle.llm.open_ai.o3mini
- ai_bundle.llm.google_ai
- ai_bundle.llm.mistral_ai
- ai_bundle.llm.anthropic
- ai_bundle.llm.ollama
- ai_bundle.llm.deep_seek
When configuring the "default" instance of a llm, in addition to the ID, the class itself (e.g. AiBundle\LLM\OpenAi\OpenAi) will be registered as a service.
Execute standalone examples
This bundle provides standalone examples of the features provided. They can be executed by a central console command similar to the Symfony console:
You can get a list of available examples by executing:
The llm backend to use can be set via the option. The following values are supported:
- ollama (default)
- open_ai
- google_ai
- anthropic
- mistral_ai
- deep_seek
Before using the examples, you have to set the api key for the corresponding backend as an environment variable:
All versions of ai-bundle with dependencies
symfony/serializer Version ^7.0
symfony/property-info Version ^7.0
symfony/http-client Version ^7.0
phpdocumentor/reflection-docblock Version ^5.2
symfony/property-access Version ^7.0
symfony/uid Version ^7.0
symfony/process Version ^7.2