PHPackages                             gtstudio/module-aiconnector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. gtstudio/module-aiconnector

ActiveMagento2-module

gtstudio/module-aiconnector
===========================

Core AI connector for Magento 2. Wraps neuron-core/neuron-ai to provide a unified, provider-agnostic AI interface for all Gtstudio modules.

1.0.3(1mo ago)08↓100%4BUSL-1.1PHPPHP &gt;=8.1

Since Mar 9Pushed 1mo agoCompare

[ Source](https://github.com/gabrielgts/module-aiconnector)[ Packagist](https://packagist.org/packages/gtstudio/module-aiconnector)[ RSS](/packages/gtstudio-module-aiconnector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (4)Used By (4)

Gtstudio\_AiConnector
=====================

[](#gtstudio_aiconnector)

Core AI provider abstraction for Magento 2. Every other Gtstudio AI module depends on this one to communicate with external AI providers.

Preview
-------

[](#preview)

[![AiConnector — provider configuration and on-demand generation](docs/images/aiconnector-preview.gif)](docs/images/aiconnector-preview.gif)

AI Studio Ecosystem
-------------------

[](#ai-studio-ecosystem)

`Gtstudio_AiConnector` is the foundation of the **AI Studio** suite — a collection of modules that bring AI capabilities to the Magento admin without coupling your store to a single provider. Each module builds on top of this connector and can be installed independently.

ModuleRepositoryDescription**Gtstudio\_AiConnector***(this module)*Core AI provider abstraction**Gtstudio\_AiAgents**[module-ai-agents](https://github.com/gabrielgts/module-ai-agents)Agent &amp; tool orchestration, cron scheduling, execution log**Gtstudio\_AiWidgets**[module-ai-widgets](https://github.com/gabrielgts/module-ai-widgets)Floating admin chat widget + PageBuilder AI generator**Gtstudio\_AiDataQuery**[module-ai-data-query](https://github.com/gabrielgts/module-ai-data-query)Natural-language store analytics (privacy-first)**Gtstudio\_AiKnowledgeBase**[module-ai-knowledge-base](https://github.com/gabrielgts/module-ai-knowledge-base)Document upload &amp; RAG retrieval for agents**Gtstudio\_AiDashboard**[module-ai-dashboard](https://github.com/gabrielgts/module-ai-dashboard)AI-powered KPI dashboard with ML insights### Gtstudio\_AiAgents — Agent &amp; Tool Orchestration

[](#gtstudio_aiagents--agent--tool-orchestration)

Define AI agents directly in the admin UI and attach reusable tools they can call. Each agent has a structured system prompt (background, reasoning steps, output rules) and a list of tools with property schemas that the LLM uses to decide what to execute.

**Key advantages**

- No code required to create a new agent — everything is configured in the admin
- **Run Now** — execute any agent on-demand from its edit page and see the result immediately
- **Cron scheduling** — attach a cron expression to any agent so it runs automatically (e.g. generate a daily sales report every morning)
- **Execution log** — every run is recorded with status, token counts, input, output, and trigger source; old entries are pruned automatically
- **Extensible tool registry** — implement `ToolExecutorInterface` and register it via `di.xml` to give agents access to any custom PHP logic

### Gtstudio\_AiWidgets — Admin UI Widgets

[](#gtstudio_aiwidgets--admin-ui-widgets)

Surfaces AI capabilities directly inside the Magento admin without requiring users to leave the page they are working on.

**Key advantages**

- **Floating chat assistant** — a persistent panel available on every admin page, backed by any agent you define (default: `admin_assistant`)
- **PageBuilder AI generator** — an *AI Generate* button inside PageBuilder HTML blocks lets content editors describe what they want and have the AI write clean semantic HTML into the block
- Real-time token and cost estimation on every message
- Fully overridable via standard Magento layout XML and DI preferences — no core patches

### Gtstudio\_AiDataQuery — Natural-Language Store Analytics

[](#gtstudio_aidataquery--natural-language-store-analytics)

Lets admin users ask plain-English questions about their store data and receive structured results — without ever sending store data to the LLM.

**Key advantages**

- **Privacy-first two-phase architecture**: the LLM only sees the user's question and returns a structured intent (which tool to call, which parameters); all actual database queries run locally on your server
- Built-in analytics tools cover the most common reporting needs: order analytics, customer lifetime value, product performance, and a general entity query
- Fully extensible: register custom query tools and entity handlers via `di.xml`; override the planner prompt to teach the LLM about your custom tools

### Gtstudio\_AiKnowledgeBase — Document Context for Agents

[](#gtstudio_aiknowledgebase--document-context-for-agents)

Upload PDF or plain-text documents in the admin and associate them with agents. At query time, relevant excerpts are retrieved and prepended to the agent's context — enabling retrieval-augmented generation (RAG) without a vector database.

**Key advantages**

- No external vector store required — excerpts are stored and matched in the Magento database
- Only the most relevant excerpts are sent to the LLM, keeping token usage low
- Extensible extraction pipeline: add support for new file formats (DOCX, CSV, etc.) by implementing `ExtractorInterface` and registering via `di.xml`
- Swappable retrieval strategy: replace the default keyword matcher with OpenSearch k-NN or any other similarity search by implementing `RetrievalServiceInterface`

---

What It Does
------------

[](#what-it-does)

- Wraps [neuron-core/neuron-ai](https://github.com/inspector-apm/neuron-ai) to expose a single, consistent interface regardless of which AI provider is configured
- Provides a REST endpoint for on-demand AI text generation
- Manages all provider configuration (API key, model, temperature, max tokens) in one place under *Stores → Configuration → AI Connector*
- Ships a `TokenCostService` for tracking and estimating token costs across providers

Supported Providers
-------------------

[](#supported-providers)

KeyProvider`anthropic`Anthropic Claude`openai`OpenAI Chat Completions`openai-responses`OpenAI Responses API`openailike`Any OpenAI-compatible endpoint (custom domain)`ollama`Ollama (local models)`gemini`Google Gemini`mistral`Mistral AI`huggingface`HuggingFace Inference`deepseek`DeepSeek`grok`xAI GrokRequirements
------------

[](#requirements)

- Magento 2.4.4+
- PHP 8.1+
- `neuron-core/neuron-ai ^2`

Installation
------------

[](#installation)

```
composer require gtstudio/module-aiconnector
php bin/magento module:enable Gtstudio_AiConnector
php bin/magento setup:upgrade
```

Configuration
-------------

[](#configuration)

*Stores → Configuration → Gtstudio → AI Connector → General*

FieldDescriptionEnabledMaster on/off switchProviderProvider key from the table aboveDomainBase URL — required for `openailike` and `ollama`API KeyProvider API keyModelModel identifier (e.g. `claude-sonnet-4-6`, `gpt-4o`)Max TokensMaximum tokens in the AI responseTemperatureSampling temperature (0.0–1.0)RulesDefault system-prompt text prepended to every requestREST API
--------

[](#rest-api)

### Generate text

[](#generate-text)

```
POST /rest/V1/aiconnector/generate

```

**Request body**

```
{
  "request": {
    "prompt": "Summarise the top 3 benefits of Magento 2.",
    "rules": "Reply in bullet points.",
    "model": "claude-sonnet-4-6",
    "temperature": 0.7,
    "max_tokens": 512
  }
}
```

All fields except `prompt` are optional and fall back to the admin-configured values.

Extensibility
-------------

[](#extensibility)

### Adding a new provider

[](#adding-a-new-provider)

Create a plugin on `NeuronClient::resolveProvider()`:

```

```

```
class CustomProviderPlugin
{
    public function aroundResolveProvider(NeuronClient $subject, callable $proceed, $request = null)
    {
        if (strtolower($subject->getConfig()->getProvider()) === 'myprovider') {
            return new MyCustomProvider(...);
        }
        return $proceed($request);
    }
}
```

### Extending the token pricing table

[](#extending-the-token-pricing-table)

Magento merges `xsi:type="array"` arguments automatically — add or override prices in your module's `di.xml`:

```

            0.002

            0.004

```

### Using NeuronClient in another module

[](#using-neuronclient-in-another-module)

Inject `NeuronClient` and call `resolveProvider()` to get a ready-to-use `AIProviderInterface`:

```
use Gtstudio\AiConnector\Model\Client\NeuronClient;
use NeuronAI\Chat\Messages\UserMessage;

class MyService
{
    public function __construct(private readonly NeuronClient $client) {}

    public function ask(string $question): string
    {
        $provider = $this->client->resolveProvider();
        $response = $provider->chat(new UserMessage($question));
        return (string) $response->getContent();
    }
}
```

### Injecting a custom system prompt at runtime

[](#injecting-a-custom-system-prompt-at-runtime)

Set `rules` on the `AiRequestInterface` object — it overrides the admin-configured default for that request only.

###  Health Score

41

—

FairBetter than 88% of packages

Maintenance98

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Total

3

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab1f0030c21bebf4e87187df361e770ffaa2c0d3cdcd0cd45c77a79db5836156?d=identicon)[gtstudio](/maintainers/gtstudio)

### Embed Badge

![Health badge](/badges/gtstudio-module-aiconnector/health.svg)

```
[![Health](https://phpackages.com/badges/gtstudio-module-aiconnector/health.svg)](https://phpackages.com/packages/gtstudio-module-aiconnector)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M787](/packages/league-flysystem-aws-s3-v3)[fastly/magento2

Fastly CDN Module for Magento 2.4.x

1564.2M1](/packages/fastly-magento2)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[palpalani/laravel-sqs-queue-json-reader

Custom SQS queue reader for Laravel

26109.8k](/packages/palpalani-laravel-sqs-queue-json-reader)[mage-os/module-automatic-translation

Automatic AI content translation for Mage-OS.

277.1k](/packages/mage-os-module-automatic-translation)[graycore/magento2-graphql-introspection-cache

1015.2k](/packages/graycore-magento2-graphql-introspection-cache)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
