建立課程計劃
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."}]}]}}}如果譯本同英文參考文件有出入,以英文參考文件為準。