智能对话
剩余免费次数:
{{ remainingQuota }}
标题
分类
内容预览
创建时间
操作
{{ item.title }}
{{ item.category }}
{{ item.content }}
{{ formatDate(item.created_at) }}
暂无知识库内容
点击上方按钮添加您的第一条知识
暂无应用
点击上方按钮创建您的第一个应用
{{ app.app_name }}
Secret只在创建时显示,请妥善保管
API接口说明
POST
/api/external/chat
请求头:
X-App-Id: your_app_idX-App-Secret: your_app_secret
请求参数:
{ "question": "用户问题", "history": [{"role": "user", "content": "历史消息"}]}
接入示例
<?php$ch = curl_init();curl_setopt($ch, CURLOPT_URL, 'https://zs.zytlife.com/api/external/chat');curl_setopt($ch, CURLOPT_POST, true);curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ 'question' => '你好', 'history' => []]));curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'X-App-Id: your_app_id', 'X-App-Secret: your_app_secret']);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);$result = curl_exec($ch);curl_close($ch);echo $result;?>
import requestsimport jsonurl = 'https://zs.zytlife.com/api/external/chat'headers = { 'Content-Type': 'application/json', 'X-App-Id': 'your_app_id', 'X-App-Secret': 'your_app_secret'}data = { 'question': '你好', 'history': []}response = requests.post(url, headers=headers, json=data)print(response.json())
const https = require('https');const options = { hostname: 'zs.zytlife.com', path: '/api/external/chat', method: 'POST', headers: { 'Content-Type': 'application/json', 'X-App-Id': 'your_app_id', 'X-App-Secret': 'your_app_secret' }};const req = https.request(options, (res) => { let body = ''; res.on('data', (chunk) => body += chunk); res.on('end', () => console.log(body));});req.write(JSON.stringify({ question: '你好', history: [] }));req.end();
URL url = new URL("https://zs.zytlife.com/api/external/chat");HttpURLConnection conn = (HttpURLConnection) url.openConnection();conn.setRequestMethod("POST");conn.setRequestProperty("Content-Type", "application/json");conn.setRequestProperty("X-App-Id", "your_app_id");conn.setRequestProperty("X-App-Secret", "your_app_secret");conn.setDoOutput(true);String json = "{\"question\":\"你好\",\"history\":[]}";conn.getOutputStream().write(json.getBytes());BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));String line; String result = "";while ((line = in.readLine()) != null) result += line;System.out.println(result);
wx.request({ url: 'https://zs.zytlife.com/api/external/chat', method: 'POST', header: { 'Content-Type': 'application/json', 'X-App-Id': 'your_app_id', 'X-App-Secret': 'your_app_secret' }, data: { question: '你好', history: [] }, success: (res) => { console.log(res.data); }})
curl -X POST https://zs.zytlife.com/api/external/chat \ -H "Content-Type: application/json" \ -H "X-App-Id: your_app_id" \ -H "X-App-Secret: your_app_secret" \ -d '{"question":"你好","history":[]}'