Lingara Lingara بەڵگەنامەکان ڕێنماییەکان API کتێبخانەکان ئەپەکان دروستکردن ئەپی وێب
زمان: سۆرانی

دروستکردنی پلانی وانە

وەشانی 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 دەنێرێت.

started PlanStarted
plan_idstringپێویست
phase PlanPhase
phasestringپێویست
attemptintegerپێویست
result PlanResult پەخشەکە کۆتایی پێدەهێنێت
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ئارەزوومەندانە
error StreamError پەخشەکە کۆتایی پێدەهێنێت

لەناو وەڵامی 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پێویست

نموونە

زمانی نموونەی کۆد

curl

curl -N -X POST "https://api.getlingara.com/v1/lesson-plans" \
  -H "Authorization: Bearer $LINGARA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"context":"Ordering food at a night market","source_lang":"en","target_lang":"zh","level":2}'

TypeScript

const stream = client.createLessonPlan({
  context: "ordering at a night market",
  source_lang: "en",
  target_lang: "zh",
  level: 2,
});
for await (const ev of stream) {
  if (ev.event === "started") console.log("plan", ev.data.plan_id);
  if (ev.event === "phase") console.log("working:", ev.data.phase);
  if (ev.event === "result") console.log(ev.data.plan.title);
}

Rust

use lingara::models::{CreateLessonPlanEvent, LessonPlanCreateRequest};

let request = LessonPlanCreateRequest {
    context: "ordering at a night market".into(),
    source_lang: "en".into(),
    target_lang: "zh".into(),
    level: 2,
};
let mut stream = client.create_lesson_plan(&request).await?;
while let Some(event) = stream.next().await {
    match event? {
        CreateLessonPlanEvent::Started(started) => println!("plan {}", started.plan_id),
        CreateLessonPlanEvent::Phase(phase) => println!("working: {}", phase.phase),
        CreateLessonPlanEvent::Result(result) => println!("{}", result.plan.title.unwrap_or_default()),
        _ => {}
    }
}

Go

s, err := client.CreateLessonPlan(ctx, lingara.LessonPlanCreateRequest{
	Context:    "ordering at a night market",
	SourceLang: "en",
	TargetLang: "zh",
	Level:      2,
})
if err != nil {
	return err
}
defer s.Close()
for ev, err := range s.Events() {
	if err != nil {
		return err
	}
	switch e := ev.(type) {
	case lingara.CreateLessonPlanEventStarted:
		fmt.Println("plan", e.Data.PlanID)
	case lingara.CreateLessonPlanEventPhase:
		fmt.Println("working:", e.Data.Phase)
	case lingara.CreateLessonPlanEventResult:
		if e.Data.Plan.Title != nil {
			fmt.Println(*e.Data.Plan.Title)
		}
	}
}

Java

import com.getlingara.client.model.CreateLessonPlanEvent;
import com.getlingara.client.model.LessonPlanCreateRequest;

LessonPlanCreateRequest request =
    new LessonPlanCreateRequest()
        .context("Ordering at a night market")
        .level(2)
        .sourceLang("en")
        .targetLang("zh");
try (EventStream<CreateLessonPlanEvent> stream = client.createLessonPlan(request)) {
  for (CreateLessonPlanEvent event : stream) {
    if (event instanceof CreateLessonPlanEvent.Started started) {
      // Keep the id: streamLessonPlan rejoins a generation that was cut off.
      System.out.println("plan " + started.data().getPlanId());
    } else if (event instanceof CreateLessonPlanEvent.Phase phase) {
      System.out.println("phase " + phase.data().getPhase());
    } else if (event instanceof CreateLessonPlanEvent.Result result) {
      System.out.println(result.data().getPlan().getTitle());
    }
  }
}

Kotlin

import com.getlingara.kotlin.LingaraClient
import com.getlingara.kotlin.model.CreateLessonPlanEvent
import com.getlingara.kotlin.model.LessonPlanCreateRequest

val request =
    LessonPlanCreateRequest(context = "Ordering at a night market", sourceLang = "en", targetLang = "zh", level = 2)
client.createLessonPlan(request).use { stream ->
    stream.collect { event ->
        when (event) {
            // Keep the id: streamLessonPlan rejoins a generation that was cut off.
            is CreateLessonPlanEvent.Started -> println("plan ${event.data.planId}")
            is CreateLessonPlanEvent.Phase -> println("phase ${event.data.phase}")
            is CreateLessonPlanEvent.Result -> println(event.data.plan.title)
        }
    }
}

Ruby

client.create_lesson_plan(context: "ordering at a night market", source_lang: "en", target_lang: "zh", level: 2) do |event|
  case event
  in Lingara::CreateLessonPlanEventStarted => started then puts "plan #{started.data.plan_id}"
  in Lingara::CreateLessonPlanEventPhase => phase then puts "working: #{phase.data.phase}"
  in Lingara::CreateLessonPlanEventResult => result then puts "ready: #{result.data.plan.title}"
  else nil
  end
end

PHP

use Lingara\Model\LessonPlanCreateRequest;
use Lingara\Stream\CreateLessonPlanEvent;

$request = new LessonPlanCreateRequest([
    'context' => 'ordering at a night market',
    'source_lang' => 'en',
    'target_lang' => 'zh',
    'level' => 2,
]);
foreach ($client->createLessonPlan($request) as $event) {
    if ($event instanceof CreateLessonPlanEvent\Started) {
        echo 'plan ', $event->data->getPlanId(), "\n";
    } elseif ($event instanceof CreateLessonPlanEvent\Phase) {
        echo 'phase: ', $event->data->getPhase(), "\n";
    } elseif ($event instanceof CreateLessonPlanEvent\Result) {
        echo 'ready: ', $event->data->getPlan()->getTitle(), "\n";
    }
}

کتێبخانەیەکت پێ باشترە؟ بەشی کتێبخانەکان ببینە.

نموونەی ستریم

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."}]}]}}}

ئەگەر وەرگێڕانێک و سەرچاوە ئینگلیزییەکە جیاواز بن، سەرچاوە ئینگلیزییەکە دروستە.