"text-davinci-003","prompt"=> "'.$text.'","max_tokens"=> 1024, "temperature"=>0];$result=curl($url,$data,$headers);var_dump(JSON_decode($result,true));exit;function curl($url,$data,$headers){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //停止验证证书(一般只需要设置此项为false即可) curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HttpHEADER, $headers); $response = curl_exec($ch); curl_close($ch); return $response;}
来源地址:https://blog.csdn.net/weixin_39934453/article/details/129288510
--结束END--
本文标题: php实现通过api实现chatgpt
本文链接: https://www.lsjlt.com/news/391640.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0