adachsoft / ai-image-minimax
MiniMax image generation adapter and plugin for the ai-image-contract package.
Requires
- adachsoft/ai-image-contract: ^0.3
- adachsoft/collection: ^3.0
- guzzlehttp/guzzle: ^7.10
Requires (Dev)
- adachsoft/php-code-style: ^0.4
- friendsofphp/php-cs-fixer: ^3.94
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.0
- rector/rector: ^2.3
- vlucas/phpdotenv: ^5.6
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-11-07 11:45:34 UTC
README
MiniMax adapter for adachsoft/ai-image-contract.
Installation
composer require adachsoft/ai-image-minimax
Plugin
This package provides the minimax image generator plugin for libraries that support adachsoft/ai-image-contract plugin auto-discovery. Such libraries can detect the plugin automatically after Composer installs this package; no provider-specific registration is required.
Parameters:
api_key(required): MiniMax API key.model(optional): MiniMax model name. When omitted, the default configured byMiniMaxImageGeneratorFactoryis used.
Example:
use AdachSoft\AiImageContract\Plugins\PluginParametersDto;
use AdachSoft\AiImageMiniMax\Plugin\MiniMaxImagePlugin;
$plugin = new MiniMaxImagePlugin();
$generator = $plugin->create(new PluginParametersDto([
'api_key' => 'your-api-key',
]));
Usage
use AdachSoft\AiImageContract\Collections\ImageInputVoCollection;
use AdachSoft\AiImageContract\Models\GenerationRequestDto;
use AdachSoft\AiImageContract\ValueObjects\ImageSizeVo;
use AdachSoft\AiImageContract\ValueObjects\PromptVo;
use AdachSoft\AiImageMiniMax\Factory\MiniMaxImageGeneratorFactory;
$generator = MiniMaxImageGeneratorFactory::create('your-api-key');
$response = $generator->generate(new GenerationRequestDto(
prompt: new PromptVo('A futuristic city at sunset, cyberpunk style'),
imageInputs: new ImageInputVoCollection([]),
size: new ImageSizeVo(1024, 1024),
options: [
'model' => 'image-01',
'response_format' => 'url',
'n' => 1,
'prompt_optimizer' => true,
],
));
foreach ($response->images as $image) {
if ($image->url !== null) {
echo $image->url . PHP_EOL;
}
}
Notes
This adapter supports text-to-image requests using the MiniMax image generation endpoint.
Current adapter behavior:
imageInputsare rejected as unsupported by this provider adapter.- The request
sizeis converted into the MiniMaxaspect_ratiopayload field. - The adapter currently expects MiniMax to return image URLs.
Contract Compatibility
This package is compatible with adachsoft/ai-image-contract ^0.3.
The updated contract introduces provider-level exception semantics such as retryable failures and content moderation rejections. This adapter maps MiniMax transport and HTTP failures to the contract exceptions exposed by the library.
Exceptions
The adapter may throw exceptions from adachsoft/ai-image-contract, including:
InvalidInputExceptionwhen unsupported request features are used.RetryableExceptionfor temporary transport failures, rate limits, and 5xx responses.ContentModerationExceptionfor moderation or safety-filter style rejections.GenerationFailedExceptionfor non-retryable provider failures or invalid generation responses.