Search by

adachsoft / ai-image-openai

Arkadiusz Adach

Package info

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

Issues

pkg:composer/adachsoft/ai-image-openai

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

v0.3.0 2026-11-07 08:57 UTC

This package is not auto-updated.

Last update: 2026-11-07 08:03:00 UTC


README

OpenAI adapter for the adachsoft/ai-image-contract package.

Overview

This package provides an ImageGeneratorInterface implementation backed by the OpenAI Images API. It maps the generic AI image contract to OpenAI image generation requests and returns contract-compatible responses.

Installation

composer require adachsoft/ai-image-openai

Plugin

This package declares the openai plugin for automatic discovery by intermediary libraries that inspect Composer plugin declarations.

  • Plugin ID: openai
  • Plugin class: AdachSoft\AiImageOpenai\OpenAiImagePlugin
  • Required parameter: api_key
use AdachSoft\AiImageContract\Plugins\PluginParametersDto;
use AdachSoft\AiImageOpenai\OpenAiImagePlugin;

$generator = (new OpenAiImagePlugin())->create(
    new PluginParametersDto(['api_key' => 'your-openai-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\AiImageOpenai\OpenAiImageGenerator;
use GuzzleHttp\Client;

$generator = new OpenAiImageGenerator(
    new Client(),
    'your-openai-api-key',
);

$response = $generator->generate(new GenerationRequestDto(
    prompt: new PromptVo('A simple red square on a white background'),
    imageInputs: new ImageInputVoCollection([]),
    size: new ImageSizeVo(1024, 1024),
    options: [
        'model' => 'gpt-image-2.5-sunburst',
        'quality' => 'high',
    ],
));

Supported contract features

  • Text-to-image generation through ImageGeneratorInterface
  • Contract-compatible GenerationRequestDto input
  • Contract-compatible ImageResponseDto output with GeneratedImageCollection
  • OpenAI options passed through GenerationRequestDto::options:
    • model (defaults to gpt-image-2.5-sunburst)
    • quality (low, medium, high, xhigh, max, or auto; legacy standard and hd values map to medium and high)

Current limitations

The OpenAI Images API integration used by this adapter does not support all contract capabilities.

  • imageInputs are not supported by this adapter and result in FeatureNotSupportedException
  • The adapter currently requests a single output image
  • GPT Image responses are base64-encoded and exposed as GeneratedImageDto::b64Json; URL responses are also preserved when returned by the API

Image-to-image generation and typed image inputs are recognized by the contract, but are intentionally rejected by this adapter.

Testing

vendor/bin/phpunit
vendor/bin/phpstan analyse src
vendor/bin/phpstan analyse tests
vendor/bin/rector process src --dry-run
vendor/bin/rector process tests --dry-run