hryvinskyi / magento2-llm-anthropic
Anthropic and Anthropic-compatible endpoints for hryvinskyi/magento2-llm
Package info
github.com/hryvinskyi/magento2-llm-anthropic
Type:magento2-module
pkg:composer/hryvinskyi/magento2-llm-anthropic
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
Anthropic and Anthropic-compatible endpoints for hryvinskyi/magento2-llm.
The module speaks the Messages API (POST <endpoint>/messages, API version 2026-10-21) through the core's own
HTTP transport; it needs no vendor SDK. It writes free text, or JSON bound to a schema through the API's output
format.
- Anthropic: requests go to
https://api.anthropic.com/v1; enter the API key in the AI Models section of the store configuration. - Anthropic-compatible endpoint: a gateway that answers the Messages API at an address you choose; set the
endpoint, the model and the key the gateway accepts in the
x-api-keyheader.
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-anthropic 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:
- Anthropic (
anthropic):hryvinskyi_llm/provider_anthropic/credential,model,strong_model,manual_prices. - Anthropic-compatible endpoint (
anthropic_compatible):hryvinskyi_llm/provider_anthropic_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 anthropic_messages (writing) and its model listing, the providers anthropic and anthropic_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. It sends
GET <endpoint>/models?limit=100 with the key in the x-api-key header and the anthropic-version header, as a
writing does; it names no model, so a provider can be tested before a model is chosen. While a page answers
"has_more": true, the next page is asked for with after_id set to the page's last_id. Of each page only the
id of every model in data, has_more and last_id are read. Both providers are listed this way.
Settings
Each provider's group has the model (the hosted provider: empty for claude-haiku-5-5), 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 anthropic item of the provider registry. The
figures were read on 2026-11-14 (prices_as_of) from the provider's pricing page
(platform.claude.com/docs/en/about-claude/pricing) and models overview
(platform.claude.com/docs/en/about-claude/models/overview).
| Model | Context | Input, $ per 1M tokens | Output, $ per 1M tokens | Recommended |
|---|---|---|---|---|
claude-haiku-5-5 |
1,000,000 | 0.10 | 0.50 | yes |
claude-sonnet-5-5 (stronger) |
1,000,000 | 2 | 10 | |
claude-opus-5-5 |
1,000,000 | 4 | 20 |
claude-haiku-5-5 is priced for prompts up to 100K tokens; above that the provider charges $0.50 / $2.50, which
the catalogue does not model.
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 Anthropic-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/LlmAnthropic/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.