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