Skip to content

查询空间可使用模型列表

接口信息

接口地址:/api/v1/space/{spaceId}/model/list

请求方式:GET

请求数据类型:

响应数据类型:*/*

接口描述:

查询指定空间中可使用的模型配置列表

请求示例:

GET /api/v1/space/1071/model/list

请求参数

请求头

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

路径参数:

参数名称参数说明是否必须数据类型
spaceId空间IDinteger(int64)

响应参数:

参数名称参数说明类型schema
code业务状态码,0000 表示成功,其余失败string
displayCode源系统状态码,用于问题跟踪string
message错误描述信息string
data模型配置列表arrayModelConfigDto
  id模型IDinteger(int64)
  tenantId租户IDinteger(int64)
  spaceId空间IDinteger(int64)
  creatorId创建者IDinteger(int64)
  scope模型生效范围,可用值: Space, Tenant, Globalstring
  name模型名称string
  description模型描述string
  model模型标识string
  type模型类型,可用值: Completions, Chat, Multi, Edits, Images, Embeddings, Audio, Otherstring
  isReasonModel是否为推理模型,0 否;1 是integer(int32)
  networkType网络类型,可用值: Internet, Intranetstring
  functionCall函数调用支持,可用值: Unsupported, CallSupported, StreamCallSupportedstring
  maxTokens最大输出token数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创建者信息objectCreatorDto
    userId用户IDinteger(int64)
    userName用户名string
    nickName昵称string
    avatar头像string
  enabled是否启用,1-启用,0-禁用integer(int32)
  accessControl访问控制,0-不管控,1-管控integer(int32)
  usageScenarios可使用的业务场景,可用值: PageApp, TaskAgent, ChatBot, Workflow, OpenApiarray
tid跟踪唯一标识string
successboolean

响应示例:

javascript
{
	"code": "0000",
	"displayCode": "0000",
	"message": "success",
	"data": [
		{
			"id": 100000006,
			"tenantId": 1,
			"spaceId": 1071,
			"creatorId": 1,
			"scope": "Space",
			"name": "更新后的空间测试模型",
			"description": null,
			"model": "gpt-3.5-turbo-space",
			"type": "Chat",
			"isReasonModel": 0,
			"networkType": "Internet",
			"natInfoList": null,
			"functionCall": "CallSupported",
			"temperature": null,
			"topP": null,
			"maxTokens": 4096,
			"maxContextTokens": 128000,
			"apiProtocol": "OpenAI",
			"apiInfoList": null,
			"strategy": "WeightedRoundRobin",
			"dimension": 1536,
			"modified": "2026-04-13T12:34:24.000+00:00",
			"created": "2026-04-13T12:30:21.000+00:00",
			"creator": {
				"userId": 1,
				"userName": "fei",
				"nickName": "冯飞",
				"avatar": "https://agent-1251073634.cos.ap-chengdu.myqcloud.com/store/8698c0ff6c814ca3b477c4380b0efa5f.jpeg"
			},
			"enabled": 1,
			"accessControl": 0,
			"usageScenarios": ["Workflow", "TaskAgent", "PageApp", "ChatBot", "OpenApi"]
		}
	],
	"tid": "5734681776084510940",
	"success": true
}

CURL示例

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

{"code":"0000","displayCode":"0000","message":"success","data":[{"id":100000006,"tenantId":1,...}],"tid":"5734681776084510940","success":true}

测试用例

#场景状态码结果
1查询空间的模型列表0000成功,返回该空间中所有模型配置

TS模板示例

ts
// API信息
export interface ApiInfo {
  /* 接口地址 */
  url: string;
  /* 接口密钥 */
  key: string;
  /* 权重 */
  weight: number;
}

// 创建者信息
export interface CreatorDto {
  /* 用户ID */
  userId: number;
  /* 用户名 */
  userName: string;
  /* 昵称 */
  nickName: string;
  /* 头像 */
  avatar: string;
}

// 模型配置详情
export interface ModelConfigDto {
  /* 模型ID */
  id: number;
  /* 租户ID */
  tenantId: number;
  /* 空间ID */
  spaceId: number;
  /* 创建者ID */
  creatorId: number;
  /* 模型生效范围: Space, Tenant, Global */
  scope: 'Space' | 'Tenant' | 'Global';
  /* 模型名称 */
  name: string;
  /* 模型描述 */
  description: string | null;
  /* 模型标识 */
  model: string;
  /* 模型类型 */
  type: 'Completions' | 'Chat' | 'Multi' | 'Edits' | 'Images' | 'Embeddings' | 'Audio' | 'Other';
  /* 是否为推理模型 */
  isReasonModel: number;
  /* 网络类型: Internet, Intranet */
  networkType: 'Internet' | 'Intranet';
  /* 内网信息列表 */
  natInfoList: unknown[] | null;
  /* 函数调用支持 */
  functionCall: 'Unsupported' | 'CallSupported' | 'StreamCallSupported';
  /* 温度参数 */
  temperature: unknown | null;
  /* topP参数 */
  topP: unknown | null;
  /* 最大输出token数 */
  maxTokens: number;
  /* 上下文最大token数 */
  maxContextTokens: number;
  /* 接口协议 */
  apiProtocol: 'OpenAI' | 'Ollama' | 'Zhipu' | 'Anthropic';
  /* API列表 */
  apiInfoList: ApiInfo[] | null;
  /* 调用策略 */
  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 SpaceModelListRes {
  code: string;
  displayCode: string;
  message: string;
  data: ModelConfigDto[];
  tid: string;
  success: boolean;
}

/** 
 * 查询空间可使用模型列表
 * @param {number} spaceId - 空间ID
 * @returns
 */
export function getSpaceModelList(spaceId: number): Promise<SpaceModelListRes> {
  return request.get(`/api/v1/space/${spaceId}/model/list`);
}