外观
公共类型定义
本文汇总核心接口涉及的公共数据结构,供字段对照参考。
消息与角色
角色常量
| 值 | 含义 |
|---|---|
system | 系统提示 |
user | 用户 |
assistant | 助手 |
tool | 工具调用结果 |
function | 函数调用结果 |
Message(globals.Message)
json
{
"role": "user",
"content": "你好",
"name": null,
"function_call": null,
"tool_call_id": null,
"tool_calls": null,
"reasoning_content": null
}| 字段 | 类型 | 说明 |
|---|---|---|
role | string | 角色 |
content | string | 文本内容 |
name | string | 可选名称 |
function_call | FunctionCall | 函数调用(function 角色) |
tool_call_id | string | 工具调用 ID(tool 角色) |
tool_calls | ToolCalls | 工具调用(assistant 角色) |
reasoning_content | string | 推理内容(DeepSeek reasoner 等模型) |
FunctionCall
json
{ "name": "get_weather", "arguments": "{\"city\":\"北京\"}" }ToolCall(ToolCalls 数组元素)
json
{
"index": 0,
"type": "function",
"id": "call_abc123",
"function": { "name": "get_weather", "arguments": "{\"city\":\"北京\"}" }
}ToolObject(FunctionTools 数组元素)
json
{
"type": "function",
"function": {
"name": "get_weather",
"description": "获取城市天气",
"parameters": {
"type": "object",
"properties": { "city": { "type": "string", "description": "城市名" } },
"required": ["city"]
}
}
}用量(Usage)
json
{ "prompt_tokens": 12, "completion_tokens": 18, "total_tokens": 30 }| 字段 | 说明 |
|---|---|
prompt_tokens | 输入 token 数 |
completion_tokens | 输出 token 数 |
total_tokens | 总 token 数 |
错误(RelayErrorResponse)
json
{
"error": { "message": "quota exceeded", "type": "quota_exceeded_error" }
}详见 错误处理。
计费规则(Charge)
json
{
"id": 1,
"type": "token-billing",
"models": ["gpt-3.5-turbo"],
"input": 0.0015,
"output": 0.002,
"anonymous": false
}套餐(Plan)
json
{
"level": 1,
"price": 19.9,
"items": [
{
"id": "basic-chat",
"name": "基础对话额度",
"icon": "chat",
"value": 100000,
"models": ["gpt-3.5-turbo"]
}
]
}模型列表(ListModels)
json
{
"object": "list",
"data": [
{ "id": "gpt-3.5-turbo", "object": "model", "created": 1700000000, "owned_by": "system" }
]
}视频任务(RelayVideoJob)
json
{
"id": "video-abc123",
"object": "video",
"model": "sora-2",
"created_at": 1700000000,
"completed_at": null,
"expires_at": null,
"error": null,
"progress": 0,
"prompt": "一只小猫在草地上奔跑",
"seconds": "5",
"size": "1024x1024",
"remixed_from_video_id": null,
"status": "queued"
}