PHPackages                             sbh/ai-integration-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. sbh/ai-integration-bundle

ActiveLibrary[API Development](/categories/api)

sbh/ai-integration-bundle
=========================

A Symfony bundle to integrate AI models (ChatGPT, DeepSeek, Gemini...) with a unified interface.

00PHP

Since Jul 17Pushed 10mo agoCompare

[ Source](https://github.com/saidbh/AI-Symfony-Bundle)[ Packagist](https://packagist.org/packages/sbh/ai-integration-bundle)[ RSS](/packages/sbh-ai-integration-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Symfony AI Integration Bundle
=============================

[](#symfony-ai-integration-bundle)

[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/04744bae0a61d2ffe29c26f07a9612eae20445fc6feaeb77b3af1f0e9be6447c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d3838393242462e737667)](https://php.net/)

A powerful Symfony bundle that provides unified access to multiple AI providers (ChatGPT, Gemini, DeepSeek) with a simple, consistent interface.

✨ Features
----------

[](#-features)

- **Multi-provider support**: Switch between ChatGPT, Gemini, DeepSeek and more
- **Simple configuration**: YAML-based setup with environment variables
- **Extensible architecture**: Easily add new AI providers
- **Smart defaults**: Pre-configured with recommended models for each provider
- **Production-ready**: Built on Symfony's HttpClient for reliability
- **Caching support**: Optional caching of API responses

📦 Installation
--------------

[](#-installation)

### Requirements

[](#requirements)

- PHP 8.1 or higher
- Symfony 5.4+ or 6.0+

### 1. Install with Composer

[](#1-install-with-composer)

```
composer require sbh/ai-integration-bundle
```

### ⚙️ Configuration

[](#️-configuration)

### config/packages/ai\_integration.yaml

[](#configpackagesai_integrationyaml)

```
ai_integration:
    default_provider: chatgpt
    providers:
        chatgpt:
            api_key: '%env(CHATGPT_API_KEY)%'
            model: 'gpt-4o'
        gemini:
            api_key: '%env(GEMINI_API_KEY)%'
            model: 'gemini-1.5-pro'
        deepseek:
            api_key: '%env(DEEPSEEK_API_KEY)%'
            model: 'deepseek-chat'
```

Add to your API keys in .env
----------------------------

[](#add-to-your-api-keys-in-env)

```
CHATGPT_API_KEY=sk-xxxx
GEMINI_API_KEY=xxxx
DEEPSEEK_API_KEY=xxxx
```

### 🛠 Usage

[](#-usage)

Inject the AIClientFactory into your service or controller.

```
use Sbh\AiIntegrationBundle\Service\AIClientFactory;

public function __construct(private AIClientFactory $factory) {}

public function askAI(): void
{
    $client = $this->factory->getClient('gemini'); // or chatgpt, deepseek...
    $answer = $client->chat('What is Symfony?');
    dump($answer);
}
```

Or via a route:

```
#[Route('/ask/{provider}', name: 'ask_ai')]
public function ask(AIClientFactory $factory, string $provider = 'chatgpt'): JsonResponse
{
    $client = $factory->getClient($provider);
    $answer = $client->chat('Explain Symfony Bundles');
    return $this->json(['provider' => $provider, 'answer' => $answer]);
}
```

### ➕ Adding a New AI Provider

[](#-adding-a-new-ai-provider)

- Create a new Client class in src/Service implementing AIClientInterface.

```
namespace Sbh\AiIntegrationBundle\Service;

use Symfony\Contracts\HttpClient\HttpClientInterface;

class ClaudeClient implements AIClientInterface
{
    public function __construct(
        private string $apiKey,
        private ?string $model,
        private HttpClientInterface $httpClient
    ) {}

    public function chat(string $prompt, array $options = []): string
    {
        // Call the Claude API here
    }
}
```

- Add its configuration in ai\_integration.yaml:

```
providers:
    claude:
        api_key: '%env(CLAUDE_API_KEY)%'
        model: 'claude-3-opus'
```

```
 Update the AIClientFactory to add a case 'claude' in the match() statement.
```

### 📜 Requirements

[](#-requirements)

- PHP &gt;=8.1
- Symfony ^6.0 || ^7.0
- symfony/http-client

### 🗺 Roadmap

[](#-roadmap)

- ✅ Add support for service tags &amp; auto-discovery (no factory changes for new tools).
- ✅ Streaming support for long responses.
- ✅ Embeddings &amp; vector search integration (pgvector, Pinecone).

### 👤 Author

[](#-author)

- Said Ben Hmed
- MIT License.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/db0f3f75e5eb87225c911ab73074f9a3c074e33baf252fe9ff8460904614fb80?d=identicon)[saidbh](/maintainers/saidbh)

---

Top Contributors

[![saidbh](https://avatars.githubusercontent.com/u/54380634?v=4)](https://github.com/saidbh "saidbh (1 commits)")

### Embed Badge

![Health badge](/badges/sbh-ai-integration-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/sbh-ai-integration-bundle/health.svg)](https://phpackages.com/packages/sbh-ai-integration-bundle)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
