Most AI wrappers ask: “Which provider? OK, now which model?”
Magic AI approaches the problem from the opposite direction. Instead of starting with a provider, the selected model determines which provider should be used.
Once resolved, the corresponding API credentials are loaded, and the request is passed to the SDK.
Magic AI powers five AI-driven features across Bagisto, from content generation to visual search.
Despite their different use cases, they all follow the same pattern: build a prompt, select a provider, and execute the request through Laravel AI.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Product & CMS Content Generation
agent()->prompt($contentPrompt);
// Product Image Generation
Image::of($imagePrompt);
// Search by Image
agent()
->withAttachment($uploadedImage)
->prompt($analysisPrompt);
// Review Translation
agent()->prompt("Translate to {$locale}: {$review}");
// Personalized Checkout Messages
agent()->prompt(buildCheckoutPrompt($order));
Before & After: AI-Generated Product Description
Without AI (manually written):
"Blue cotton t-shirt. Available in sizes S, M, L, XL. Machine washable."
With AI (generated via GPT-4.1 from admin panel):
"Elevate your everyday wardrobe with this classic blue cotton t-shirt.
Crafted from 100% breathable cotton, it offers all-day comfort with a relaxed fit that pairs effortlessly with jeans, chinos, or layered under a blazer.
Available in S through XL. Easy care — simply machine wash and tumble dry."
Same product, dramatically better copy — generated in seconds from the product editor.
Admin Configuration at a Glance
The admin panel exposes Magic AI settings in four sections, all defined declaratively in system.php:
The model dropdowns are populated dynamically by AiProvider::textModelOptions(), which aggregates all text-capable models across every registered provider.
Bagisto’s Magic AI demonstrates a clean pattern for building framework-native AI integrations:
Foundation — Laravel AI SDK provides agent() and Image::of()
Abstraction — Magic AI wraps them with eCommerce features and model-first provider resolution
Configuration — The admin panel gives non-developers a GUI to manage everything
The architecture is worth studying beyond eCommerce.
Laravel applications can use this enum registry and runtime injection pattern to support multiple AI providers without hard-coded credentials or vendor lock-in.