Files
X-Agents/team-require/api/model-api.md
2026-03-07 13:54:06 +08:00

4.2 KiB
Raw Blame History

Model Settings 接口文档

接口列表

1. 获取模型列表

接口地址: GET /model/list

返回参数:

{
  "list": [
    {
      "id": "xxx-xxx-xxx",
      "name": "OpenAI",
      "model_type": "chat",
      "provider": "OpenAI",
      "model": "gpt-4o",
      "api_key": "sk-xxx",
      "base_url": "https://api.openai.com",
      "api_endpoint": "/v1/chat/completions",
      "status": "active",
      "created_at": "2024-01-01T00:00:00Z",
      "updated_at": "2024-01-01T00:00:00Z"
    }
  ]
}

2. 获取模型详情

接口地址: GET /model/:id

返回参数:

{
  "id": "xxx-xxx-xxx",
  "name": "OpenAI",
  "model_type": "chat",
  "provider": "OpenAI",
  "model": "gpt-4o",
  "api_key": "sk-xxx",
  "base_url": "https://api.openai.com",
  "api_endpoint": "/v1/chat/completions",
  "status": "active",
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-01-01T00:00:00Z"
}

3. 创建模型

接口地址: POST /model/add

请求参数:

参数 类型 必填 说明
name string 模型名称
model_type string 模型类型chat/embedding/rerank/vlm
provider string 提供商OpenAI/Ollama
model string 模型标识,如 gpt-4o
api_key string API 密钥
base_url string 基础 URL
api_endpoint string API 端点路径

请求示例:

{
  "name": "OpenAI",
  "model_type": "chat",
  "provider": "OpenAI",
  "model": "gpt-4o",
  "api_key": "sk-xxx",
  "base_url": "https://api.openai.com",
  "api_endpoint": "/v1/chat/completions"
}

返回参数:

{
  "id": "xxx-xxx-xxx",
  "name": "OpenAI",
  "model_type": "chat",
  "provider": "OpenAI",
  "model": "gpt-4o",
  "api_key": "sk-xxx",
  "base_url": "https://api.openai.com",
  "api_endpoint": "/v1/chat/completions",
  "status": "active",
  "created_at": "2024-01-01T00:00:00Z",
  "updated_at": "2024-01-01T00:00:00Z"
}

4. 更新模型

接口地址: PUT /model/:id

请求参数:

参数 类型 必填 说明
name string 模型名称
model_type string 模型类型chat/embedding/rerank/vlm
provider string 提供商OpenAI/Ollama
model string 模型标识
api_key string API 密钥
base_url string 基础 URL
api_endpoint string API 端点路径
status string 状态active/inactive

请求示例:

{
  "name": "OpenAI Updated",
  "model_type": "chat",
  "provider": "OpenAI",
  "model": "gpt-4o",
  "api_key": "sk-xxx",
  "base_url": "https://api.openai.com",
  "api_endpoint": "/v1/chat/completions",
  "status": "active"
}

5. 删除模型

接口地址: DELETE /model/:id

返回参数:

{
  "success": true
}

6. 测试连接

接口地址: POST /model/test

请求参数:

参数 类型 必填 说明
provider string 提供商OpenAI/Ollama
model string 模型标识
api_key string API 密钥
base_url string 基础 URL
api_endpoint string API 端点路径

请求示例:

{
  "provider": "OpenAI",
  "model": "gpt-4o",
  "api_key": "sk-xxx",
  "base_url": "https://api.openai.com",
  "api_endpoint": "/v1/chat/completions"
}

返回参数:

{
  "success": true,
  "message": "Connection successful"
}

或失败时:

{
  "success": false,
  "message": "HTTP 401: Unauthorized"
}

数据结构

ModelInfo 模型信息

字段 类型 说明
id string 主键 UUID
name string 模型名称
model_type string 模型类型chat/embedding/rerank/vlm
provider string 提供商OpenAI/Ollama
model string 模型标识
api_key string API 密钥
base_url string 基础 URL
api_endpoint string API 端点路径
status string 状态active/inactive
created_at datetime 创建时间
updated_at datetime 更新时间