建立課程計畫
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."}]}]}}}假使翻譯㧯英文參考文件無共樣,就以英文參考文件為準。