xmon-org/ai-content-bundle

Symfony bundle for AI content generation (text and images) with provider fallback

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:symfony-bundle

pkg:composer/xmon-org/ai-content-bundle

1.1.0 2025-12-22 00:24 UTC

This package is auto-updated.

Last update: 2025-12-22 16:19:44 UTC


README

Latest Version on Packagist PHP Version Symfony Total Downloads License

CI semantic-release

Symfony 7 bundle for AI content generation (text and images) with automatic fallback between providers.

Features

  • Text generation with Gemini, OpenRouter, Pollinations
  • Image generation with Pollinations (Flux model)
  • Automatic fallback between providers
  • Style presets for consistent image generation
  • Configurable prompt templates for text generation
  • Prompt variants with intelligent content-based selection
  • SonataMedia integration (optional)
  • Sonata Admin integration with image regeneration UI (optional)

Requirements

  • PHP >= 8.2
  • Symfony >= 7.0
  • symfony/http-client

Quick Start

1. Installation

composer require xmon-org/ai-content-bundle

2. Configuration

# config/packages/xmon_ai_content.yaml
xmon_ai_content:
    text:
        providers:
            pollinations:
                enabled: true
    image:
        providers:
            pollinations:
                enabled: true

3. Generate Text

use Xmon\AiContentBundle\Service\AiTextService;

class MyService
{
    public function __construct(
        private readonly AiTextService $aiTextService,
    ) {}

    public function summarize(string $content): string
    {
        $result = $this->aiTextService->generate(
            systemPrompt: 'You are a helpful assistant.',
            userMessage: "Summarize: {$content}",
        );

        return $result->getText();
    }
}

4. Generate Image

use Xmon\AiContentBundle\Service\AiImageService;

class MyService
{
    public function __construct(
        private readonly AiImageService $aiImageService,
    ) {}

    public function generateImage(): void
    {
        $result = $this->aiImageService->generate(
            prompt: 'A serene Japanese dojo with morning light',
        );

        file_put_contents('image.png', $result->getBytes());
    }
}

Documentation

Installation & Setup

Guides

Reference

Development

Available Providers

Text

Provider Requires API Key Notes
Gemini Yes Recommended, fast
OpenRouter Yes Multiple models
Pollinations Optional Always available, higher rate limits with key

Image

Provider Requires API Key Notes
Pollinations Optional Flux model

Debug Command

bin/console xmon:ai:debug

Shows configured providers, styles, presets, and prompt templates.

Roadmap

  • Phase 1: Base structure + Pollinations
  • Phase 2: SonataMedia integration
  • Phase 3: Text providers (Gemini, OpenRouter, Pollinations)
  • Phase 4: Styles/presets system (ImageOptionsService, PromptBuilder)
  • Phase 5: Configurable prompts (PromptTemplateService)
  • Phase 6: Admin regeneration UI (Form Types, Controller, Templates)
  • Phase 7: Aikido project migration
  • Phase 8: Packagist publication

License

MIT