php调用通义千问模型api接口示例代码
代码语言:php
所属分类:其他
代码描述:php调用通义千问模型api接口示例代码
代码标签: php 调用 通义千问 模型 api 接口 示例 代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<?php //key申请地址:https://dashscope.console.aliyun.com/apiKey $apikey=""; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $body = [ 'model' => 'qwen-turbo', // 'model' => 'qwen-plus-v1', 'messages' => [['role' => "system", "content" => "You are a helpful assistant."], ['role' => "user", "content" => "你是谁?"], ], ]; curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body, JSON_UNESCAPED_UNICODE)); curl_setopt($ch, .........完整代码请登录后点击上方下载按钮下载查看
网友评论0