马上注册,解锁更多高级玩法
您需要 登录 才可以下载或查看,没有账号?立即注册
×
价格不贵
apiKey申请地址:https://platform.deepseek.com/api_keys
提示词库:https://api-docs.deepseek.com/zh-cn/prompt-library/
[JavaScript] 纯文本查看 复制代码 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[0].message.content);
}
返回值如下
[Plain Text] 纯文本查看 复制代码 {"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"}
[2025-01-08 12:27:46.819]【远程设备】(js/main.js#43 )1 + 1 = 2。
这是一个基本的加法运算。如果你有其他问题或需要进一步的解释,请告诉我!
|