adachsoft/ai-image-openai 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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 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

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固