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

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

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

adachsoft/ai-image-xai

最新稳定版本:v0.2.0

Composer 安装命令:

composer require adachsoft/ai-image-xai

包简介

AI image explanation library

README 文档

README

AI image generator implementation for the X.AI (Grok) API.

Installation

composer require adachsoft/ai-image-xai

Usage

use AdachSoft\AiImageContract\Collections\ImageInputCollection;
use AdachSoft\AiImageContract\Exceptions\AiImageExceptionInterface;
use AdachSoft\AiImageContract\Models\GenerationRequest;
use AdachSoft\AiImageContract\ValueObjects\ImageSize;
use AdachSoft\AiImageContract\ValueObjects\Prompt;
use AdachSoft\AiImageXai\XaiImageGeneratorFactory;

$generator = XaiImageGeneratorFactory::create('your-xai-api-key');

$request = new GenerationRequest(
    prompt: new Prompt('A cute dog with a lion mane'),
    imageInputs: new ImageInputCollection([]),
    size: new ImageSize(1024, 1024),
    options: ['model' => 'grok-imagine-image'],
);

try {
    $response = $generator->generate($request);

    foreach ($response->images as $image) {
        if ($image->url !== null) {
            echo $image->url . PHP_EOL;
        }

        if ($image->b64Json !== null) {
            echo $image->b64Json . PHP_EOL;
        }
    }
} catch (AiImageExceptionInterface $exception) {
    echo $exception->getMessage();
}

Exception model

This adapter follows the adachsoft/ai-image-contract exception model.

  • ContentModerationException is used for moderation and safety filter rejections.
  • RetryableException is used for temporary provider failures such as rate limits, connectivity issues, and transient server errors.
  • GenerationFailedException is used for non-retryable generation failures.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固