xmon-org/ai-content-bundle

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

Installs: 1

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.12.0 2025-12-29 18:27 UTC

This package is auto-updated.

Last update: 2025-12-29 18:28:21 UTC


README

Latest Version on Packagist PHP Version Symfony Total Downloads License

CI semantic-release Pollinations.ai

Symfony 7 bundle for AI-powered content generation. Access multiple LLMs and image models through a single, consistent API powered by Pollinations.ai.

Why Pollinations?

This bundle uses Pollinations.ai as its AI gateway, providing:

  • Unified API - One integration for Claude, GPT, Gemini, Mistral, DeepSeek, and more
  • No vendor lock-in - Switch models with a config change, no code modifications
  • Generous free tier - Start generating content without API keys
  • Transparent pricing - Pay only for what you use with premium models
  • Open ecosystem - Built on open-source principles

Features

Requirements

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

Optional Dependencies

For full functionality, consider these additional bundles:

Package Version Purpose
sonata-project/admin-bundle ^4.0 Admin panel with image regeneration UI
sonata-project/media-bundle ^4.0 Media storage for generated images

Quick Start

1. Installation

composer require xmon-org/ai-content-bundle

2. Configuration

The bundle works out of the box with zero configuration using free-tier models:

# config/packages/xmon_ai_content.yaml
xmon_ai_content: ~  # That's it! Uses free-tier defaults

Default models (no API key required):

  • Text: mistralnova-microgemini-fastopenai-fast
  • Image: fluxzimageturbo

For custom configuration:

xmon_ai_content:
    # Configure models per task type
    tasks:
        news_content:
            default_model: 'mistral'
            allowed_models: ['mistral', 'openai-fast', 'gemini-fast']
        image_prompt:
            default_model: 'openai-fast'
            allowed_models: ['openai-fast', 'mistral', 'nova-micro']
        image_generation:
            default_model: 'flux'
            allowed_models: ['flux', 'zimage', 'turbo']

    # Text generation (optional - these are the defaults)
    text:
        model: 'mistral'
        fallback_models: ['nova-micro', 'gemini-fast', 'openai-fast']

    # Image generation (optional - these are the defaults)
    image:
        model: 'flux'
        fallback_models: ['zimage', 'turbo']

Tip: Get a free API key at enter.pollinations.ai to unlock premium models like claude, gemini, and gptimage.

3. Generate Text

use Xmon\AiContentBundle\Enum\TaskType;
use Xmon\AiContentBundle\Service\AiTextService;

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

    public function summarize(string $content): string
    {
        // Uses the model configured for NEWS_CONTENT task
        $result = $this->aiTextService->generateForTask(
            TaskType::NEWS_CONTENT,
            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
    {
        // Uses the model configured for IMAGE_GENERATION task
        $result = $this->aiImageService->generateForTask(
            prompt: 'A serene Japanese dojo with morning light',
        );

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

5. Override Options Per-Request

// Use specific model without fallback
$result = $this->aiTextService->generate($system, $user, [
    'model' => 'claude',
    'use_fallback' => false,
    'timeout' => 120,
]);

// Use specific model with fallback to configured fallback_models
$result = $this->aiTextService->generate($system, $user, [
    'model' => 'claude',
    'use_fallback' => true,
]);

Documentation

Installation & Setup

Guides

Reference

Development

Available Models

Powered by Pollinations.ai - Unified access to Claude, GPT, Gemini, Mistral, Flux, and more.

Query current models and pricing directly from the API:

# Text models with Pollen pricing
curl https://gen.pollinations.ai/text/models

# Image models with Pollen pricing
curl https://gen.pollinations.ai/image/models

API Documentation: enter.pollinations.ai/api/docs

Text Models

Prices updated: 2025-12-27 | These are approximate estimates for reference only. For current pricing, query the endpoints above.

Model Tier ~Resp/$ Description
openai-fast anonymous ~2,270 GPT-5 Nano - Ultra fast
openai anonymous ~1,660 GPT-5 Mini - Balanced
gemini-fast seed ~2,500 Gemini 2.5 Flash - Fast & cheap
gemini seed ~330 Gemini 3 Flash - Pro-grade
gemini-search seed ~330 Gemini 3 Flash with Search
deepseek seed ~595 DeepSeek V3.2 - Reasoning
mistral seed ~2,850 Mistral Small 3.2 - Efficient
claude flower ~65 Claude Sonnet 4.5 - Premium

Image Models

Prices updated: 2025-12-27 | These are approximate estimates for reference only. For current pricing, query the endpoints above.

Model Tier ~Img/$ Description
flux anonymous ~8,333 Fast & high quality
turbo anonymous ~3,333 Ultra-fast previews
nanobanana seed ~33,333 Gemini-based, reference images
gptimage flower ~125,000 OpenAI, best prompt understanding
seedream flower ~33 ByteDance ARK, complex scenes

Access Tiers

Tier Requirements Access
anonymous None openai, openai-fast, flux, turbo
seed Free API key from enter.pollinations.ai + gemini*, deepseek, mistral, nanobanana
flower Pollen credits All models including claude, gptimage, seedream

Debug Command

bin/console xmon:ai:debug

Displays current configuration including:

  • Provider Status - Pollinations API connectivity for text and image generation
  • Task Models - Default model, cost estimate, and allowed models per task type
  • Styles, Compositions, Palettes - Available image options
  • Presets - Pre-configured style combinations
  • Prompt Templates - Configured templates for AI prompts

Acknowledgments

This bundle is built on top of Pollinations.ai, an open-source platform that provides unified access to state-of-the-art AI models. Their commitment to open AI and developer-friendly APIs makes projects like this possible.

License

MIT