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
Requires
- php: >=8.2
- psr/log: ^3.0
- symfony/framework-bundle: ^7.0
- symfony/http-client: ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.50
- phpstan/phpstan: ^1.10
- phpstan/phpstan-symfony: ^1.3
- phpunit/phpunit: ^10.0|^11.0
- symfony/phpunit-bridge: ^7.0
- twig/twig: ^3.0
Suggests
- sonata-project/admin-bundle: Required for admin UI features (^4.0)
- sonata-project/media-bundle: Required for image storage with SonataMedia (^4.0)
README
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
- Text generation with multiple models (Claude, Gemini, GPT, Mistral, DeepSeek)
- Image generation with multiple models (GPTImage, Flux, Seedream, Turbo)
- Image subject generator - Two-step anchor extraction for unique, differentiated images
- Task Types - Configure different models for different tasks (content, prompts, images)
- Cost tracking - See estimated costs per model (pricing reference)
- Style presets for consistent image generation
- Configurable prompt templates with intelligent variant selection
- Automatic fallback between models when one fails
- SonataMedia integration (optional)
- Sonata Admin integration with image regeneration UI (optional)
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:
mistral→nova-micro→gemini-fast→openai-fast - Image:
flux→zimage→turbo
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, andgptimage.
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
- Installation Guide - Full setup instructions
Guides
- Task Types - Configure models per task
- Text Generation - Generate text with AI
- Image Generation - Generate images with AI
- Image Subject Generator - Two-step anchor extraction
- Prompt Templates - Configurable prompts with variants
- Admin Integration - Sonata Admin integration
Reference
- Configuration - Full YAML reference
- Providers - Available AI models and costs
- Fallback System - How automatic fallback works
- Architecture - Bundle structure
Development
- Development Guide - Local setup and commands
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.
- Website: pollinations.ai
- API Docs: enter.pollinations.ai/api/docs
- GitHub: github.com/pollinations
License
MIT