【AI】deepseek对接api
价格不贵apiKey申请地址:https://platform.deepseek.com/api_keys
提示词库:https://api-docs.deepseek.com/zh-cn/prompt-library/
let apiKey = "sk-0b31e8c2ced7493c9bdb87xxxxxxxx"
let ret = http.postJSON("https://api.deepseek.com/chat/completions", {
"model": "deepseek-chat",
"messages": [
{"role": "system", "content": "你是一个老师."}, //给定ai一个角色
{"role": "user", "content": "1+1="} //提问
],
"stream": false
}, 10 * 1000, {Authorization: "Bearer " + apiKey})
logd(ret);
if (ret) {
ret = JSON.parse(ret)
logd(ret.choices.message.content);
}
返回值如下
{"id":"5797e93d-ffa6-4b9c-8e55-1cc47f5af34d","object":"chat.completion","created":1736310465,"model":"deepseek-chat","choices":[{"index":0,"message":{"role":"assistant","content":"1 + 1 = 2。\n\n这是一个基本的加法运算。如果你有其他问题或需要进一步的解释,请告诉我!"},"logprobs":null,"finish_reason":"stop"}],"usage":{"prompt_tokens":11,"completion_tokens":24,"total_tokens":35,"prompt_cache_hit_tokens":0,"prompt_cache_miss_tokens":11},"system_fingerprint":"fp_3a5770e1b4"}
【远程设备】(js/main.js#43 )1 + 1 = 2。
这是一个基本的加法运算。如果你有其他问题或需要进一步的解释,请告诉我!
页:
[1]