根据指定学科、题型和难度自动生成高质量题目。支持基于教学材料生成题目,支持多种题型和难度等级。
| 请求URL | POST /api/generate 或 GET /api/generate |
| 请求方法 | POST / GET |
| 认证方式 | API Key(请求头:X-API-Key) |
| 参数名 | 必填 | 类型 | 说明 |
|---|---|---|---|
subject |
是 | string | 学科名称,如:数学、物理、化学、英语、语文、历史、地理、生物等 |
type |
否 | string | 题型,默认为 single。支持的题型包括: 基础题型:single(单选题), multiple(多选题), judgement(判断题), fill(填空题), short_answer(简答题), calculation(计算题), essay(论述题), coding(编程题) 高考题型:reading_comprehension(阅读理解), material_analysis(材料分析题), cloze_test(完形填空), translation(翻译题), writing(写作题), continuation_writing(读后续写), summary_writing(概要写作), error_correction(改错题), grammar(语法题), vocabulary(词汇题), paragraph_ordering(段落排序题), listening_comprehension(听力理解) |
difficulty |
否 | string | 难度等级,默认为 medium。可选值:easy(简单), medium(中等), hard(困难) |
count |
否 | integer | 生成题目数量,默认为1,最大为10 |
keywords |
否 | string | 关键词,用于指定出题范围,多个关键词用逗号分隔 |
material |
否 | file | 教学材料文件(支持 .txt, .md, .pdf, .doc, .docx),用于基于材料生成题目 |
material_content |
否 | string | 教学材料文本内容(当使用POST JSON格式时可直接传递文本) |
{
"subject": "数学",
"type": "single",
"difficulty": "medium",
"count": 3,
"keywords": "二次函数,因式分解",
"material_content": "二次函数是高中数学的重要内容..."
}
curl -X POST \
-H "X-API-Key: your_api_key" \
-F "subject=数学" \
-F "type=single" \
-F "difficulty=medium" \
-F "count=3" \
-F "keywords=二次函数,因式分解" \
-F "material=@/path/to/material.pdf" \
"https://tiku.anevol.cn/api/generate"
curl -X GET \
-H "X-API-Key: your_api_key" \
"https://tiku.anevol.cn/api/generate?subject=数学&type=single&difficulty=medium&count=3&keywords=二次函数,因式分解"
| 参数名 | 类型 | 说明 |
|---|---|---|
code |
integer | 状态码,1表示成功,0表示失败 |
subject |
string | 学科名称 |
difficulty |
string | 难度等级 |
type |
string | 题型 |
count |
integer | 生成题目数量 |
questions |
string | 生成的题目内容(字符串格式,多题用 --- 分隔)(成功时返回) |
model |
string | 使用的AI模型名称(成功时返回) |
using_backup |
boolean | 是否使用了备用模型(可选,成功时可能返回) |
msg |
string | 错误信息(失败时返回) |
{
"code": 1,
"subject": "数学",
"difficulty": "medium",
"type": "single",
"count": 1,
"questions": "题目:已知函数f(x)=x²+2x+1,求f(x)的最小值。\nA. 0\nB. 1\nC. 2\nD. 3\n正确答案:A",
"model": "deepseek-chat"
}
{
"code": 1,
"subject": "数学",
"difficulty": "medium",
"type": "single",
"count": 3,
"questions": "题目1:已知函数f(x)=x²+2x+1,求f(x)的最小值。\nA. 0\nB. 1\nC. 2\nD. 3\n正确答案:A\n---\n题目2:已知函数f(x)=x²+4x+4,求f(x)的最小值。\nA. 0\nB. 1\nC. 2\nD. 3\n正确答案:A\n---\n题目3:已知函数f(x)=x²+6x+9,求f(x)的最小值。\nA. 0\nB. 1\nC. 2\nD. 3\n正确答案:A",
"model": "deepseek-chat"
}
{
"code": 1,
"subject": "数学",
"difficulty": "medium",
"type": "single",
"count": 1,
"questions": "题目:已知函数f(x)=x²+2x+1,求f(x)的最小值。\nA. 0\nB. 1\nC. 2\nD. 3\n正确答案:A",
"model": "maas",
"using_backup": true
}
{
"code": 0,
"msg": "没有提供学科内容"
}
| 错误码 | 说明 |
|---|---|
400 |
请求参数错误(如缺少必填参数 subject,或不支持的文件格式) |
401 |
未提供API密钥或密钥无效 |
429 |
请求过于频繁,触发限流 |
500 |
服务器内部错误(AI模型调用失败等) |
count 参数控制,最大为 10 道keywords 参数可以指定出题范围,多个关键词用逗号分隔using_backup: true--- 分隔,每道题包含题目、选项(如有)和答案