hryvinskyi / magento2-llm-openai
OpenAI and OpenAI-compatible endpoints for hryvinskyi/magento2-llm
Package info
github.com/hryvinskyi/magento2-llm-openai
Type:magento2-module
pkg:composer/hryvinskyi/magento2-llm-openai
Requires
- php: ^8.2
- hryvinskyi/magento2-llm: ^1.0
- magento/framework: *
- magento/module-config: *
- psr/log: ^1.1 || ^2.0 || ^3.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
OpenAI and OpenAI-compatible endpoints for hryvinskyi/magento2-llm.
The module speaks chat completions (POST <endpoint>/chat/completions) through the core's own HTTP transport; it
needs no vendor SDK.
- OpenAI: requests go to
https://api.openai.com/v1; enter the API key in the AI Models section of the store configuration. - OpenAI-compatible endpoint: a gateway or a model served on your own machine that answers chat completions at an address you choose; set the endpoint, the model and the key.
Requirements and installation
PHP 8.2 or higher, hryvinskyi/magento2-llm, psr/log and the platform's Config module (what composer.json and etc/module.xml declare).
composer require hryvinskyi/magento2-llm-openai 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:
- OpenAI (
openai):hryvinskyi_llm/provider_openai/credential,model,strong_model,manual_prices. - OpenAI-compatible endpoint (
openai_compatible):hryvinskyi_llm/provider_openai_compatible/endpoint,model,credential,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 openai_chat (writing) and its model listing, the providers openai and openai_compatible with the hosted provider's catalogue, and both credential paths marked sensitive.
Connection test: the model list
The connection test lists the models the key may use and spends no tokens: GET <endpoint>/models with the key
as a bearer token in the Authorization header, as a writing does. It names no model, so a provider can be
tested before a model is chosen. The list is read as one page: the API reference page of the list could not be
read on 2026-11-14, so no paging parameter is sent. Of the answer only the id of every model in data is
read, and only chat models are kept: the API says nothing about a model's kind, so an id holding embedding,
whisper, tts, dall-e, moderation, transcribe, image, audio, realtime or search is left out
(Hryvinskyi\LlmOpenAi\Model\ModelListing::NON_CHAT_MARKS). A compatible server that answers 404 has no list:
the test says so, and the model ID is entered by hand.
Settings
Each provider's group has the model (the hosted provider: empty for gpt-6-luna), 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 hosted provider's catalogue is in etc/di.xml, inside the openai item of the provider registry. The figures
were read on 2026-11-14 (prices_as_of) from the provider's pricing page (developers.openai.com/api/docs/pricing)
and model pages (developers.openai.com/api/docs/models).
| Model | Context | Input, $ per 1M tokens | Output, $ per 1M tokens | Recommended |
|---|---|---|---|---|
gpt-6-luna (default) |
1,050,000 | 0.10 | 0.50 | yes |
gpt-6-astra (stronger) |
1,050,000 | 10 | 50 | |
gpt-6.1-terra |
1,050,000 | 1 | 5 | |
gpt-6.1-sol |
1,050,000 | 2 | 10 |
The provider charges more for prompts above 272K tokens; the catalogue does not model that tier.
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.
Every model of the OpenAI-compatible endpoint is priced by hand.
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/LlmOpenAi/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.