API REF
模型列表
查询当前开放可调用的全部模型。提交生成任务前,先用本接口拿到目标模型的 id。
接口基本信息
| 项目 | 说明 |
|---|---|
| 接口用途 | 列出全部可调用模型,支持按类型 / 关键词过滤 |
| 请求方式 | GET https://api.mozhiai.net/v1/models |
| 认证方式 | Authorization: Bearer YOUR_API_KEY |
| 返回格式 | JSON(统一信封,模型数组在 data 字段) |
请求参数(Query)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
type | string | 否 | 按模型类型过滤,如 chat / image / video |
q | string | 否 | 按名称关键词模糊搜索 |
响应示例
Response
{
"code": 0,
"message": "ok",
"data": [
{
"id": "1234567890",
"display_name": "GPT-5",
"slug": "gpt-5",
"model_types": ["chat"],
"capability_tags": ["对话", "推理"],
"icon": "https://cos.mozhiai.net/icons/gpt5.png",
"description": "旗舰对话模型,适合复杂推理与写作",
"sort_weight": 100
}
],
"trace_id": "..."
}响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 模型 ID(雪花 ID 的字符串形式),提交生成任务时作为 model_id 使用 |
display_name | string | 模型展示名 |
slug | string | 模型短标识 |
model_types | string[] | 模型类型,如 chat / image / video |
capability_tags | string[] | 能力标签 |
icon | string | 模型图标 URL |
description | string | 模型简介 |
sort_weight | int | 排序权重,越大越靠前 |
注意:模型 ID 是字符串而不是数字,代码里不要做数值转换 (雪花 ID 超出 JS 安全整数范围,转数字会丢精度)。
错误码
| HTTP | 错误码 | 说明 |
|---|---|---|
| 401 | 190002 | API Key 缺失、无效或已吊销 |
| 402 | 190003 | API Key 额度已用尽 |
| 500 | 100006 | 服务器内部错误 |
调用示例
cURL
curl "https://api.mozhiai.net/v1/models?type=image&q=seedream" \
-H "Authorization: Bearer $MOZHIAI_API_KEY"Python
import os, requests
resp = requests.get(
"https://api.mozhiai.net/v1/models",
headers={"Authorization": f"Bearer {os.environ['MOZHIAI_API_KEY']}"},
params={"type": "image"},
)
resp.raise_for_status()
envelope = resp.json()
assert envelope["code"] == 0, envelope["message"]
for model in envelope["data"]:
print(model["id"], model["display_name"])TypeScript
const resp = await fetch("https://api.mozhiai.net/v1/models?type=image", {
headers: { Authorization: `Bearer ${process.env.MOZHIAI_API_KEY}` },
});
const envelope = await resp.json();
if (envelope.code !== 0) throw new Error(envelope.message);
// 注意:model.id 是字符串,不要 Number() 转换
for (const model of envelope.data) {
console.log(model.id, model.display_name);
}