⚡ 模型服务
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 工具调用 | tool | Function Calling、Agent、任务编排 | 工具调用自动化适配,任务指令逻辑编排 |
API 参考
POST https://api.deepshields.com/v1/chat/completions
统一的对话补全端点,完全兼容 OpenAI SDK。通过 model 参数选择不同模型能力。请求需在 Header 中携带 Authorization: Bearer YOUR_API_KEY。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | ✓ | chat 对话 · reasoner 推理 · tool 工具调用 |
| messages | array | ✓ | 消息数组,每项含 role(system / user / assistant / tool)和 content |
| stream | boolean | — | 是否流式输出,默认 false |
| temperature | number | — | 采样温度 0~2,默认 1。推理建议设为 0.3 |
| max_tokens | integer | — | 最大生成 token 数 |
| tools | array | — | 工具定义列表(仅 model="tool" 时使用),符合 OpenAI Function Calling 规范 |
| tool_choice | string | — | "auto" 模型自行判断 · "none" 不调用工具。默认 "auto" |
返回值 — choices[].message
| 字段 | 类型 | 说明 |
|---|---|---|
| role | string | 固定 "assistant" |
| content | string | null | 模型生成的文本(工具调用时为 null) |
| tool_calls | array | null | 工具调用列表,含 function.name 和 function.arguments(JSON 字符串) |
| finish_reason | string | "stop" 正常完成 · "tool_calls" 需执行工具后回传结果 |
| usage | object | token 用量:prompt_tokens / completion_tokens / total_tokens |
示例
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 专属参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| tools | array | ✓ | 工具定义列表,每项含 type: "function" 和 function(name / description / parameters) |
| tool_choice | string | — | "auto" 模型自行判断 · "none" 不调用工具。默认 "auto" |
Tool 返回值差异
| 字段 | 值 | 说明 |
|---|---|---|
| message.content | null | 模型选择调用工具时不返回文本 |
| message.tool_calls[] | array | 含 id、function.name、function.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());
}
}执行结果
点击「执行」查看结果