{ "openapi": "3.0.3", "info": { "title": "LangBot Service API", "description": "LangBot external service API documentation. These endpoints support API Key authentication for programmatic access to LangBot resources.\n\n**Authentication:**\n- User Token (via `Authorization: Bearer `)\n- API Key (via `X-API-Key: ` or `Authorization: Bearer `)\n\nAll endpoints in this document support both authentication methods unless otherwise noted.\n", "version": "4.9.5", "contact": { "name": "LangBot", "url": "https://langbot.app" }, "license": { "name": "AGPL-3.0", "url": "https://github.com/langbot-app/LangBot/blob/master/LICENSE" } }, "servers": [ { "url": "http://localhost:5300", "description": "Local development server" } ], "tags": [ { "name": "モデルプロバイダー", "description": "Model provider management. Providers define API endpoints and keys; models reference providers via provider_uuid." }, { "name": "LLMモデル", "description": "Large Language Model (LLM) management. Each model is associated with a provider." }, { "name": "埋め込みモデル", "description": "Embedding model management. Each model is associated with a provider." }, { "name": "ボット", "description": "Bot instance management and messaging" }, { "name": "パイプライン", "description": "Pipeline configuration management" }, { "name": "ナレッジベース", "description": "Knowledge base management" }, { "name": "ナレッジエンジン", "description": "Knowledge engine (plugin-provided) queries" }, { "name": "パーサー", "description": "File parser (plugin-provided) queries" }, { "name": "ファイル", "description": "File upload operations" }, { "name": "プラグイン", "description": "Plugin installation, configuration, and management" }, { "name": "システム", "description": "System information (no auth required)" } ], "security": [ { "ApiKeyAuth": [] }, { "BearerAuth": [] } ], "paths": { "/api/v1/system/info": { "get": { "tags": [ "System" ], "summary": "获取系统信息", "description": "获取 LangBot 实例的版本、版本类型等基本信息。此接口无需认证。", "security": [], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "version": { "type": "string", "example": "v4.9.5" }, "debug": { "type": "boolean" }, "edition": { "type": "string", "example": "community" }, "enable_marketplace": { "type": "boolean" }, "cloud_service_url": { "type": "string" }, "allow_modify_login_info": { "type": "boolean" }, "disable_models_service": { "type": "boolean" }, "limitation": { "type": "object" }, "wizard_status": { "type": "string", "enum": [ "none", "skipped", "completed" ] }, "wizard_progress": { "type": "object", "nullable": true } } } } } } } } } } }, "/api/v1/provider/providers": { "get": { "tags": [ "Model Providers" ], "summary": "获取所有供应商", "description": "获取所有模型供应商列表,包含每个供应商关联的 LLM 和 Embedding 模型数量。", "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "providers": { "type": "array", "items": { "$ref": "#/components/schemas/ModelProvider" } } } } } } } } } } }, "post": { "tags": [ "Model Providers" ], "summary": "创建供应商", "description": "创建一个新的模型供应商。", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ModelProviderCreate" } } } }, "responses": { "200": { "description": "创建成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } } } } } } } }, "/api/v1/provider/providers/{provider_uuid}": { "get": { "tags": [ "Model Providers" ], "summary": "获取单个供应商", "parameters": [ { "name": "provider_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "provider": { "$ref": "#/components/schemas/ModelProvider" } } } } } } } }, "404": { "$ref": "#/components/responses/NotFound" } } }, "put": { "tags": [ "Model Providers" ], "summary": "更新供应商", "parameters": [ { "name": "provider_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ModelProviderUpdate" } } } }, "responses": { "200": { "$ref": "#/components/responses/Success" } } }, "delete": { "tags": [ "Model Providers" ], "summary": "删除供应商", "description": "删除供应商。如果还有模型引用该供应商,则无法删除。", "parameters": [ { "name": "provider_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "$ref": "#/components/responses/Success" }, "400": { "description": "供应商仍有模型引用,无法删除", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } } }, "/api/v1/provider/models/llm": { "get": { "tags": [ "LLM Models" ], "summary": "获取所有 LLM 模型", "description": "获取所有大语言模型列表。可通过 provider_uuid 过滤特定供应商的模型。", "parameters": [ { "name": "provider_uuid", "in": "query", "required": false, "schema": { "type": "string", "format": "uuid" }, "description": "按供应商 UUID 过滤" } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "models": { "type": "array", "items": { "$ref": "#/components/schemas/LLMModel" } } } } } } } } } } }, "post": { "tags": [ "LLM Models" ], "summary": "创建 LLM 模型", "description": "创建一个新的大语言模型。模型必须关联到一个已存在的供应商。", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LLMModelCreate" } } } }, "responses": { "200": { "description": "创建成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } } } } } } } }, "/api/v1/provider/models/llm/{model_uuid}": { "get": { "tags": [ "LLM Models" ], "summary": "获取单个 LLM 模型", "parameters": [ { "name": "model_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "model": { "$ref": "#/components/schemas/LLMModel" } } } } } } } }, "404": { "$ref": "#/components/responses/NotFound" } } }, "put": { "tags": [ "LLM Models" ], "summary": "更新 LLM 模型", "parameters": [ { "name": "model_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LLMModelUpdate" } } } }, "responses": { "200": { "$ref": "#/components/responses/Success" } } }, "delete": { "tags": [ "LLM Models" ], "summary": "删除 LLM 模型", "parameters": [ { "name": "model_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "$ref": "#/components/responses/Success" } } } }, "/api/v1/provider/models/llm/{model_uuid}/test": { "post": { "tags": [ "LLM Models" ], "summary": "测试 LLM 模型", "description": "向指定的 LLM 模型发送测试请求,验证模型是否可用。", "parameters": [ { "name": "model_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "prompt": { "type": "string", "description": "测试用的提示文本", "example": "Hello" } } } } } }, "responses": { "200": { "$ref": "#/components/responses/Success" } } } }, "/api/v1/provider/models/embedding": { "get": { "tags": [ "Embedding Models" ], "summary": "获取所有向量模型", "description": "获取所有向量模型列表。可通过 provider_uuid 过滤特定供应商的模型。", "parameters": [ { "name": "provider_uuid", "in": "query", "required": false, "schema": { "type": "string", "format": "uuid" }, "description": "按供应商 UUID 过滤" } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "models": { "type": "array", "items": { "$ref": "#/components/schemas/EmbeddingModel" } } } } } } } } } } }, "post": { "tags": [ "Embedding Models" ], "summary": "创建向量模型", "description": "创建一个新的向量模型。模型必须关联到一个已存在的供应商。", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/EmbeddingModelCreate" } } } }, "responses": { "200": { "description": "创建成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } } } } } } } }, "/api/v1/provider/models/embedding/{model_uuid}": { "get": { "tags": [ "Embedding Models" ], "summary": "获取单个向量模型", "parameters": [ { "name": "model_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "model": { "$ref": "#/components/schemas/EmbeddingModel" } } } } } } } }, "404": { "$ref": "#/components/responses/NotFound" } } }, "put": { "tags": [ "Embedding Models" ], "summary": "更新向量模型", "parameters": [ { "name": "model_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/EmbeddingModelUpdate" } } } }, "responses": { "200": { "$ref": "#/components/responses/Success" } } }, "delete": { "tags": [ "Embedding Models" ], "summary": "删除向量模型", "parameters": [ { "name": "model_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "$ref": "#/components/responses/Success" } } } }, "/api/v1/provider/models/embedding/{model_uuid}/test": { "post": { "tags": [ "Embedding Models" ], "summary": "测试向量模型", "description": "向指定的向量模型发送测试请求,验证模型是否可用。", "parameters": [ { "name": "model_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "text": { "type": "string", "description": "测试用的文本", "example": "Hello" } } } } } }, "responses": { "200": { "$ref": "#/components/responses/Success" } } } }, "/api/v1/platform/bots": { "get": { "tags": [ "Bots" ], "summary": "获取所有机器人", "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "bots": { "type": "array", "items": { "$ref": "#/components/schemas/Bot" } } } } } } } } } } }, "post": { "tags": [ "Bots" ], "summary": "创建机器人", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/BotCreate" } } } }, "responses": { "200": { "description": "创建成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } } } } } } } }, "/api/v1/platform/bots/{bot_uuid}": { "get": { "tags": [ "Bots" ], "summary": "获取单个机器人", "description": "获取机器人信息,包括运行时信息(如 Webhook 地址等)。", "parameters": [ { "name": "bot_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "bot": { "$ref": "#/components/schemas/Bot" } } } } } } } }, "404": { "$ref": "#/components/responses/NotFound" } } }, "put": { "tags": [ "Bots" ], "summary": "更新机器人", "parameters": [ { "name": "bot_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/BotUpdate" } } } }, "responses": { "200": { "$ref": "#/components/responses/Success" } } }, "delete": { "tags": [ "Bots" ], "summary": "删除机器人", "parameters": [ { "name": "bot_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "$ref": "#/components/responses/Success" } } } }, "/api/v1/platform/bots/{bot_uuid}/logs": { "post": { "tags": [ "Bots" ], "summary": "获取机器人事件日志", "description": "获取指定机器人的事件日志记录。", "parameters": [ { "name": "bot_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "from_index": { "type": "integer", "description": "起始索引(-1 表示从最新开始)", "default": -1 }, "max_count": { "type": "integer", "description": "最大返回数量", "default": 10 } } } } } }, "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "logs": { "type": "array", "items": { "type": "object" } }, "total_count": { "type": "integer" } } } } } } } } } } }, "/api/v1/platform/bots/{bot_uuid}/send_message": { "post": { "tags": [ "Bots" ], "summary": "通过机器人发送消息", "description": "通过指定的机器人向目标发送消息。仅支持 API Key 认证。", "security": [ { "ApiKeyAuth": [] } ], "parameters": [ { "name": "bot_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "target_type", "target_id", "message_chain" ], "properties": { "target_type": { "type": "string", "enum": [ "person", "group" ], "description": "目标类型" }, "target_id": { "type": "string", "description": "目标 ID(用户 ID 或群组 ID)" }, "message_chain": { "type": "array", "description": "消息链", "items": { "type": "object", "properties": { "type": { "type": "string", "enum": [ "Plain", "Image", "At", "Voice" ], "description": "消息元素类型" }, "text": { "type": "string", "description": "文本内容(Plain 类型)" }, "url": { "type": "string", "description": "图片 URL(Image 类型)" }, "target": { "type": "string", "description": "@ 的目标 ID(At 类型)" } } }, "example": [ { "type": "Plain", "text": "Hello, World!" } ] } } } } } }, "responses": { "200": { "description": "发送成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "sent": { "type": "boolean", "example": true } } } } } } } }, "400": { "description": "参数错误", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } } }, "/api/v1/pipelines": { "get": { "tags": [ "Pipelines" ], "summary": "获取所有流水线", "parameters": [ { "name": "sort_by", "in": "query", "required": false, "schema": { "type": "string", "default": "created_at" } }, { "name": "sort_order", "in": "query", "required": false, "schema": { "type": "string", "enum": [ "ASC", "DESC" ], "default": "DESC" } } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "pipelines": { "type": "array", "items": { "$ref": "#/components/schemas/Pipeline" } } } } } } } } } } }, "post": { "tags": [ "Pipelines" ], "summary": "创建流水线", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PipelineCreate" } } } }, "responses": { "200": { "description": "创建成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } } } } } } } }, "/api/v1/pipelines/_/metadata": { "get": { "tags": [ "Pipelines" ], "summary": "获取流水线元数据", "description": "获取流水线配置的元数据描述,包括可配置的字段和类型信息。", "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "configs": { "type": "object" } } } } } } } } } } }, "/api/v1/pipelines/{pipeline_uuid}": { "get": { "tags": [ "Pipelines" ], "summary": "获取单个流水线", "parameters": [ { "name": "pipeline_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "pipeline": { "$ref": "#/components/schemas/Pipeline" } } } } } } } }, "404": { "$ref": "#/components/responses/NotFound" } } }, "put": { "tags": [ "Pipelines" ], "summary": "更新流水线", "parameters": [ { "name": "pipeline_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PipelineUpdate" } } } }, "responses": { "200": { "$ref": "#/components/responses/Success" } } }, "delete": { "tags": [ "Pipelines" ], "summary": "删除流水线", "parameters": [ { "name": "pipeline_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "$ref": "#/components/responses/Success" } } } }, "/api/v1/pipelines/{pipeline_uuid}/copy": { "post": { "tags": [ "Pipelines" ], "summary": "复制流水线", "description": "复制一个已有的流水线,生成一个新的副本。", "parameters": [ { "name": "pipeline_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "复制成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } } } } }, "404": { "$ref": "#/components/responses/NotFound" } } } }, "/api/v1/pipelines/{pipeline_uuid}/extensions": { "get": { "tags": [ "Pipelines" ], "summary": "获取流水线扩展配置", "description": "获取流水线绑定的插件和 MCP 服务器配置。", "parameters": [ { "name": "pipeline_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "enable_all_plugins": { "type": "boolean" }, "enable_all_mcp_servers": { "type": "boolean" }, "bound_plugins": { "type": "array", "items": { "type": "string" } }, "available_plugins": { "type": "array", "items": { "type": "object" } }, "bound_mcp_servers": { "type": "array", "items": { "type": "string" } }, "available_mcp_servers": { "type": "array", "items": { "type": "object" } } } } } } } } }, "404": { "$ref": "#/components/responses/NotFound" } } }, "put": { "tags": [ "Pipelines" ], "summary": "更新流水线扩展配置", "description": "更新流水线绑定的插件和 MCP 服务器。", "parameters": [ { "name": "pipeline_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "enable_all_plugins": { "type": "boolean", "default": true }, "enable_all_mcp_servers": { "type": "boolean", "default": true }, "bound_plugins": { "type": "array", "items": { "type": "string" } }, "bound_mcp_servers": { "type": "array", "items": { "type": "string" } } } } } } }, "responses": { "200": { "$ref": "#/components/responses/Success" } } } }, "/api/v1/knowledge/bases": { "get": { "tags": [ "Knowledge Bases" ], "summary": "获取所有知识库", "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "bases": { "type": "array", "items": { "type": "object" } } } } } } } } } } }, "post": { "tags": [ "Knowledge Bases" ], "summary": "创建知识库", "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "name" ], "properties": { "name": { "type": "string" }, "description": { "type": "string" }, "engine_plugin_id": { "type": "string", "description": "知识引擎插件 ID(author/name 格式)" }, "creation_settings": { "type": "object", "description": "引擎创建参数" } } } } } }, "responses": { "200": { "description": "创建成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" } } } } } } } } } } }, "/api/v1/knowledge/bases/{kb_uuid}": { "get": { "tags": [ "Knowledge Bases" ], "summary": "获取单个知识库", "parameters": [ { "name": "kb_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "base": { "type": "object" } } } } } } } }, "404": { "$ref": "#/components/responses/NotFound" } } }, "put": { "tags": [ "Knowledge Bases" ], "summary": "更新知识库", "parameters": [ { "name": "kb_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string" }, "description": { "type": "string" } } } } } }, "responses": { "200": { "$ref": "#/components/responses/Success" } } }, "delete": { "tags": [ "Knowledge Bases" ], "summary": "删除知识库", "parameters": [ { "name": "kb_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "$ref": "#/components/responses/Success" } } } }, "/api/v1/knowledge/bases/{kb_uuid}/files": { "get": { "tags": [ "Knowledge Bases" ], "summary": "获取知识库文件列表", "parameters": [ { "name": "kb_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "files": { "type": "array", "items": { "type": "object" } } } } } } } } } } }, "post": { "tags": [ "Knowledge Bases" ], "summary": "将文件存入知识库", "description": "将已上传的文件关联到知识库并开始解析。先通过 /api/v1/files/documents 上传文件获取 file_id。", "parameters": [ { "name": "kb_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "file_id" ], "properties": { "file_id": { "type": "string", "description": "已上传的文件 ID" }, "parser_plugin_id": { "type": "string", "description": "指定的解析器插件 ID(可选)" } } } } } }, "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "task_id": { "type": "string" } } } } } } } } } } }, "/api/v1/knowledge/bases/{kb_uuid}/files/{file_id}": { "delete": { "tags": [ "Knowledge Bases" ], "summary": "从知识库删除文件", "parameters": [ { "name": "kb_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }, { "name": "file_id", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "$ref": "#/components/responses/Success" } } } }, "/api/v1/knowledge/bases/{kb_uuid}/retrieve": { "post": { "tags": [ "Knowledge Bases" ], "summary": "检索知识库", "description": "对知识库进行语义检索,返回相关文档片段。", "parameters": [ { "name": "kb_uuid", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "query" ], "properties": { "query": { "type": "string", "description": "检索查询文本" }, "retrieval_settings": { "type": "object", "description": "检索参数(如 top_k 等)", "properties": { "top_k": { "type": "integer" } } } } } } } }, "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "results": { "type": "array", "items": { "type": "object" } } } } } } } } } } } }, "/api/v1/knowledge/engines": { "get": { "tags": [ "Knowledge Engines" ], "summary": "获取可用知识引擎列表", "description": "列出所有由插件提供的知识引擎,包含其能力和配置模式。", "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "engines": { "type": "array", "items": { "type": "object" } } } } } } } } } } } }, "/api/v1/knowledge/engines/{plugin_id}/creation-schema": { "get": { "tags": [ "Knowledge Engines" ], "summary": "获取知识引擎创建配置模式", "description": "获取指定知识引擎的创建参数 JSON Schema。", "parameters": [ { "name": "plugin_id", "in": "path", "required": true, "schema": { "type": "string" }, "description": "插件 ID(author/name 格式)" } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "schema": { "type": "object" } } } } } } } } } } }, "/api/v1/knowledge/engines/{plugin_id}/retrieval-schema": { "get": { "tags": [ "Knowledge Engines" ], "summary": "获取知识引擎检索配置模式", "description": "获取指定知识引擎的检索参数 JSON Schema。", "parameters": [ { "name": "plugin_id", "in": "path", "required": true, "schema": { "type": "string" }, "description": "插件 ID(author/name 格式)" } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "schema": { "type": "object" } } } } } } } } } } }, "/api/v1/knowledge/parsers": { "get": { "tags": [ "Parsers" ], "summary": "获取可用解析器列表", "description": "列出所有由插件提供的文件解析器。可通过 mime_type 过滤。", "parameters": [ { "name": "mime_type", "in": "query", "required": false, "schema": { "type": "string" }, "description": "按 MIME 类型过滤解析器" } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "parsers": { "type": "array", "items": { "type": "object" } } } } } } } } } } } }, "/api/v1/files/images": { "post": { "tags": [ "Files" ], "summary": "上传图片", "description": "上传图片文件,支持 jpg、jpeg、png、gif、webp 格式,大小限制 10MB。", "requestBody": { "required": true, "content": { "multipart/form-data": { "schema": { "type": "object", "required": [ "file" ], "properties": { "file": { "type": "string", "format": "binary", "description": "图片文件" } } } } } }, "responses": { "200": { "description": "上传成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "file_key": { "type": "string", "description": "文件标识符,可用于引用图片" } } } } } } } } } } }, "/api/v1/files/documents": { "post": { "tags": [ "Files" ], "summary": "上传文档", "description": "上传文档文件,大小限制 10MB。上传后可将 file_id 用于知识库关联。", "requestBody": { "required": true, "content": { "multipart/form-data": { "schema": { "type": "object", "required": [ "file" ], "properties": { "file": { "type": "string", "format": "binary", "description": "文档文件" } } } } } }, "responses": { "200": { "description": "上传成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "file_id": { "type": "string", "description": "文件 ID,可用于知识库关联" } } } } } } } } } } }, "/api/v1/plugins": { "get": { "tags": [ "Plugins" ], "summary": "获取已安装插件列表", "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "plugins": { "type": "array", "items": { "type": "object" } } } } } } } } } } } }, "/api/v1/plugins/{author}/{plugin_name}": { "get": { "tags": [ "Plugins" ], "summary": "获取插件详情", "parameters": [ { "name": "author", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "plugin_name", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "plugin": { "type": "object" } } } } } } } }, "404": { "$ref": "#/components/responses/NotFound" } } }, "delete": { "tags": [ "Plugins" ], "summary": "删除插件", "description": "异步删除插件,返回任务 ID。", "parameters": [ { "name": "author", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "plugin_name", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "delete_data", "in": "query", "required": false, "schema": { "type": "boolean", "default": false }, "description": "是否同时删除插件数据" } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "task_id": { "type": "integer" } } } } } } } } } } }, "/api/v1/plugins/{author}/{plugin_name}/upgrade": { "post": { "tags": [ "Plugins" ], "summary": "升级插件", "description": "异步升级插件到最新版本,返回任务 ID。", "parameters": [ { "name": "author", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "plugin_name", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "task_id": { "type": "integer" } } } } } } } } } } }, "/api/v1/plugins/{author}/{plugin_name}/config": { "get": { "tags": [ "Plugins" ], "summary": "获取插件配置", "description": "获取插件的当前配置值和配置模式。", "parameters": [ { "name": "author", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "plugin_name", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object" } } } } } } } }, "put": { "tags": [ "Plugins" ], "summary": "更新插件配置", "parameters": [ { "name": "author", "in": "path", "required": true, "schema": { "type": "string" } }, { "name": "plugin_name", "in": "path", "required": true, "schema": { "type": "string" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "description": "插件配置键值对" } } } }, "responses": { "200": { "$ref": "#/components/responses/Success" } } } }, "/api/v1/plugins/install/marketplace": { "post": { "tags": [ "Plugins" ], "summary": "从 Marketplace 安装插件", "description": "从 LangBot Marketplace 安装插件。异步操作,返回任务 ID。", "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "plugin_id" ], "properties": { "plugin_id": { "type": "string", "description": "Marketplace 插件 ID(author/name 格式)", "example": "kellz-dev/disaster-alert" } } } } } }, "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "task_id": { "type": "integer" } } } } } } } } } } }, "/api/v1/plugins/install/github": { "post": { "tags": [ "Plugins" ], "summary": "从 GitHub 安装插件", "description": "从 GitHub 仓库安装插件。异步操作,返回任务 ID。", "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": [ "url" ], "properties": { "url": { "type": "string", "description": "GitHub 仓库 URL", "example": "https://github.com/rocksclawbot/langbot-community-plugins/tree/main/disaster-alert" } } } } } }, "responses": { "200": { "description": "成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "data": { "type": "object", "properties": { "task_id": { "type": "integer" } } } } } } } } } } }, "/api/v1/tools": { "get": { "tags": [ "ツール" ], "summary": "利用可能なツール一覧を取得", "description": "現在の LangBot インスタンスで利用可能なすべてのツール(プラグインツールおよび MCP ツール)を取得します。", "operationId": "listTools", "security": [ { "BearerAuth": [] } ], "responses": { "200": { "description": "Success", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "msg": { "type": "string", "example": "ok" }, "data": { "type": "object", "properties": { "tools": { "type": "array", "items": { "$ref": "#/components/schemas/ToolSummary" } } } } } } } } } } } }, "/api/v1/tools/{tool_name}": { "get": { "tags": [ "ツール" ], "summary": "ツール詳細を取得", "description": "指定されたツールの詳細情報を取得します。", "operationId": "getToolDetail", "security": [ { "BearerAuth": [] } ], "parameters": [ { "name": "tool_name", "in": "path", "required": true, "schema": { "type": "string" }, "description": "ツール名" } ], "responses": { "200": { "description": "Success", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 }, "msg": { "type": "string", "example": "ok" }, "data": { "type": "object", "properties": { "tool": { "$ref": "#/components/schemas/ToolSummary" } } } } } } } }, "404": { "description": "Tool not found" } } } } }, "components": { "securitySchemes": { "ApiKeyAuth": { "type": "apiKey", "in": "header", "name": "X-API-Key" }, "BearerAuth": { "type": "http", "scheme": "bearer" } }, "schemas": { "ModelProvider": { "type": "object", "description": "模型供应商。定义了 API 地址和密钥,模型通过 provider_uuid 关联。", "properties": { "uuid": { "type": "string", "format": "uuid" }, "name": { "type": "string", "example": "OpenAI" }, "requester": { "type": "string", "description": "请求器类型", "example": "openai-chat-completions" }, "base_url": { "type": "string", "description": "API 基础地址", "example": "https://api.openai.com/v1" }, "api_keys": { "type": "array", "description": "API 密钥列表", "items": { "type": "string" } }, "llm_count": { "type": "integer", "description": "关联的 LLM 模型数量" }, "embedding_count": { "type": "integer", "description": "关联的 Embedding 模型数量" }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" } } }, "ModelProviderCreate": { "type": "object", "required": [ "name", "requester", "base_url" ], "properties": { "name": { "type": "string", "example": "OpenAI" }, "requester": { "type": "string", "description": "请求器类型。可通过 GET /api/v1/provider/requesters 获取可用列表。", "example": "openai-chat-completions" }, "base_url": { "type": "string", "example": "https://api.openai.com/v1" }, "api_keys": { "type": "array", "items": { "type": "string" }, "example": [ "sk-xxx" ] } } }, "ModelProviderUpdate": { "type": "object", "properties": { "name": { "type": "string" }, "requester": { "type": "string" }, "base_url": { "type": "string" }, "api_keys": { "type": "array", "items": { "type": "string" } } } }, "LLMModel": { "type": "object", "description": "大语言模型。通过 provider_uuid 关联到供应商,继承供应商的 API 地址和密钥。", "properties": { "uuid": { "type": "string", "format": "uuid" }, "name": { "type": "string", "description": "模型名称(即模型 ID,发送到 API 的 model 参数值)", "example": "gpt-4o" }, "provider_uuid": { "type": "string", "format": "uuid", "description": "关联的供应商 UUID" }, "abilities": { "type": "array", "items": { "type": "string" }, "description": "模型能力标签", "example": [ "chat", "vision", "tool-use" ] }, "extra_args": { "type": "object", "description": "额外参数(如 temperature、max_tokens 等)" }, "prefered_ranking": { "type": "integer", "description": "优先级排序(越大越优先)", "default": 0 }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" } } }, "LLMModelCreate": { "type": "object", "required": [ "name", "provider_uuid" ], "properties": { "name": { "type": "string", "description": "模型名称(即模型 ID)", "example": "gpt-4o" }, "provider_uuid": { "type": "string", "format": "uuid", "description": "关联的供应商 UUID" }, "abilities": { "type": "array", "items": { "type": "string" }, "example": [ "chat", "vision" ] }, "extra_args": { "type": "object" }, "prefered_ranking": { "type": "integer", "default": 0 } } }, "LLMModelUpdate": { "type": "object", "properties": { "name": { "type": "string" }, "provider_uuid": { "type": "string", "format": "uuid" }, "abilities": { "type": "array", "items": { "type": "string" } }, "extra_args": { "type": "object" }, "prefered_ranking": { "type": "integer" } } }, "EmbeddingModel": { "type": "object", "description": "向量模型。通过 provider_uuid 关联到供应商。", "properties": { "uuid": { "type": "string", "format": "uuid" }, "name": { "type": "string", "description": "模型名称(即模型 ID)", "example": "text-embedding-3-small" }, "provider_uuid": { "type": "string", "format": "uuid", "description": "关联的供应商 UUID" }, "extra_args": { "type": "object" }, "prefered_ranking": { "type": "integer", "default": 0 }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" } } }, "EmbeddingModelCreate": { "type": "object", "required": [ "name", "provider_uuid" ], "properties": { "name": { "type": "string", "example": "text-embedding-3-small" }, "provider_uuid": { "type": "string", "format": "uuid" }, "extra_args": { "type": "object" }, "prefered_ranking": { "type": "integer", "default": 0 } } }, "EmbeddingModelUpdate": { "type": "object", "properties": { "name": { "type": "string" }, "provider_uuid": { "type": "string", "format": "uuid" }, "extra_args": { "type": "object" }, "prefered_ranking": { "type": "integer" } } }, "Bot": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" }, "name": { "type": "string" }, "adapter": { "type": "string", "example": "telegram" }, "config": { "type": "object" }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" } } }, "BotCreate": { "type": "object", "required": [ "name", "adapter", "config" ], "properties": { "name": { "type": "string" }, "adapter": { "type": "string" }, "config": { "type": "object" } } }, "BotUpdate": { "type": "object", "properties": { "name": { "type": "string" }, "adapter": { "type": "string" }, "config": { "type": "object" } } }, "Pipeline": { "type": "object", "properties": { "uuid": { "type": "string", "format": "uuid" }, "name": { "type": "string" }, "config": { "type": "object" }, "is_default": { "type": "boolean" }, "created_at": { "type": "string", "format": "date-time" }, "updated_at": { "type": "string", "format": "date-time" } } }, "PipelineCreate": { "type": "object", "required": [ "name" ], "properties": { "name": { "type": "string" }, "config": { "type": "object" } } }, "PipelineUpdate": { "type": "object", "properties": { "name": { "type": "string" }, "config": { "type": "object" }, "is_default": { "type": "boolean" } } }, "ErrorResponse": { "type": "object", "properties": { "code": { "type": "integer", "example": -1 }, "msg": { "type": "string" } } }, "ToolSummary": { "type": "object", "properties": { "name": { "type": "string", "description": "Tool name" }, "label": { "type": "object", "description": "Display label (i18n)", "additionalProperties": { "type": "string" } }, "description": { "type": "object", "description": "Tool description (i18n)", "additionalProperties": { "type": "string" } }, "icon": { "type": "string", "description": "Tool icon" }, "spec": { "type": "object", "description": "Tool specification", "properties": { "llm_prompt": { "type": "string" }, "parameters": { "type": "object", "description": "JSON Schema for tool parameters" } } } } } }, "responses": { "Success": { "description": "操作成功", "content": { "application/json": { "schema": { "type": "object", "properties": { "code": { "type": "integer", "example": 0 } } } } } }, "NotFound": { "description": "资源未找到", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } } } } } }