获取模型列表

获取当前用户可访问的所有AI模型列表,包括模型ID、名称、提供商和详细信息。

关于模型列表与令牌分组

模型列表返回什么模型取决于 API KEY(API令牌)所在的令牌分组。您可以在控制台 → API令牌页面,添加令牌时选择对应的令牌分组。

API 端点

GET https://aiberm.com/v1/models

请求示例

1curl -X GET "https://aiberm.com/v1/models" \
2-H "Authorization: Bearer sk-your-api-token-here" \
3-H "Content-Type: application/json"

响应格式

成功响应 (200 OK)

1{
2"success": true,
3"data": [
4 {
5 "id": "gpt-4",
6 "object": "model",
7 "created": 1626777600,
8 "owned_by": "openai",
9 "supported_endpoint_types": [
10 "chat",
11 "completion"
12 ]
13 },
14 {
15 "id": "gpt-3.5-turbo",
16 "object": "model",
17 "created": 1626777600,
18 "owned_by": "openai",
19 "supported_endpoint_types": [
20 "chat",
21 "completion"
22 ]
23 },
24 {
25 "id": "claude-3-sonnet-20240229",
26 "object": "model",
27 "created": 1626777600,
28 "owned_by": "anthropic",
29 "supported_endpoint_types": [
30 "chat"
31 ]
32 }
33]
34}

响应字段说明

顶层字段:

  • success - 布尔值,表示请求是否成功
  • data - 模型列表数组(仅在成功时返回)
  • message - 错误信息(仅在失败时返回)

模型对象字段:

  • id - 模型唯一标识符
  • object - 对象类型,固定为 “model”
  • created - 模型创建时间戳
  • owned_by - 模型所属的服务商
  • supported_endpoint_types - 支持的API端点类型数组

支持的端点类型

  • chat - 聊天完成
  • completion - 文本完成
  • embedding - 文本嵌入
  • image - 图像生成
  • audio - 音频处理
  • rerank - 重排序

注意事项

认证要求

必须提供有效的API令牌,令牌决定了用户可以访问哪些模型。

权限控制

返回的模型列表基于用户组和令牌组进行过滤,只显示用户有权限访问的模型。

常见错误

  • 401 Unauthorized - API令牌无效或已过期
  • 403 Forbidden - 用户没有访问权限
  • 500 Internal Server Error - 服务器内部错误