注册登录
好像需要个人认证
最好不要前端调用因为被用户会看到keys 我这里就用前端了 看效果比较快
复制keys
我这里用js
这里headers必须是json结构
model是模型 目前有这几种模型 GLM-4-FLASH是最便宜的 tokens/0.0001
fetch("https://open.bigmodel.cn/api/paas/v4/chat/completions", {
"headers": {
"authorization": "这里填入Keys",
"content-type": "application/json",
},
"body": "{\"model\":\"glm-4-flash\",\"messages\":[{\"role\":\"user\",\"content\":\"" +
'你好啊'+ "\"}]}",
"method": "POST",
}).then(text => text.json()).then(req => {
console.log( req.choices[0].message.content)
})