跳到主要内容

DeepSeek API

通过 Hubnode 调用 DeepSeek 大语言模型。

端点

POST https://hubnode.uk/api/v1/llm/chat/completions

text

认证

需要 Bearer Token。先在 注册页面 获取 API 密钥。

curl -X POST https://hubnode.uk/api/auth/oauth2/token \
-H "Content-Type: application/json" \
-d '{"client_id":"YOUR_CLIENT_ID","client_secret":"YOUR_CLIENT_SECRET"}'
请求参数
参数类型说明
modelstringdeepseek-chat 或 deepseek-coder
messagesarray对话消息列表
max_tokensint最大输出 token 数,默认 1024
temperaturefloat0-1,默认 0.7
cURL 示例
bash
JWT=$(curl -s -X POST https://hubnode.uk/api/auth/oauth2/token \
-H "Content-Type: application/json" \
-d '{"client_id":"YOUR_ID","client_secret":"YOUR_SECRET"}' \
| python3 -c "import sys,json; print(json.load(sys.stdin)['access_token'])")

curl -X POST https://hubnode.uk/api/v1/llm/chat/completions \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-d '{"model":"deepseek-chat","messages":[{"role":"user","content":"你好"}],"max_tokens":100}'
Python 示例
python
import requests

resp = requests.post("https://hubnode.uk/api/auth/oauth2/token", json={
"client_id": "YOUR_ID", "client_secret": "YOUR_SECRET"
})
token = resp.json()["access_token"]

resp = requests.post("https://hubnode.uk/api/v1/llm/chat/completions",
headers={"Authorization": f"Bearer {token}"},
json={"model":"deepseek-chat","messages":[{"role":"user","content":"你好"}],"max_tokens":100})

print(resp.json()["choices"][0]["message"]["content"])
JavaScript 示例
javascript
const tokenResp = await fetch("https://hubnode.uk/api/auth/oauth2/token", {
method: "POST", headers: {"Content-Type":"application/json"},
body: JSON.stringify({client_id:"YOUR_ID", client_secret:"YOUR_SECRET"})
});
const {access_token} = await tokenResp.json();

const llmResp = await fetch("https://hubnode.uk/api/v1/llm/chat/completions", {
method: "POST",
headers: {"Authorization":`Bearer ${access_token}`,"Content-Type":"application/json"},
body: JSON.stringify({model:"deepseek-chat",messages:[{role:"user",content:"你好"}],max_tokens:100})
});
console.log((await llmResp.json()).choices[0].message.content);
可用模型
模型说明
deepseek-chat通用对话模型
deepseek-coder代码生成模型
限制
免费套餐:每天 100 次请求

Token 有效期:1 小时

单次最大输出:4096 tokens