docs(api): 同步 /api/v1/chat/completions 的 OpenAPI 与同步响应

补充 Chat Completions 的兼容响应模型与路由注释,确保 /api/v1/chat/completions 按同步兼容格式返回并更新对应测试与 Swagger 文档。
This commit is contained in:
2026-05-16 00:19:39 +08:00
parent 34c3251c6d
commit ae197a742f
7 changed files with 491 additions and 154 deletions
+95 -24
View File
@@ -4000,26 +4000,27 @@
"BearerAuth": []
}
],
"description": "网关任务接口按 model 选择平台模型;/api/v1 路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"description": "/api/v1/chat/completions 同步执行:stream=true 返回 text/event-stream SSEstream=false 或未传返回兼容 JSON;该接口忽略 X-Async。",
"consumes": [
"application/json"
],
"produces": [
"application/json"
"application/json",
"text/event-stream"
],
"tags": [
"tasks"
],
"summary": "创建或执行 AI 任务",
"summary": "创建 Chat Completions",
"parameters": [
{
"type": "boolean",
"description": "true 时异步创建任务并返回 202",
"description": "该接口忽略此参数",
"name": "X-Async",
"in": "header"
},
{
"description": "AI 任务请求,字段随任务类型变化",
"description": "Chat Completions 请求",
"name": "input",
"in": "body",
"required": true,
@@ -4032,13 +4033,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/httpapi.CompatibleResponse"
}
},
"202": {
"description": "Accepted",
"schema": {
"$ref": "#/definitions/httpapi.TaskAcceptedResponse"
"$ref": "#/definitions/httpapi.ChatCompletionCompatibleResponse"
}
},
"400": {
@@ -4161,7 +4156,7 @@
"BearerAuth": []
}
],
"description": "网关任务接口按 model 选择平台模型;/api/v1 路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"description": "网关任务接口按 model 选择平台模型;除 /api/v1/chat/completions 以外的 /api/v1 任务路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"consumes": [
"application/json"
],
@@ -4254,7 +4249,7 @@
"BearerAuth": []
}
],
"description": "网关任务接口按 model 选择平台模型;/api/v1 路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"description": "网关任务接口按 model 选择平台模型;除 /api/v1/chat/completions 以外的 /api/v1 任务路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"consumes": [
"application/json"
],
@@ -4653,7 +4648,7 @@
"BearerAuth": []
}
],
"description": "网关任务接口按 model 选择平台模型;/api/v1 路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"description": "网关任务接口按 model 选择平台模型;除 /api/v1/chat/completions 以外的 /api/v1 任务路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"consumes": [
"application/json"
],
@@ -4985,7 +4980,7 @@
"BearerAuth": []
}
],
"description": "网关任务接口按 model 选择平台模型;/api/v1 路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"description": "网关任务接口按 model 选择平台模型;除 /api/v1/chat/completions 以外的 /api/v1 任务路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"consumes": [
"application/json"
],
@@ -5452,7 +5447,7 @@
"BearerAuth": []
}
],
"description": "网关任务接口按 model 选择平台模型;/api/v1 路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"description": "网关任务接口按 model 选择平台模型;除 /api/v1/chat/completions 以外的 /api/v1 任务路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"consumes": [
"application/json"
],
@@ -5565,7 +5560,7 @@
"BearerAuth": []
}
],
"description": "网关任务接口按 model 选择平台模型;/api/v1 路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"description": "网关任务接口按 model 选择平台模型;除 /api/v1/chat/completions 以外的 /api/v1 任务路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"consumes": [
"application/json"
],
@@ -5658,7 +5653,7 @@
"BearerAuth": []
}
],
"description": "网关任务接口按 model 选择平台模型;/api/v1 路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"description": "网关任务接口按 model 选择平台模型;除 /api/v1/chat/completions 以外的 /api/v1 任务路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"consumes": [
"application/json"
],
@@ -5777,7 +5772,7 @@
"BearerAuth": []
}
],
"description": "网关任务接口按 model 选择平台模型;/api/v1 路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"description": "网关任务接口按 model 选择平台模型;除 /api/v1/chat/completions 以外的 /api/v1 任务路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"consumes": [
"application/json"
],
@@ -5976,7 +5971,7 @@
"BearerAuth": []
}
],
"description": "网关任务接口按 model 选择平台模型;/api/v1 路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"description": "网关任务接口按 model 选择平台模型;除 /api/v1/chat/completions 以外的 /api/v1 任务路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"consumes": [
"application/json"
],
@@ -6137,7 +6132,7 @@
"BearerAuth": []
}
],
"description": "网关任务接口按 model 选择平台模型;/api/v1 路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"description": "网关任务接口按 model 选择平台模型;除 /api/v1/chat/completions 以外的 /api/v1 任务路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"consumes": [
"application/json"
],
@@ -6230,7 +6225,7 @@
"BearerAuth": []
}
],
"description": "网关任务接口按 model 选择平台模型;/api/v1 路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"description": "网关任务接口按 model 选择平台模型;除 /api/v1/chat/completions 以外的 /api/v1 任务路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"consumes": [
"application/json"
],
@@ -6323,7 +6318,7 @@
"BearerAuth": []
}
],
"description": "网关任务接口按 model 选择平台模型;/api/v1 路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"description": "网关任务接口按 model 选择平台模型;除 /api/v1/chat/completions 以外的 /api/v1 任务路径返回任务受理结果,OpenAI-compatible 路径同步返回兼容响应或 SSE 流。",
"consumes": [
"application/json"
],
@@ -6551,6 +6546,82 @@
}
}
},
"httpapi.ChatCompletionChoice": {
"type": "object",
"properties": {
"finish_reason": {
"type": "string",
"example": "stop"
},
"index": {
"type": "integer",
"example": 0
},
"message": {
"$ref": "#/definitions/httpapi.ChatCompletionChoiceMessage"
}
}
},
"httpapi.ChatCompletionChoiceMessage": {
"type": "object",
"properties": {
"content": {
"type": "string",
"example": "Hello"
},
"role": {
"type": "string",
"example": "assistant"
}
}
},
"httpapi.ChatCompletionCompatibleResponse": {
"type": "object",
"properties": {
"choices": {
"type": "array",
"items": {
"$ref": "#/definitions/httpapi.ChatCompletionChoice"
}
},
"created": {
"type": "integer",
"example": 1710000000
},
"id": {
"type": "string",
"example": "chatcmpl-123"
},
"model": {
"type": "string",
"example": "gpt-4o-mini"
},
"object": {
"type": "string",
"example": "chat.completion"
},
"usage": {
"$ref": "#/definitions/httpapi.ChatCompletionUsage"
}
}
},
"httpapi.ChatCompletionUsage": {
"type": "object",
"properties": {
"completion_tokens": {
"type": "integer",
"example": 8
},
"prompt_tokens": {
"type": "integer",
"example": 12
},
"total_tokens": {
"type": "integer",
"example": 20
}
}
},
"httpapi.ChatMessage": {
"type": "object",
"properties": {