使用vscode中的REST Client 插件
新建一个.http文件
POST https://api.deepseek.com/v1/chat/completions
Authorization: Bearer your_api_key_here
Content-Type: application/json
{
"model": "deepseek-chat",
"messages": [{"role": "user", "content": "Testing API"}]
}
send request一下 查看结果
结果返回值
- 返回200 并包含正常聊天信息,为API key有效
- 返回401 或者 403,为需检查key是否正确
- 返回402 Payment Required 并提示 Insufficient Balance ,为你的 DeepSeek API 账户没有足够的额度或未开通付费订阅。
返回200 示例
返回401 示例
{
"error": {
"message": "Authentication Fails, Your api key: ****here is invalid",
"type": "authentication_error",
"param": null,
"code": "invalid_request_error"
}
}
返回402 示例
HTTP/1.1 402 Payment Required
Date: Mon, 19 May 2025 12:44:46 GMT
Content-Type: application/json
Content-Length: 111
Connection: close
vary: origin, access-control-request-method, access-control-request-headers access-control-allow-credentials: true
x-ds-trace-id: 9c61771c9fdf62f01855910e8a749298
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload X-Content-Type-Options: nosniff
Server: CW
{
"error":{
"message": "Insufficient Balance",
"type": "unknown_error",
"param": null,
"code": "invalid_request_error"
}
}