adachsoft/ai-image-openai
最新稳定版本:v0.2.0
Composer 安装命令:
composer require adachsoft/ai-image-openai
包简介
README 文档
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
GenerationRequestinput - Contract-compatible
ImageResponseoutput withGeneratedImageCollection - OpenAI options passed through
GenerationRequest::options:modelqualitystyle
Current limitations
The underlying OpenAI DALL-E integration used by this adapter does not support all contract capabilities.
imageInputsare not supported and result inFeatureNotSupportedException- 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
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-19