腾讯AI开放平台 SDK
Tencent AI open platform sdk
Special thanks to the generous sponsorship by:
Requirement
PHP >= 7.0
ext-curl 拓展
ext-json 拓展
安装
composer require justmd5/tencent-ai
使用
$config = [
'appKey' => '1106944xxx',
'appSecret' => 'dsgnbnWnX8Yxxxxxx',
'debug' => true,//true show debug info
];
$AI = new \Justmd5\TencentAi\Ai($config);
接口调用示例
$params = [
'question'=>'腾讯人工智能',
'session'=>123,
];
try {
dd($AI->nlp->request('textchat', $params));
} catch (\Justmd5\TencentAi\Exception\NotFoundException $e) {
dd($e);
}
$params = [
//image 支持两种传递参数方式
// 'image' => base64_encode(file_get_contents(__DIR__ . '/1571126902_843200.jpg')),//old
'image' => __DIR__ . '/1571126902_843200.jpg',//new
'session_id' => time(),
];
try {
var_dump($AI->vision->request('imgtotext', $params));
} catch (\Justmd5\TencentAi\Exception\NotFoundException $e) {
print_r($e->getMessage());
} catch (\Justmd5\TencentAi\Exception\IllegalParameterException $e) {
print_r($e->getMessage());
}
文档
帮助
qq群
Todo
parameter verify
感谢
源码列表
License
MIT