创建课程计划
API 版本 2026-10-affable-towhee
post https://api.getlingara.com/v1/lesson-plans
开始生成课程计划并以流式方式返回进度。计划一经创建,started 即给出其标识,因此连接断开后可以通过 GET /v1/lesson-plans/{id}/stream 重新连接。流以 result 或 error 结束。来自资料库的计划会以单个 result 返回。
权限范围 lesson_plans:write
参数
Lingara-Versionheaderstring可选- 回应此请求所用的 API 版本。不提供时,访问令牌使用其客户端绑定的版本,不带令牌的请求使用当前版本。仍在开发中的版本只能通过在此指定来访问。未知版本会以
400回应,代码为api_version_unknown。GET /v1/versions会列出所有版本。
请求体 application/json
contextstring必填source_langstring必填target_langstring必填levelinteger必填
响应
200 计划的进度,然后是计划本身
流事件 text/event-stream
每 15 秒发送一条 keepalive 注释。
-
startedPlanStarted -
plan_idstring必填
-
phasePlanPhase -
phasestring必填attemptinteger必填
-
resultPlanResult 结束数据流 -
planLessonPlan必填idstring必填statusPlanStatus必填titlestring | null可选source_langstring必填target_langstring必填levelinteger必填created_atstring必填completed_atstring | null可选ai_generatedboolean必填contentLessonPlanContent | null可选introductionstring | null可选learning_objectivesarray of string必填vocabularyarray of PlanWord必填wordstring必填pronunciationstring | null可选translationstring必填
setsarray of PlanSet必填numberinteger必填contextstring | null可选questionsarray of PlanQuestion必填typestring必填promptstring必填optionsarray of string | null可选answerstring必填explanationstring必填hintstring | null可选
-
errorStreamError 结束数据流 -
在 200 响应内送达。状态行已经发送,因此数据流打开后的失败会以此事件报告。
codestring必填messagestring必填plan_idstring | null可选
错误
402application/json- 一个按用量计费的客户端的调用在产生任何花费之前就被拒绝了。
spend_cap_reached:客户端或其账户已达到每月支出上限;请在集成页面提高上限。metered_billing_inactive:此账户的按用量计费未激活;请在集成页面进行设置,或更新付款方式。 410application/json- 回应此请求所用的 API 版本已停用。请在
Lingara-Version中发送一个受支持的版本,或将客户端绑定到其他版本。 4XXapplication/json- 请求被拒绝。
code说明原因,error用文字描述原因。 503application/json · text/plain- 服务暂时不可用;请在
Retry-After所示的秒数之后重试。维护期间,响应体为纯文本,而不是错误信封。 5XXapplication/json- 请求被拒绝。
code说明原因,error用文字描述原因。
codestring必填请求被拒绝的原因,以稳定的代码表示,可据此进行分支处理:例如
insufficient_scope(403)、rate_limited(429),以及按用量计费的客户端的spend_cap_reached(402)和metered_billing_inactive(402)。errorstring必填
示例
流示例
event: started
data: {"plan_id":"3f1c2a9e-5b7d-4e21-9a0c-6d8e4f2b1a37"}
event: phase
data: {"phase":"selecting_vocabulary","attempt":1}
event: result
data: {"plan":{"id":"3f1c2a9e-5b7d-4e21-9a0c-6d8e4f2b1a37","status":"complete","title":"At the night market","source_lang":"en","target_lang":"zh","level":2,"created_at":"2026-09-23T10:00:00Z","completed_at":"2026-09-23T10:00:41Z","ai_generated":true,"content":{"introduction":"Order food and ask prices at a night market.","learning_objectives":["Ask how much something costs"],"vocabulary":[{"word":"多少钱","pronunciation":"duōshao qián","translation":"how much"}],"sets":[{"number":1,"questions":[{"type":"multiple_choice_word","prompt":"Which word asks for a price?","options":["多少钱","谢谢"],"answer":"多少钱","explanation":"多少钱 means how much money."}]}]}}}如译文与英文参考文档不一致,以英文参考文档为准。