Search by

hryvinskyi / magento2-llm-gemini

hryvinskyi

Google Gemini models for hryvinskyi/magento2-llm

Package info

github.com/hryvinskyi/magento2-llm-gemini

Type:magento2-module

pkg:composer/hryvinskyi/magento2-llm-gemini

Statistics

Installs: 0

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-11-30 18:52 UTC

This package is auto-updated.

Last update: 2026-11-30 20:08:07 UTC


README

Google Gemini models for hryvinskyi/magento2-llm.

The module speaks the Gemini API (POST <endpoint>/v1beta/models/<model>:generateContent) through the core's own HTTP transport; it needs no vendor SDK. Requests go to https://generativelanguage.googleapis.com unless another endpoint is set; the key goes into the x-goog-api-key header, never into the address.

Requirements and installation

PHP 8.2 or higher, hryvinskyi/magento2-llm and the platform's Config module (what composer.json and etc/module.xml declare).

composer require hryvinskyi/magento2-llm-gemini
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:flush

Then connect the provider in System › AI Models › Setup, or in Stores › Configuration › Hryvinskyi Extensions › AI Models. A writing provider also answers typed decisions: its model is asked for the probabilities as JSON, and the result says it is an estimate.

Settings paths

Every field at the default scope:

  • Google Gemini (gemini): hryvinskyi_llm/provider_gemini/credential, endpoint (empty: the default one), model, strong_model, manual_prices.

The key is stored encrypted, bound to the endpoint saved with it, and never shown again: the setup shows only whether one is set.

What it adds to the AI module

All in the global etc/di.xml: the protocol gemini (writing) and its model listing, the provider gemini with its catalogue, and the credential path marked sensitive.

Connection test: the model list

The connection test lists the models the key may use and spends no tokens. It sends GET <endpoint>/v1beta/models?pageSize=100 with the key in the x-goog-api-key header, as a writing does; it names no model, so the provider can be tested before a model is chosen. While a page names a nextPageToken, the next page is asked for with pageToken set to it. Of each model in models only its name and supportedGenerationMethods are read: a model is kept when it supports generateContent, and its id is the name without models/. An id that is not one path segment (one that still holds /, or holds :) is left out.

Settings

The provider's group has the model (empty for gemini-4-hydrogen), the Stronger model that a feature set to the stronger tier asks for (empty: the default model), and Prices you enter.

Catalogue and prices

The catalogue is in etc/di.xml, inside the gemini item of the provider registry. The figures were read on 2026-11-14 (prices_as_of) from the provider's pricing page (aistudio.google.com/docs/pricing) and models page (aistudio.google.com/docs/models). Where the provider has announced a higher price from a later date, the catalogue holds the announced price.

Model Context Input, $ per 1M tokens Output, $ per 1M tokens Recommended
gemini-4-hydrogen (default) 1,000,000 1.50 7.50 yes
gemini-4-carbon (stronger) 1,000,000 4 20
gemini-4-argon 1,000,000 4 20

gemini-4-carbon and gemini-4-argon carry the price the provider announced from 1 December 2026.

Prices are US dollars per million tokens, standard input and output (no batch or cache price), as "0.1"-style decimal strings. A model whose price depends on the prompt's length is declared with the price of prompts below the provider's long-context threshold; a longer prompt is not priced by its own tier. The features of this store never send one.

To correct a price, read the provider's price page, change price_in / price_out of the model in etc/di.xml, and set prices_as_of to the day you read it. A dated snapshot id the provider documents as the same model goes into the model's aliases; none is declared today. A model the catalogue does not name shows as "Price not known"; an admin may price it in the provider's Prices you enter field, which refuses a row for a model the catalogue already prices.

Translations

The admin wording ships in en_US and 25 more locales: the official languages of the European Union, Norwegian Bokmål and Ukrainian. The translations are machine-made; have them read by a native speaker before a store relies on them.

Tests

  • Unit: vendor/bin/phpunit -c app/code/Hryvinskyi/LlmGemini/phpunit.xml.dist.
  • Integration: the platform's harness in dev/tests/integration; the tests record what the transport would send and never reach the provider.