XGPT

XGPT 是微步在线自研的网络安全大模型,基于 DeepSeek-R1 构建,融合微步丰富的情报库与安全知识库,专为网络安全场景深度优化,具备更强的中文理解与推理能力,能够提供高质量的威胁分析、处置建议与深度安全洞见。

调用脚本
Run In Postman
请求方式
请求地址: https://api.threatbook.cn/v3/xgpt/completion

请求方式:POST

请求参数说明
序号参数名称必选类型描述
1messagearray对话信息。是一个JSON数组,每个item的字段定义如下:
  • role:消息角色,目前支持user/assistant/system
  • content:消息内容
2max_tokensint允许生成的最大 token 数,取值[1, 4000],默认值为1024。
3modelstring模型名称,默认为"XGPT-deepseek"
响应参数说明
序号参数名称类型描述
1response_codeint响应正常会返回"0"。其他Response code及对应msg描述参见"响应Code和Msg对照表"
2verbose_msgstring响应正常会返回"Ok"。其他Response code及对应msg描述参见"响应Code和Msg对照表"
3idstring请求 id
4createdstring表示本次 chat 请求被创建的时间
5choiceobject模型返回内容,是一个JSON对象,字段说明如下:
  • message:模型返回内容,是一个JSON对象,包含以下字段:
    • role:消息角色,目前支持user/assistant/system
    • content:消息内容
  • finish_reason:结束原因,string类型,"stop"表示正常生成结束, "length"表示已经到了制定的最大的 token 数量(max_tokens)
6modelstring响应正常会返回"XGPT-deepseek"
请求示例

微步在线云API支持cURL、Python、PHP、Java、Go语言的请求,以Python为例:

Python
import requests
 
url = "https://api.threatbook.cn/v3/xgpt/completion"
 
headers = {
    "Authorization": "Bearer 请替换apikey",
    "Content-Type": "application/json"
}
 
query = {
    "message": [
        {
            "role": "user",
            "content": "What are the latest trends in cybersecurity?"
        }
    ],
    "max_tokens": 1024,
    "model": "XGPT-deepseek"
}
 
response = requests.post(url, headers=headers, json=query)  # Fixed params to json since content-type is json
 
print(response.json())
响应示例(JSON)
{
    "response_code": 0,
    "verbose_msg": "Ok",
    "data": {
        "id": "unique_request_id",
        "created": "2024-11-14T10:30:45Z",
        "choice": {
            "message": {
                "role": "assistant",
                "content": "The latest trends in cybersecurity include advancements in AI-driven threat detection, zero-trust architecture, and enhanced data privacy measures."
            },
            "finish_reason": "stop"
        },
        "model": "XGPT-deepseek"
    }
}
云API是北京微步在线科技有限公司旗下产品了解微步在线《用户服务条款》《数据保护政策》联系我们:api@threatbook.cn