⚡ 模型服务

YuZo 提供完全兼容 OpenAI 的模型 API,覆盖对话推理工具调用三种核心能力。所有模型共享统一端点,只需切换 model 参数。

Base URL https://api.deepshields.com/v1
端点 POST /v1/chat/completions
认证 Bearer YOUR_API_KEY
能力model 参数适用场景特点
Chat 对话chat文本对话、知识问答、翻译摘要快速响应,互联网深度搜索
Reasoner 推理reasoner复杂分析、安全研判、代码审计专用场景深度推理
Tool 工具调用toolFunction Calling、Agent、任务编排工具调用自动化适配,任务指令逻辑编排
API 参考

POST https://api.deepshields.com/v1/chat/completions

统一的对话补全端点,完全兼容 OpenAI SDK。通过 model 参数选择不同模型能力。请求需在 Header 中携带 Authorization: Bearer YOUR_API_KEY

请求参数

参数类型必填说明
modelstringchat 对话 · reasoner 推理 · tool 工具调用
messagesarray消息数组,每项含 role(system / user / assistant / tool)和 content
streamboolean是否流式输出,默认 false
temperaturenumber采样温度 0~2,默认 1。推理建议设为 0.3
max_tokensinteger最大生成 token 数
toolsarray工具定义列表(仅 model="tool" 时使用),符合 OpenAI Function Calling 规范
tool_choicestring"auto" 模型自行判断 · "none" 不调用工具。默认 "auto"

返回值 — choices[].message

字段类型说明
rolestring固定 "assistant"
contentstring | null模型生成的文本(工具调用时为 null
tool_callsarray | null工具调用列表,含 function.namefunction.arguments(JSON 字符串)
finish_reasonstring"stop" 正常完成 · "tool_calls" 需执行工具后回传结果
usageobjecttoken 用量:prompt_tokens / completion_tokens / total_tokens
示例
🔐 注册登录 后,代码示例中的 API Key 将自动替换为您的专属密钥,可直接复制运行。未登录状态下示例使用演示密钥,可能受到调用限制。

Chat 对话

使用 model="chat" 调用对话模型。适用于日常对话、知识问答、翻译和内容生成。

PYTHON
from openai import OpenAI

client = OpenAI(
    base_url="https://api.deepshields.com/v1",
    api_key="YOUR_API_KEY",
)

response = client.chat.completions.create(
    model="chat",
    messages=[
        {"role": "system", "content": "你是 YuZo,一个有帮助的AI助手"},
        {"role": "user", "content": "你好!请用一句话介绍你自己"},
    ],
)
print(response.choices[0].message.content)
GO
package main

import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)

func main() {
body, _ := json.Marshal(map[string]interface{}{
"model": "chat",
"messages": []map[string]string{
{"role": "system", "content": "你是 YuZo,一个有帮助的AI助手"},
{"role": "user", "content": "你好!请用一句话介绍你自己"},
},
})
req, _ := http.NewRequest("POST",
"https://api.deepshields.com/v1/chat/completions",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")

resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
data, _ := io.ReadAll(resp.Body)
fmt.Println(string(data))
}
JAVASCRIPT
const resp = await fetch("https://api.deepshields.com/v1/chat/completions", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer YOUR_API_KEY",
  },
  body: JSON.stringify({
    model: "chat",
    messages: [
      { role: "system", content: "你是 YuZo,一个有帮助的AI助手" },
      { role: "user", content: "你好!请用一句话介绍你自己" },
    ],
  }),
});
const data = await resp.json();
console.log(data.choices[0].message.content);
JAVA
import java.net.URI;
import java.net.http.*;

public class Chat {
    public static void main(String[] args) throws Exception {
        var client = HttpClient.newHttpClient();
        var body = "{\"model\":\"chat\",\"messages\":["
            + "{\"role\":\"system\",\"content\":\"你是 YuZo,一个有帮助的AI助手\"},"
            + "{\"role\":\"user\",\"content\":\"你好!请用一句话介绍你自己\"}]}";
        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.deepshields.com/v1/chat/completions"))
            .header("Content-Type", "application/json")
            .header("Authorization", "Bearer YOUR_API_KEY")
            .POST(HttpRequest.BodyPublishers.ofString(body))
            .build();
        var response = client.send(request,
            HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
执行结果
点击「执行」查看结果

Reasoner 推理

使用 model="reasoner" 调用深度推理模型。适用于复杂逻辑分析、安全研判、代码审计等需要深度思考的场景。建议将 temperature 设为 0.3。

PYTHON
from openai import OpenAI

client = OpenAI(
    base_url="https://api.deepshields.com/v1",
    api_key="YOUR_API_KEY",
)

response = client.chat.completions.create(
    model="reasoner",
    temperature=0.3,
    messages=[
        {"role": "system", "content": "你是一名网络安全分析专家"},
        {"role": "user", "content": "分析以下流量特征是否为DDoS:源IP分散、目标端口80/443、请求量从100激增到50000、SYN包占比95%"},
    ],
)
print(response.choices[0].message.content)
GO
package main

import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)

func main() {
body, _ := json.Marshal(map[string]interface{}{
"model":       "reasoner",
"temperature": 0.3,
"messages": []map[string]string{
{"role": "system", "content": "你是一名网络安全分析专家"},
{"role": "user", "content": "分析以下流量特征是否为DDoS:源IP分散、目标端口80/443、请求量从100激增到50000、SYN包占比95%"},
},
})
req, _ := http.NewRequest("POST",
"https://api.deepshields.com/v1/chat/completions",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")

resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
data, _ := io.ReadAll(resp.Body)
fmt.Println(string(data))
}
JAVASCRIPT
const resp = await fetch("https://api.deepshields.com/v1/chat/completions", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer YOUR_API_KEY",
  },
  body: JSON.stringify({
    model: "reasoner",
    temperature: 0.3,
    messages: [
      { role: "system", content: "你是一名网络安全分析专家" },
      { role: "user", content: "分析以下流量特征是否为DDoS:源IP分散、目标端口80/443、请求量从100激增到50000、SYN包占比95%" },
    ],
  }),
});
const data = await resp.json();
console.log(data.choices[0].message.content);
JAVA
import java.net.URI;
import java.net.http.*;

public class Reasoner {
    public static void main(String[] args) throws Exception {
        var client = HttpClient.newHttpClient();
        var body = "{\"model\":\"reasoner\",\"temperature\":0.3,\"messages\":["
            + "{\"role\":\"system\",\"content\":\"你是一名网络安全分析专家\"},"
            + "{\"role\":\"user\",\"content\":\"分析以下流量特征是否为DDoS:"
            + "源IP分散、目标端口80/443、请求量从100激增到50000、SYN包占比95%\"}]}";
        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.deepshields.com/v1/chat/completions"))
            .header("Content-Type", "application/json")
            .header("Authorization", "Bearer YOUR_API_KEY")
            .POST(HttpRequest.BodyPublishers.ofString(body))
            .build();
        var response = client.send(request,
            HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
执行结果
点击「执行」查看结果

Tool 工具调用 (Function Calling)

使用 model="tool" 进行标准 Function Calling。您提供工具定义清单(tools 参数),模型自动判断调用哪个工具并填入参数,返回标准 tool_calls 响应。完全兼容 OpenAI Function Calling 规范。

Tool 专属参数

参数类型必填说明
toolsarray工具定义列表,每项含 type: "function"function(name / description / parameters)
tool_choicestring"auto" 模型自行判断 · "none" 不调用工具。默认 "auto"

Tool 返回值差异

字段说明
message.contentnull模型选择调用工具时不返回文本
message.tool_calls[]arrayidfunction.namefunction.arguments(JSON 字符串)
finish_reason"tool_calls"表示您需要执行工具并将结果以 role="tool" 回传模型
PYTHON
from openai import OpenAI

client = OpenAI(
    base_url="https://api.deepshields.com/v1",
    api_key="YOUR_API_KEY",
)

tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "查询指定城市的天气",
        "parameters": {
            "type": "object",
            "properties": {
                "city": {"type": "string", "description": "城市名"}
            },
            "required": ["city"]
        }
    }
}]

response = client.chat.completions.create(
    model="tool",
    messages=[{"role": "user", "content": "北京天气怎么样?"}],
    tools=tools,
    tool_choice="auto",
)

msg = response.choices[0].message
if msg.tool_calls:
    tc = msg.tool_calls[0]
    print(f"调用: {tc.function.name}({tc.function.arguments})")
else:
    print(msg.content)
GO
package main

import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)

func main() {
payload := map[string]interface{}{
"model": "tool",
"messages": []map[string]string{
{"role": "user", "content": "北京天气怎么样?"},
},
"tools": []map[string]interface{}{{
"type": "function",
"function": map[string]interface{}{
"name":        "get_weather",
"description": "查询指定城市的天气",
"parameters": map[string]interface{}{
"type": "object",
"properties": map[string]interface{}{
"city": map[string]string{
"type": "string", "description": "城市名",
},
},
"required": []string{"city"},
},
},
}},
"tool_choice": "auto",
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST",
"https://api.deepshields.com/v1/chat/completions",
bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")

resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
data, _ := io.ReadAll(resp.Body)
fmt.Println(string(data))
}
JAVASCRIPT
const resp = await fetch("https://api.deepshields.com/v1/chat/completions", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer YOUR_API_KEY",
  },
  body: JSON.stringify({
    model: "tool",
    messages: [{ role: "user", content: "北京天气怎么样?" }],
    tools: [{
      type: "function",
      function: {
        name: "get_weather",
        description: "查询指定城市的天气",
        parameters: {
          type: "object",
          properties: {
            city: { type: "string", description: "城市名" }
          },
          required: ["city"]
        }
      }
    }],
    tool_choice: "auto",
  }),
});
const data = await resp.json();
const msg = data.choices[0].message;
if (msg.tool_calls) {
  const tc = msg.tool_calls[0];
  console.log(`调用: ${tc.function.name}(${tc.function.arguments})`);
} else {
  console.log(msg.content);
}
JAVA
import java.net.URI;
import java.net.http.*;

public class ToolCall {
    public static void main(String[] args) throws Exception {
        var client = HttpClient.newHttpClient();
        var body = "{\"model\":\"tool\",\"tool_choice\":\"auto\","
            + "\"messages\":[{\"role\":\"user\",\"content\":\"北京天气怎么样?\"}],"
            + "\"tools\":[{\"type\":\"function\",\"function\":{"
            + "\"name\":\"get_weather\","
            + "\"description\":\"查询指定城市的天气\","
            + "\"parameters\":{\"type\":\"object\","
            + "\"properties\":{\"city\":{\"type\":\"string\","
            + "\"description\":\"城市名\"}},"
            + "\"required\":[\"city\"]}}}]}";
        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.deepshields.com/v1/chat/completions"))
            .header("Content-Type", "application/json")
            .header("Authorization", "Bearer YOUR_API_KEY")
            .POST(HttpRequest.BodyPublishers.ofString(body))
            .build();
        var response = client.send(request,
            HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
执行结果
点击「执行」查看结果