yu-dev/module-ai-llm

Multi-provider LLM client for Magento 2: OpenAI, Anthropic, Gemini, Grok, DeepSeek, Gonka and any OpenAI-compatible API, with priority failover and cost tracking

Maintainers

Package info

github.com/yuriyakishin/magento2-ai-llm

Type:magento2-module

pkg:composer/yu-dev/module-ai-llm

Transparency log

Statistics

Installs: 11

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.2 2026-07-28 18:49 UTC

This package is auto-updated.

Last update: 2026-07-28 18:50:28 UTC


README

The module connects your store to several large language model (LLM) providers at once — OpenAI, Anthropic Claude, Google Gemini, xAI Grok, DeepSeek, Gonka, and any OpenAI-compatible API — through a single interface, with automatic failover to a backup provider and cost tracking for every call. Yu_AiLlm doesn't do anything visible on the storefront by itself — it's the infrastructure layer other AI modules are built on: Yu_AiChat (the customer-facing chat assistant) and Yu_AiCatalogSearch (AI-powered catalog search).

Why it exists

Any module that needs an LLM would otherwise have to, on its own:

  • deal with each vendor's HTTP format separately — OpenAI has one message format, Anthropic another, Gemini a third, each with its own tool-calling format;
  • write its own failover logic for when the primary provider is unavailable;
  • store and encrypt API keys;
  • calculate the cost of every request by hand.

Yu_AiLlm takes care of all of this and gives other modules one simple interface: send a request, get a response — without knowing or caring which specific provider answered.

Features

  • Multi-provider. Seven providers out of the box: OpenAI, Anthropic Claude, Google Gemini, xAI Grok, DeepSeek, Gonka, plus a universal adapter for any OpenAI-compatible API (e.g. a self-hosted Ollama server). Each provider is enabled and configured independently.
  • Automatic failover. Providers are tried in the priority order set in the admin panel; if a provider is unavailable (rate limit, invalid key, network failure, timeout), the request automatically falls through to the next one in the list. A provider that just failed is temporarily excluded from the chain, so time isn't wasted on a vendor already known to be down.
  • Cost tracking. Every LLM call is priced in dollars, based on the token count and the price per 1M tokens set in the admin panel for that provider. Yu_AiChat's analytics consume this data. If no price is set for a provider, the module simply omits the cost instead of erroring out.
  • Unified temperature scale. Response creativity is set on a common 0–1 scale regardless of each vendor's native range — no need to remember that one provider uses 0–1 and another uses 0–2.
  • Secure key storage. All API keys are stored encrypted using Magento's own configuration encryption mechanism.

Requirements

  • PHP >= 8.1
  • Magento 2.4.x
  • guzzlehttp/guzzle (installed automatically as a dependency)

Installation

composer require yu-dev/module-ai-llm
bin/magento module:enable Yu_AiLlm
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush

The module doesn't do anything on the storefront by itself — it only provides the LLM layer for other modules (Yu_AiChat, Yu_AiCatalogSearch), which are installed separately and list it as a dependency.

Configuration

Stores → Configuration → AI → LLM AI

LLM settings in the admin panel

  • Shared Settings — the default temperature and token limit, used when a consuming module doesn't set its own.
  • A separate settings group per provider (OpenAI, Anthropic Claude, Google Gemini, xAI Grok, DeepSeek, Gonka, Custom):
    • Enabled — turn this specific provider on.
    • Priority — the lower the number, the earlier this provider is tried in the failover chain.
    • API Key — stored encrypted.
    • Model — the specific model for this vendor (e.g. gpt-5-mini, claude-haiku-4-5).
    • Price: Input / Output (USD per 1M tokens) — used for the cost estimate; optional.

You can enable just one provider, or several at once — in which case automatic failover kicks in between them by priority.

Author

Yuriy Akishin:

License

MIT