Search by

adachsoft / ai-image-proxy

Arkadiusz Adach

A Composer-discovered proxy for delegating image generation to configured provider plugins.

Package info

gitlab.com/a.adach/ai-image-proxy

Issues

pkg:composer/adachsoft/ai-image-proxy

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-11-07 09:07 UTC

This package is not auto-updated.

Last update: 2026-11-08 09:58:38 UTC


README

adachsoft/ai-image-proxy provides an ImageGeneratorInterface implementation that delegates image generation to installed provider plugins. It discovers provider packages through Composer metadata, configures only providers for which parameters are available, and allows providers to be disabled without uninstalling them.

Installation

Install the proxy and the provider packages you want to use:

composer require adachsoft/ai-image-proxy adachsoft/ai-image-xai adachsoft/ai-image-openai

A provider package must implement ImageGeneratorPluginInterface and declare its plugin in its composer.json:

{
    "extra": {
        "adachsoft/ai-image-contract": {
            "plugins": {
                "xai": "AdachSoft\\AiImageXai\\XaiImagePlugin"
            }
        }
    }
}

Plugin identifiers must follow ^[a-z0-9]+(?:[._-][a-z0-9]+)*$, be no longer than 64 characters, and be unique across the Composer installation. A provider plugin must have no required constructor arguments. Provider packages should document the parameter names they require.

Usage

use AdachSoft\AiImageContract\Collections\ImageInputVoCollection;
use AdachSoft\AiImageContract\Models\GenerationRequestDto;
use AdachSoft\AiImageContract\ValueObjects\PromptVo;
use AdachSoft\AiImageProxy\ImageGeneratorProxyFactory;
use AdachSoft\AiImageProxy\Parameters\InMemoryPluginParametersProvider;

$generator = (new ImageGeneratorProxyFactory())->create(
    new InMemoryPluginParametersProvider([
        'xai' => ['api_key' => $xaiApiKey],
        'openai' => ['api_key' => $openAiApiKey],
    ]),
    defaultPluginId: 'xai',
    disabledPluginIds: ['minimax'],
);

$defaultResponse = $generator->generate(new GenerationRequestDto(
    new PromptVo('A mountain landscape at sunrise'),
    new ImageInputVoCollection([]),
));

$openAiResponse = $generator->generate(new GenerationRequestDto(
    new PromptVo('A quiet forest in autumn'),
    new ImageInputVoCollection([]),
    options: ['plugin_id' => 'openai'],
));

The plugin_id option selects a provider for one request. The proxy removes this option before forwarding the request to the provider; all other request data and options are preserved.

Configuration behavior

  • A discovered provider without a parameter set is not activated.
  • A disabled provider is excluded from discovery, even if its package is installed.
  • The default provider must be installed, enabled, and configured when the proxy is created.
  • A provider's create() method is called during proxy creation. Provider configuration failures are therefore reported immediately.
  • The in-memory provider validates plugin identifiers and parameter names. Error messages never include parameter values.
  • Applications can implement PluginParametersProviderInterface to load parameters from another source, such as an environment, secret vault, or configuration service.

Exceptions

  • InvalidPluginParametersConfigurationException indicates an invalid application-supplied parameter map.
  • PluginNotAvailableException indicates that the default or requested provider is unavailable.
  • InvalidInputException from adachsoft/ai-image-contract indicates an invalid plugin_id request option.
  • Provider and discovery exceptions are propagated without being wrapped.