项目管理 API
项目、项目路由、项目模型和项目 API Key 的管理接口。
项目管理 API
接口参考待联调:当前控制台通过 GET /modelrouter/list/byoks 获取模型,旧接口资料记录为 POST;创建字段必填性、成员与 Key 的返回范围也待核准。 以下是待核对的接口资料,不作为可直接接入的正式示例。控制台操作请按对应使用指南完成。
概述
项目管理API用于创建和管理企业网关项目,配置项目的路由、模型和团队成员。每个项目都有独立的配置和API Token。
基础信息
- Base URL:
YOUR_GATEWAY_MANAGEMENT_BASE_URL - 认证方式: AccessKey/SecretKey签名 或 JWT Token
- 请求格式: JSON
- 响应格式: JSON
权限说明
| 操作 | 主账号 | RAM管理员 | RAM成员-Manager | RAM成员-Viewer |
|---|---|---|---|---|
| 创建项目 | ✅ | ✅ | ❌ | ❌ |
| 查看项目列表 | ✅ | ✅ | ✅ | ✅ |
| 删除项目 | ✅ | ✅ | ✅ (自己项目的manager) | ❌ |
| 编辑项目 | ✅ | ✅ | ✅ (自己项目的manager) | ❌ |
| 管理路由 | ✅ | ✅ | ✅ (项目manager) | ❌ |
| 查看路由 | ✅ | ✅ | ✅ (项目manager/viewer) | ✅ |
| 管理模型 | ✅ | ✅ | ✅ (项目manager) | ❌ |
| 查看模型 | ✅ | ✅ | ✅ (项目manager/viewer) | ✅ |
| 生成API Token | ✅ | ✅ | ✅ (项目manager/viewer) | ✅ |
| 管理成员 | ✅ | ✅ | ✅ (项目manager) | ❌ |
API接口列表
1. 获取项目列表
查询用户有权访问的项目列表。
接口信息
- Path:
/project/list - Method:
GET - 权限: 所有用户
请求参数(Query参数)
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| project_name | string | 否 | 项目名称 | xxxxxx |
| status | string | 否 | 项目状态 (active, expired) | active |
| role | string | 否 | 项目角色 (manager, viewer) | manager |
请求示例
GET /project/list
X-Access-Key-Id: AK_xxx
X-Timestamp: 2024-01-01T12:00:00+00:00
X-Signature: xxx
响应示例
{
"code": 0,
"data": [
{
"id": 35,
"mainUserName": "lichaowei",
"projectName": "虚构示例项目 A",
"projectTime": [
"2025-12-17",
"2026-01-17"
],
"teamMembers": [
{
"id": 2,
"name": "junior_li_test",
"roleId": 13,
"role": "有限制只查看",
"type": "member"
},
{
"id": 16,
"name": "lcw",
"roleId": 5,
"role": "无限制管理员",
"type": "member"
}
],
"selectedModels": [
{
"id": 24,
"name": "anthropic/claude-3-7-sonnet-official",
"type": "",
"inputPrice": 0,
"outputPrice": 0,
"provider": "Anthropic",
"supportModelId": 0,
"icon": ""
},
{
"id": 1,
"name": "deepseek/deepseek-r1",
"type": "",
"inputPrice": 40000,
"outputPrice": 160000,
"provider": "DeepSeek",
"supportModelId": 0,
"icon": ""
},
{
"id": 3,
"name": "deepseek/deepseek-v3",
"type": "",
"inputPrice": 5100,
"outputPrice": 8900,
"provider": "DeepSeek",
"supportModelId": 0,
"icon": ""
},
{
"id": 22,
"name": "anthropic/claude-3-7-sonnet-vertex",
"type": "",
"inputPrice": 12500,
"outputPrice": 100000,
"provider": "Anthropic",
"supportModelId": 0,
"icon": ""
},
{
"id": 92,
"name": "google/gemini-3-pro-image-preview",
"type": "",
"inputPrice": 50000,
"outputPrice": 90000,
"provider": "Google",
"supportModelId": 0,
"icon": ""
},
{
"id": 101,
"name": "deepseek/deepseek-v3.2",
"type": "",
"inputPrice": 20000,
"outputPrice": 30000,
"provider": "DeepSeek",
"supportModelId": 0,
"icon": ""
},
{
"id": 104,
"name": "deepseek/deepseek-v3.2",
"type": "",
"inputPrice": 20000,
"outputPrice": 40000,
"provider": "DeepSeek",
"supportModelId": 0,
"icon": ""
}
],
"routerConfigs": [
{
"id": 0,
"name": "负载均衡",
"mode": "loadBalance",
"models": [
{
"id": 168,
"model": "qwen/qwen-plus",
"weight": 10
},
{
"id": 168,
"model": "qwen/qvq-72b",
"weight": 10
},
{
"id": 168,
"model": "qwen/qwen-vl-plus",
"weight": 80
}
],
"isConfirmed": false,
"routeId": "",
"strategies": null
},
{
"id": 0,
"name": "故障转移测试",
"mode": "failover",
"models": [
{
"id": 169,
"model": "qwen/qwen-plus",
"weight": 0
},
{
"id": 169,
"model": "qwen/qvq-72b",
"weight": 0
}
],
"isConfirmed": false,
"routeId": "",
"strategies": null
}
]
},
{
"id": 36,
"mainUserName": "lichaowei",
"projectName": "虚构示例项目 B",
"projectTime": [
"2025-12-19",
"2026-01-19"
],
"teamMembers": [
{
"id": 3,
"name": "junior_lichaowei",
"roleId": 5,
"role": "无限制管理员",
"type": "member"
},
{
"id": 16,
"name": "lcw",
"roleId": 11,
"role": "有限制管理员",
"type": "member"
}
],
"selectedModels": [
{
"id": 1,
"name": "deepseek/deepseek-r1",
"type": "",
"inputPrice": 40000,
"outputPrice": 160000,
"provider": "DeepSeek",
"supportModelId": 0,
"icon": ""
},
{
"id": 3,
"name": "deepseek/deepseek-v3",
"type": "",
"inputPrice": 5100,
"outputPrice": 8900,
"provider": "DeepSeek",
"supportModelId": 0,
"icon": ""
},
{
"id": 44,
"name": "google/gemini-2.5-flash-image",
"type": "",
"inputPrice": 50000,
"outputPrice": 90000,
"provider": "Google",
"supportModelId": 0,
"icon": ""
},
{
"id": 92,
"name": "google/gemini-3-pro-image-preview",
"type": "",
"inputPrice": 50000,
"outputPrice": 90000,
"provider": "Google",
"supportModelId": 0,
"icon": ""
},
{
"id": 100,
"name": "deepseek/deepseek-v3.2-think",
"type": "",
"inputPrice": 20000,
"outputPrice": 30000,
"provider": "DeepSeek",
"supportModelId": 0,
"icon": ""
},
{
"id": 101,
"name": "deepseek/deepseek-v3.2",
"type": "",
"inputPrice": 20000,
"outputPrice": 30000,
"provider": "DeepSeek",
"supportModelId": 0,
"icon": ""
},
{
"id": 104,
"name": "deepseek/deepseek-v3.2",
"type": "",
"inputPrice": 20000,
"outputPrice": 40000,
"provider": "DeepSeek",
"supportModelId": 0,
"icon": ""
}
],
"routerConfigs": [
{
"id": 0,
"name": "路由配置1",
"mode": "loadBalance",
"models": [
{
"id": 171,
"model": "deepseek/deepseek-v3.2",
"weight": 100
}
],
"isConfirmed": false,
"routeId": "",
"strategies": null
},
{
"id": 0,
"name": "mix1",
"mode": "mix",
"models": null,
"isConfirmed": false
}
]
}
],
"msg": "获取成功"
}
2. 创建项目
创建一个新的企业网关项目。
接口信息
- Path:
/project/create - Method:
POST - 权限: 主账号、RAM管理员
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| projectName | string | 是 | 项目名称 | xxxxx |
| projectTime | []string | 否 | 项目持续时间 | [开始时间, 结束时间] |
| teamMembers | []TeamMember | 是 | 团队成员 | |
| selectedModels | []ModelPrice | 否 | 选择的模型 | |
| routerConfigs | []RouterConfig | 是 | 路由配置 |
请求示例
POST /project/create
Content-Type: application/json
X-Access-Key-Id: AK_xxx
X-Timestamp: 2024-01-01T12:00:00+00:00
X-Signature: xxx
{
"mainUserName": "string",
"projectName": "string",
"projectTime": [
"string"
],
"routerConfigs": [
{
"id": 0,
"isConfirmed": true,
"mode": "load_balancing",
"models": [
{
"id": 0,
"model": "string",
"weight": 0
}
],
"name": "string",
"routeId": "string",
"strategies": [
"string"
]
}
],
"selectedModels": [
{
"inputPrice": 0,
"name": "string",
"outputPrice": 0,
"provider": "string",
"supportModelId": 0,
"type": "string"
}
],
"teamMembers": [
{
"name": "string",
"role": "string",
"roleId": 0,
"type": "string"
}
]
}
响应示例
{
"code": 0,
"data": {},
"msg": "创建项目成功"
}
3. 编辑项目
更新项目的基本信息。
接口信息
- Path:
/project/edit - Method:
POST - 权限: 主账号、RAM管理员、项目管理员
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| projectId | integer | 是 | 项目ID | 1 |
| startTime | time.Time | 否 | 项目开始时间 | 2025-01-01T12:00:00+00:00 |
| endTime | time.Time | 否 | 项目结束时间 | 2026-01-01T12:00:00+00:00 |
| projectName | string | 否 | 项目名称 | xxxxx |
请求示例
POST /project/edit?project_id=1
Content-Type: application/json
X-Access-Key-Id: AK_xxx
X-Timestamp: 2024-01-01T12:00:00+00:00
X-Signature: xxx
{
"project_id": 1,
"startTime": "更新后的项目名称",
"endTime": "更新后的项目描述",
"projectName": "xxxxxx"
}
响应示例
{
"code": 0,
"data": {},
"msg": "编辑项目成功"
}
4. 删除项目
删除指定的项目。
接口信息
- Path:
/project/delete - Method:
POST - 权限: 主账号、RAM管理员、项目管理员
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| project_id | integer | 是 | 项目ID | 1 |
请求示例
POST /project/delete?project_id=1
Content-Type: application/json
X-Access-Key-Id: AK_xxx
X-Timestamp: 2024-01-01T12:00:00+00:00
X-Signature: xxx
{
"project_id": 1
}
响应示例
{
"code": 0,
"msg": "删除项目成功"
}
5. 获取项目路由列表
查询项目的路由配置列表。
接口信息
- Path:
/project/router/list - Method:
POST - 权限: 主账号、RAM管理员、项目管理员、项目查看者
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| project_id | integer | 是 | 项目ID | 1 |
请求示例
POST /project/router/list
Content-Type: application/json
X-Access-Key-Id: AK_xxx
X-Timestamp: 2024-01-01T12:00:00+00:00
X-Signature: xxx
{
"project_id": 1
}
响应示例
{
"code": 0,
"data": [
{
"id": 168,
"name": "负载均衡",
"mode": "loadBalance",
"models": [
{
"id": 214,
"model": "qwen/qwen-plus",
"weight": 10
},
{
"id": 215,
"model": "qwen/qvq-72b",
"weight": 10
},
{
"id": 216,
"model": "qwen/qwen-vl-plus",
"weight": 80
}
],
"isConfirmed": false,
"routeId": "3919c69336acb30d",
"strategies": []
},
{
"id": 169,
"name": "故障转移",
"mode": "failover",
"models": [
{
"id": 217,
"model": "qwen/qwen-plus",
"weight": 0
},
{
"id": 218,
"model": "qwen/qvq-72b",
"weight": 0
}
],
"isConfirmed": false,
"routeId": "754149d7e6e8b932",
"strategies": []
}
],
"msg": "获取路由详情成功"
}
6. 添加项目路由
为项目添加新的路由配置。
接口信息
- Path:
/project/router/add - Method:
POST - 权限: 主账号、RAM管理员、项目管理员
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| project_id | integer | 是 | 项目ID | 1 |
| RouterConfig | string | 是 | 路由配置 |
请求示例
POST /project/router/add?project_id=1
Content-Type: application/json
X-Access-Key-Id: AK_xxx
X-Timestamp: 2024-01-01T12:00:00+00:00
X-Signature: xxx
{
"project_id": 0,
"router_config": {
"id": 0,
"isConfirmed": true,
"mode": "load_balancing",
"models": [
{
"id": 0,
"model": "string",
"weight": 0
}
],
"name": "string",
"routeId": "string",
"strategies": [
"string"
]
}
}
响应示例
{
"code": 0,
"data": { },
"msg": "添加成功"
}
7. 获取项目模型列表
查询项目可用的模型列表。
接口信息
- Path:
/project/models/list - Method:
POST - 权限: 主账号、RAM管理员、项目管理员、项目查看者
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| project_id | integer | 是 | 项目ID | 1 |
请求示例
POST /project/models/list?project_id=1
Content-Type: application/json
X-Access-Key-Id: AK_xxx
X-Timestamp: 2024-01-01T12:00:00+00:00
X-Signature: xxx
{
"project_id": 1
}
响应示例
{
"code": 0,
"data": [
{
"id": 92,
"name": "google/gemini-3-pro-image-preview",
"type": "图像生成",
"inputPrice": 50000,
"outputPrice": 90000,
"provider": "Google",
"supportModelId": 0,
"icon": ""
},
{
"id": 104,
"name": "deepseek/deepseek-v3.2",
"type": "LLM",
"inputPrice": 20000,
"outputPrice": 40000,
"provider": "DeepSeek",
"supportModelId": 0,
"icon": ""
}
],
"msg": "获取项目模型详情成功"
}
获取可用模型
接口信息
- Path:
/modelrouter/list/byoks?pageSize=1000&modelTypeId=1,2,3,4 - Method:
POST - 权限: 主账号、RAM管理员、项目管理员
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| pageSize | integer | 是 | 每页记录数 | 1000 |
| modelTypeId | []uint | 是 | 模型类型id. 1:llm ,2:embedding, 3:图像生成, 4:视频生成 | 1,2,3,4 |
请求示例
POST /modelrouter/list/byoks?pageSize=1000&modelTypeId=1,2,3,4
Content-Type: application/json
X-Access-Key-Id: AK_xxx
X-Timestamp: 2024-01-01T12:00:00+00:00
X-Signature: xxx
响应示例
{
"code": 0,
"data": {
"infos": [
{
"id": 268,
"icon_64": "",
"company": "MiniMax",
"name": "MiniMax M2.1 lightning",
"api_name": "minimax/minimax-m2.1-lightning",
"description": "",
"support_id": 364,
"context": 0,
"provider": "MiniMax",
"model_type": 1,
"pricing": {
"price": 0,
"input_price": 0,
"output_price": 0,
"cached_price": 0,
"image_price": 0,
"currency": ""
},
"provider_pricing": {
"price": 0,
"input_price": 0,
"output_price": 0,
"cached_price": 0,
"image_price": 0,
"currency": ""
},
"endpoint": {
"provider": "",
"quantization": "",
"context_length": 0,
"max_output": 0
},
"architecture": {
"input": "",
"output": "",
"tokenizer": ""
},
"total_tokens": 0,
"supported_apis": "",
"is_byok": false,
"byok_router_names": [
"/v1/chat/completions",
"/v1/messages"
]
}
]
},
"msg": "获取项目模型详情成功"
}
8. 编辑项目模型配置
更新项目的模型配置(启用/禁用模型)。
接口信息
- Path:
/project/models/edit - Method:
POST - 权限: 主账号、RAM管理员、项目管理员
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| project_id | integer | 是 | 项目ID | 1 |
| models | []tensify.ModelPrice | 是 | 项目名称 | 见下方示例 |
请求示例
POST /project/models/edit
Content-Type: application/json
X-Access-Key-Id: AK_xxx
X-Timestamp: 2024-01-01T12:00:00+00:00
X-Signature: xxx
{
"models": [
{
"icon": "string",
"id": 0,
"inputPrice": 0,
"name": "string",
"outputPrice": 0,
"provider": "string",
"supportModelId": 0,
"type": "string"
}
],
"project_id": 0
}
响应示例
{
"code": 0,
"msg": "编辑项目模型详情成功"
}
9. 生成项目API Token
为项目生成新的API Token,用于调用企业网关API。
接口信息
- Path:
/project/generate/apitoken - Method:
POST - 权限: 主账号、RAM管理员、项目管理员、项目查看者
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| project_id | integer | 是 | 项目ID | 1 |
| api_name | string | 是 | 项目ID | xxxxxx |
请求示例
POST /project/generate/apitoken
Content-Type: application/json
X-Access-Key-Id: AK_xxx
X-Timestamp: 2024-01-01T12:00:00+00:00
X-Signature: xxx
{
"project_id": 1,
"api_name": "xxxxxx"
}
响应示例
{
"code": 0,
"data": {
"ID": 114,
"CreatedAt": "2025-12-26T16:04:38.031504+08:00",
"UpdatedAt": "2025-12-26T16:04:38.031504+08:00",
"UserID": 4,
"IsBanned": false,
"IsExpired": false,
"Name": "xxxxxx",
"Desc": "",
"Key": "DHjiThiu",
"Token": "YOUR_PROJECT_API_KEY",
"Tpm": 0,
"Rpm": 0,
"MaxQuota": 0,
"ConsumedAmount": 0,
"SupportedModels": "",
"IsDefault": false,
"ExpiresAt": null,
"RamUserId": 3,
"EnterpriseGatewayProjectID": 35
},
"msg": "查询成功"
}
10. 获取项目API Key列表
查询项目的所有API Token。
接口信息
- Path:
/project/apikey/list - Method:
POST - 权限: 主账号、RAM管理员、项目管理员、项目查看者
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| project_id | integer | 是 | 项目ID | 1 |
请求示例
POST /project/apikey/list
Content-Type: application/json
X-Access-Key-Id: AK_xxx
X-Timestamp: 2024-01-01T12:00:00+00:00
X-Signature: xxx
{
"project_id": 1
}
响应示例
{
"code": 0,
"data": [
{
"ID": 105,
"CreatedAt": "2025-12-17T12:00:35.50753+08:00",
"UpdatedAt": "2025-12-18T11:08:38.576763+08:00",
"UserID": 4,
"IsBanned": false,
"IsExpired": false,
"Name": "测试router",
"Desc": "",
"Key": "EuBTkJ52",
"Token": "YOUR_PROJECT_API_KEY",
"Tpm": 0,
"Rpm": 0,
"MaxQuota": 0,
"ConsumedAmount": 0,
"SupportedModels": "",
"IsDefault": false,
"ExpiresAt": null,
"RamUserId": 0,
"EnterpriseGatewayProjectID": 35
}
],
"msg": "获取apikey成功"
}
11. 获取项目团队成员
查询项目的团队成员列表及其角色。
接口信息
- Path:
/project/team/members - Method:
POST - 权限: 主账号、RAM管理员、项目管理员
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| project_id | integer | 是 | 项目ID | 1 |
请求示例
POST /project/team/members
Content-Type: application/json
X-Access-Key-Id: AK_xxx
X-Timestamp: 2024-01-01T12:00:00+00:00
X-Signature: xxx
{
"project_id": 1
}
响应示例
{
"code": 0,
"data": [
{
"id": 2,
"name": "junior_li_test",
"roleId": 13,
"role": "有限制只查看",
"type": "member"
},
{
"id": 16,
"name": "lcw",
"roleId": 5,
"role": "无限制管理员",
"type": "member"
}
],
"msg": "获取项目成员详情成功"
}
12. 编辑项目团队成员
添加或移除项目团队成员,分配角色。
接口信息
- Path:
/project/team/members/edit - Method:
POST - 权限: 主账号、RAM管理员、项目管理员
请求参数
| 参数名 | 类型 | 必填 | 说明 | 示例 |
|---|---|---|---|---|
| project_id | integer | 是 | 项目ID | 1 |
| members | array | 是 | 成员配置数组 | 见下方示例 |
请求示例
POST /project/team/members/edit
Content-Type: application/json
X-Access-Key-Id: AK_xxx
X-Timestamp: 2024-01-01T12:00:00+00:00
X-Signature: xxx
{
"project_id": 0,
"team_members": [
{
"id": 0,
"name": "string",
"role": "string",
"roleId": 0,
"type": "string"
}
]
}
响应示例
{
"code": 0,
"msg": "编辑项目成员详情成功"
}
完整调用示例
Python完整示例
将 BYOK 页完整 Python 客户端中的导入语句和 BYOKAPI 类保存为 byok_client.py(不包含底部调用演示),再运行以下扩展。认证编码仍待核准。
from byok_client import BYOKAPI
class ProjectAPI(BYOKAPI):
# ========== Project ==========
def list_projects(self, filters=None):
return self._request(
"GET",
"/project/list",
params=filters or {}
)
def create_project(self, project_payload: dict):
"""
project_payload:
{
projectName,
projectTime?,
teamMembers,
selectedModels?,
routerConfigs
}
"""
return self._request(
"POST",
"/project/create",
body=project_payload
)
def edit_project(self, project_id: int, updates: dict):
body = {"project_id": project_id, **updates}
return self._request("POST", "/project/edit", body)
def delete_project(self, project_id: int):
return self._request(
"POST",
"/project/delete",
{"project_id": project_id}
)
# ========== Router ==========
def list_routers(self, project_id: int):
return self._request(
"POST",
"/project/router/list",
{"project_id": project_id}
)
def add_router(self, project_id: int, router_config: dict):
return self._request(
"POST",
"/project/router/add",
{
"project_id": project_id,
"router_config": router_config
}
)
# ========== Models ==========
def list_project_models(self, project_id: int):
return self._request(
"POST",
"/project/models/list",
{"project_id": project_id}
)
def edit_project_models(self, project_id: int, models: list):
return self._request(
"POST",
"/project/models/edit",
{
"project_id": project_id,
"models": models
}
)
# ========== API Token ==========
def generate_api_token(self, project_id: int, api_name: str):
return self._request(
"POST",
"/project/generate/apitoken",
{
"project_id": project_id,
"api_name": api_name
}
)
def list_api_tokens(self, project_id: int):
return self._request(
"POST",
"/project/apikey/list",
{"project_id": project_id}
)
# ========== Team ==========
def list_team_members(self, project_id: int):
return self._request(
"POST",
"/project/team/members",
{"project_id": project_id}
)
def edit_team_members(self, project_id: int, team_members: list):
return self._request(
"POST",
"/project/team/members/edit",
{
"project_id": project_id,
"team_members": team_members
}
)
错误码说明
| 错误码 | 说明 | 解决方法 |
|---|---|---|
| 400 | 参数错误或项目ID缺失 | 检查请求参数和URL |
| 401 | 未认证 | 检查AccessKey和签名 |
| 403 | 权限不足或没有项目权限 | 确认账号权限和项目角色 |
| 404 | 项目不存在 | 检查项目ID |
| 500 | 服务器错误 | 联系技术支持 |
注意事项
- project_id参数: 大部分项目API需要在URL查询参数和请求体中都包含project_id
- 签名计算: 包含查询参数的URI需要在计算签名时使用完整路径
- 权限验证: 项目相关操作会验证用户在该项目中的角色权限
- API Token: 生成的API Token用于调用企业网关的模型API,不是管理API