PHP code example of ihome / wujie-ai

1. Go to this page and download the library: Download ihome/wujie-ai library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ihome / wujie-ai example snippets




return [
    'app_id' => env('WUJIE_AI_APP_ID', ''),
    'private_key' => env('WUJIE_AI_PRIVATE_KEY', ''),
    'base_url' => env('WUJIE_AI_BASE_URL', ''),
];


$config = [
    'appId' => config('wujie.app_id'),
    'privateKey' => config('wujie.private_key'),
    'baseUrl' => config('wujie.base_url'),
];

// 获取无界AI工厂实例
$wujie = WujieAiFactory::create($config);

// 获取数据 如果你使用了全局错误异常处理,此处可以不包 try-catch
try {
    // 文生图 & 图生图
    $result = $wujie->image->create([
                    'model_code' => 22,
                    'prompt' => '一个漂亮的年轻女孩,洛丽塔服装,长头发,瓜子脸,在原野上,手持法杖'
                ]); // 文生图,图生图根据官网参数传递
    $result = $wujie->image->baseModelInfos(); // 获取基础模型列表
    $result = $wujie->image->styleModelDefaultResource(); // 获取基础风格模型列表
    $result = $wujie->image->defaultResource(['model' => 22]); // 获取模型的预设资源
    $result = $wujie->image->priceInfos(['model' => 22,'uc_prompt' => '模糊,混乱', 'prompt' => '一个精致的现代风格女孩']); // 计算作画成本
    $result = $wujie->image->generatingInfo(['2C633CD85DW0D869AXSYYCDADE3CWXAA']);// 作画结果查询
    $result = $wujie->image->info(['key' => '2C633CD85DW0D869AXSYYCDADE3CWXAA']);// 作画成功后的图片详情查询
    
    // 视频生视频
    $result = $wujie->video->create([
                    'origin_video_url' => 'http://www.google.com/youtube/abc.mp4',
                    'video_duration' => 10,
                    'model_code' => 22,
              ]);  // 用视频生成另外一个风格的视频
    $result = $wujie->video->info(['key' => '2C633CD85DW0D869AXSYYCDADE3CWXAA']);// 视频生成成功后的视频详情查询
    $result = $wujie->video->generatingInfo(['2C633CD85DW0D869AXSYYCDADE3CWXAA']);// 视频生成结果查询
    $result = $wujie->video->optionMenu(); // 获取视频生视频模型列表及价格表
    $result = $wujie->video->waitTime(['modelCode' => 22]); // 视频生视频模型排队情况查询
    
    var_dump($result);
} catch (\Exception $e) {
    logger()->error('wujie', ['error' => $e->getMessage()]);
    // 其他业务逻辑处理
}