adachsoft/ai-image-openai

Maintainers

Package info

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

Issues

pkg:composer/adachsoft/ai-image-openai

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

v0.2.0 2026-03-19 06:16 UTC

This package is not auto-updated.

Last update: 2026-03-20 03:46:44 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

Usage

use AdachSoft\AiImageContract\Collections\ImageInputCollection;
use AdachSoft\AiImageContract\Models\GenerationRequest;
use AdachSoft\AiImageContract\ValueObjects\ImageSize;
use AdachSoft\AiImageContract\ValueObjects\Prompt;
use AdachSoft\AiImageOpenai\OpenAiImageGenerator;
use GuzzleHttp\Client;

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

$response = $generator->generate(new GenerationRequest(
    prompt: new Prompt('A simple red square on a white background'),
    imageInputs: new ImageInputCollection([]),
    size: new ImageSize(1024, 1024),
    options: [
        'model' => 'dall-e-3',
        'quality' => 'hd',
        'style' => 'natural',
    ],
));

Supported contract features

  • Text-to-image generation through ImageGeneratorInterface
  • Contract-compatible GenerationRequest input
  • Contract-compatible ImageResponse output with GeneratedImageCollection
  • OpenAI options passed through GenerationRequest::options:
    • model
    • quality
    • style

Current limitations

The underlying OpenAI DALL-E integration used by this adapter does not support all contract capabilities.

  • imageInputs are not supported and result in FeatureNotSupportedException
  • The adapter currently requests a single output image
  • The response format is URL-based

This means newer contract concepts such as image-to-image 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