adachsoft / model-pricing-source-minimax
MiniMax image pricing source for ai-pricing-api
Package info
gitlab.com/a.adach/model-pricing-source-minimax
pkg:composer/adachsoft/model-pricing-source-minimax
Requires
- php: ^8.3
- adachsoft/model-pricing-contracts: ^0.4.1
- psr/http-client: ^1.0
- psr/http-factory: ^1.1
Requires (Dev)
- adachsoft/php-code-style: ^0.9.0
- friendsofphp/php-cs-fixer: ^3.95
- guzzlehttp/psr7: ^2.7
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13
- rector/rector: ^2.9
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
adachsoft/model-pricing-source-minimax provides MiniMax image-model price sheets for the model-pricing synchronization flow. It reads the official Markdown pricing page through PSR-18 and currently supports the Image Generation token table and legacy per-image prices.
Features
- Fetches MiniMax's official Markdown pricing page using PSR-18 and PSR-17 contracts.
- Parses Image Generation token pricing and legacy per-image pricing into validated price sheets.
- Follows a limited number of HTTPS redirects and reports skipped rows as warnings rather than guessing prices.
Installation
composer require adachsoft/model-pricing-source-minimax
Requirements
- PHP 8.3 or newer.
- A PSR-18 HTTP client and a PSR-17 request factory supplied by the application.
Usage with ai-pricing-api
Create the source with the application's PSR-18 HTTP client and a PSR-17 request factory, then register it with the PriceSyncService used by ai-pricing-api:
use AdachSoft\ModelPricingSourceMinimax\Http\MinimaxPricingPageFetcher;
use AdachSoft\ModelPricingSourceMinimax\MinimaxPriceSource;
$minimaxSource = new MinimaxPriceSource(
new MinimaxPricingPageFetcher($httpClient, $requestFactory),
);
// Register $minimaxSource with the PriceSyncService used by ai-pricing-api.
// The application's `model-pricing:sync` command synchronizes its price sheets.
The fetcher defaults to https://platform.minimax.io/docs/pricing/overview.md and follows up to three HTTPS redirects. A different page URL can be supplied as the third MinimaxPricingPageFetcher constructor argument.
After a fetch, MinimaxPriceSource::getLastWarnings() returns warnings for unparseable rows that were skipped. A missing Image Generation pricing table raises PriceSourceException instead of producing guessed prices.
Supported image prices
- Image Generation models are published with
input,input_image, andoutput_imageprices per one million tokens. - Legacy image models are published with an
imageprice per unit. - All supported prices use USD and the
standardservice-tier condition.