快速开始
从平台令牌、模型 ID 到第一个请求。
1. 获取令牌
登录 可当 AI 平台,在令牌管理中创建 API Key。请勿将真实密钥写入网页、截图或代码仓库。
2. 确认地址与模型
API 基础域名是 https://ai.kedang.net。在平台模型广场复制完整模型 ID;大小写和后缀必须原样使用。
3. 发送首个请求
以下均调用对话接口。选择公开目录中的文本模型,并确认令牌有权访问。
curl
curl https://ai.kedang.net/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "MODEL_ID",
"messages": [
{"role": "user", "content": "你好"}
]
}'Python(标准库)
import json
import urllib.request
payload = {"model": "MODEL_ID", "messages": [{"role": "user", "content": "你好"}]}
request = urllib.request.Request(
"https://ai.kedang.net/v1/chat/completions",
data=json.dumps(payload, ensure_ascii=False).encode("utf-8"),
headers={"Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json"},
method="POST",
)
with urllib.request.urlopen(request) as response:
print(json.load(response))Node.js 18+
const response = await fetch("https://ai.kedang.net/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({model: "MODEL_ID", messages: [{role: "user", content: "你好"}]}),
});
console.log(await response.json());将 YOUR_API_KEY 和 MODEL_ID 替换为你的令牌与模型 ID。完整参数和响应格式见对话接口文档。