阿里云通义万相 PHP SDK
近日,因想试试阿里云的通义万相 AI 生成图片功能,在 github 和 packagist.org 都未能找到相应的包,所以利用五一空隙时间自己写了一个并发布出来。现分享出来:github.com/icetalker/dashscope-php
欢迎大家指导!
安装
通过 Composer 安装此包:
composer require icetalker/dashscope-php
用法
生成图片
示例如下:
use Dashscope\Dashscope;
$api_key = 'your-dashscope-api-key';
$parameters = [
'api_key' => $api_key,
'prompt' => 'Hello World!',
];
$response = Dashscope::imageSynthesis($parameters)->call();
return $response->getBody()->getContents();
查询作业结果
$api_key = 'your-dashscope-api-key';
$task_id = '******';
$response = Dashscope::fetchTask($task_id, $api_key);
return $response->getBody()->getContents();
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: