Bagisto Hosting

How Bagisto Builds Magic AI on Top of Laravel AI SDK

Updated 29 June 2026

Bagisto introduces Magic AI, a built-in AI layer that enables features like product description generation, image creation, and visual search.

It also powers review translation and personalized checkout messages, bringing AI directly into the eCommerce workflow.

The Need for Magic AI

Laravel AI SDK abstracts communication with multiple AI providers through a unified API.

Magic AI adds provider configuration and prompt orchestration tailored for Bagisto.

It seamlessly integrates AI-powered features across products, categories, CMS pages, and SEO.

Key Architectural Decisions

1. Every Model Is a Typed Enum

Instead of storing model names in config arrays, Bagisto represents every AI model as a PHP enum case implementing AiModelContract:

Each provider has its own enum containing all its models. Here’s how OpenAI implements it:

 

2. A Single-Array Provider Registry

The AiProvider class maps every provider to its model enum in one array.

AiProvider auto-generates everything the admin UI needs: provider dropdowns, model selectors (prefixed as “OpenAI: GPT-4.1”), and filtered lists.

 

3. Model-First Provider Resolution

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.

 

Five eCommerce Features, One Pattern

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.

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. 

 

Storefront Integration

The Shop package is integrated with simple feature checks. Both follow the same pattern: check the feature toggle before calling Magic AI.

 

How to Add a New AI Provider

Adding a new provider requires two changes:

Step 1: Create a Model Enum

Create a new PHP enum inside Enums/Models/ implementing AiModelContract:

Step 2: Register in AiProvider

Add one line to the $providers array: The admin UI auto-populates, the API key config field appears, and credential injection works automatically.

No controller changes, no route changes, no migration.

 

Behind the Scenes: Magic AI Architecture

Magic-AI

Magic AI

 

Conclusion

Bagisto’s Magic AI demonstrates a clean pattern for building framework-native AI integrations:

  1. Foundation – Laravel AI SDK provides agent() and Image::of()

  2. Abstraction – Magic AI wraps them with eCommerce features and model-first provider resolution

  3. Configuration – The admin panel gives non-developers a GUI to manage everything

The architecture is worth studying beyond eCommerce.

Laravel applications can support multiple AI providers using enum registries and runtime injection, avoiding hard-coded credentials and vendor lock-in.

You can also explore our Bagisto Extensions. If you are planning to build with Laravel, consider hiring laravel developers. 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project




    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home