Skip to content

查询模型配置列表

接口信息

接口地址:/api/v1/system/model/list

请求方式:GET

请求数据类型:

响应数据类型:*/*

接口描述:

查询全部模型配置列表

请求示例:

GET /api/v1/system/model/list

请求参数

请求头

参数名类型必填描述示例值
AuthorizationstringAPI KeyBearer ak-xxxxeyJhbGciOiJIUzI1NiJ9

响应参数:

参数名称参数说明类型schema
code业务状态码,0000 表示成功,其余失败string
displayCode源系统状态码,用于问题跟踪string
message错误描述信息string
data模型配置列表arrayModelConfigDto
  id模型IDinteger(int64)
  tenantId商户IDinteger(int64)
  spaceId空间IDinteger(int64)
  scope模型生效范围,可用值: Space, Tenant, Globalstring
  name模型名称string
  description模型描述string
  model模型标识string
  type模型类型,可用值: Completions, Chat, Multi, Edits, Images, Embeddings, Audio, Otherstring
  isReasonModel是否为推理模型integer(int32)
  networkType网络类型,可用值: Internet, Intranetstring
  functionCall函数调用支持程度,可用值: Unsupported, CallSupported, StreamCallSupportedstring
  maxTokenstoken上限integer(int32)
  maxContextTokens上下文token上限integer(int32)
  apiProtocol接口协议,可用值: OpenAI, Ollama, Zhipu, Anthropicstring
  apiInfoListAPI列表arrayApiInfo
    url接口地址string
    key接口密钥string
    weight权重integer(int32)
  strategy调用策略,可用值: RoundRobin, WeightedRoundRobin, LeastConnections, WeightedLeastConnections, Random, ResponseTimestring
  dimension向量维度integer(int32)
  modified修改时间string(date-time)
  created创建时间string(date-time)
  creator创建者信息CreatorDto
    userId用户IDinteger(int64)
    userName用户名string
    nickName昵称string
    avatar头像string
  enabled是否启用integer(int32)
  accessControl访问控制,0-不管控,1-管控integer(int32)
  usageScenarios可使用的业务场景arraystring
tid跟踪唯一标识string
successboolean

响应示例:

javascript
{
	"code": "0000",
	"displayCode": "0000",
	"message": "success",
	"data": [
		{
			"id": 1,
			"tenantId": 1,
			"spaceId": null,
			"scope": "Tenant",
			"name": "更新后的GPT-3.5",
			"description": null,
			"model": "gpt-3.5-turbo",
			"type": "Chat",
			"isReasonModel": 0,
			"networkType": "Internet",
			"functionCall": "CallSupported",
			"maxTokens": 4096,
			"maxContextTokens": 128000,
			"apiProtocol": "OpenAI",
			"apiInfoList": [
				{
					"url": "https://api.openai.com/v1",
					"key": "sk-updated-key",
					"weight": 1
				}
			],
			"strategy": "RoundRobin",
			"dimension": 1536,
			"enabled": 1,
			"accessControl": 0,
			"usageScenarios": ["Workflow", "TaskAgent", "PageApp", "ChatBot", "OpenApi"]
		}
	],
	"tid": "123456",
	"success": true
}

CURL示例

shell
curl 'http://127.0.0.1:8081/api/v1/system/model/list' \
  -H 'Authorization: Bearer ak-d1f2129c4ba24629b8448af3354f9dd0'

{"code":"0000","displayCode":"0000","message":"success","data":[...],"tid":"123456","success":true}

测试用例

#场景状态码结果
1查询模型列表0000成功,返回全部模型配置

TS模板示例

ts
// API信息
export interface ApiInfo {
  url: string;
  key: string;
  weight: number;
}

// 创建者信息
export interface CreatorDto {
  userId: number;
  userName: string;
  nickName: string;
  avatar: string;
}

// 模型配置
export interface ModelConfigDto {
  id: number;
  tenantId: number;
  spaceId: number | null;
  scope: 'Space' | 'Tenant' | 'Global';
  name: string;
  description: string | null;
  model: string;
  type: 'Completions' | 'Chat' | 'Multi' | 'Edits' | 'Images' | 'Embeddings' | 'Audio' | 'Other';
  isReasonModel: number;
  networkType: 'Internet' | 'Intranet';
  functionCall: 'Unsupported' | 'CallSupported' | 'StreamCallSupported';
  maxTokens: number;
  maxContextTokens: number;
  apiProtocol: 'OpenAI' | 'Ollama' | 'Zhipu' | 'Anthropic';
  apiInfoList: ApiInfo[];
  strategy: 'RoundRobin' | 'WeightedRoundRobin' | 'LeastConnections' | 'WeightedLeastConnections' | 'Random' | 'ResponseTime';
  dimension: number;
  modified: string;
  created: string;
  creator: CreatorDto;
  enabled: number;
  accessControl: number;
  usageScenarios: ('PageApp' | 'TaskAgent' | 'ChatBot' | 'Workflow' | 'OpenApi')[];
}

// 响应接口
export interface ModelListRes {
  code: string;
  displayCode: string;
  message: string;
  data: ModelConfigDto[];
  tid: string;
  success: boolean;
}

/** 
 * 查询模型配置列表
 * @returns
 */
export function getModelList(): Promise<ModelListRes> {
  return request.get(`/api/v1/system/model/list`);
}