Lingara Lingara Docs Guides API Libraries Apps Build Web app
Language: English

Reconnect to a lesson plan

API version 2026-10-affable-towhee

get https://api.getlingara.com/v1/lesson-plans/{id}/stream

Rejoins the progress stream of a plan that is still generating. A finished plan answers one result. A plan still generating with no live stream to join answers one pending; poll GET /v1/lesson-plans/{id} until it is complete.

Scopes lesson_plans:read

Parameters

Lingara-Versionheaderstringoptional
The API version to answer this request under. Without it, an access token gets the version its client is pinned to, and a request with no token gets the current version. The version still in development is reached only by naming it here. An unknown version answers 400 with code api_version_unknown. GET /v1/versions lists the versions.
idpathstringrequired

Responses

200 The plan's remaining progress, then the plan

Stream events text/event-stream

Sends a keepalive comment every 15 seconds.

started PlanStarted
plan_idstringrequired
phase PlanPhase
phasestringrequired
attemptintegerrequired
result PlanResult Ends the stream
planLessonPlanrequired
idstringrequired
statusPlanStatusrequired
titlestring | nulloptional
source_langstringrequired
target_langstringrequired
levelintegerrequired
created_atstringrequired
completed_atstring | nulloptional
ai_generatedbooleanrequired
contentLessonPlanContent | nulloptional
introductionstring | nulloptional
learning_objectivesarray of stringrequired
vocabularyarray of PlanWordrequired
wordstringrequired
pronunciationstring | nulloptional
translationstringrequired
setsarray of PlanSetrequired
numberintegerrequired
contextstring | nulloptional
questionsarray of PlanQuestionrequired
typestringrequired
promptstringrequired
optionsarray of string | nulloptional
answerstringrequired
explanationstringrequired
hintstring | nulloptional
pending PlanPending Ends the stream
plan_idstringrequired
statusPlanStatusrequired
error StreamError Ends the stream

Arrives inside the 200 response. The status line has already been sent, so a failure after the stream opens is reported as this event.

codestringrequired
messagestringrequired
plan_idstring | nulloptional

Errors

410application/json
The API version this request is answered under has been discontinued. Send a supported version in Lingara-Version, or re-pin the client.
4XXapplication/json
The request was refused. code says why, and error says it in words.
503application/json · text/plain
The service is temporarily unavailable; retry after the number of seconds in Retry-After. During maintenance the body is plain text rather than the error envelope.
5XXapplication/json
The request was refused. code says why, and error says it in words.
codestringrequired

Why the request was refused, as a stable code to branch on: for example insufficient_scope (403), rate_limited (429) and, for a metered client, spend_cap_reached (402) and metered_billing_inactive (402).

errorstringrequired

Example

Code sample language

curl

curl -N "https://api.getlingara.com/v1/lesson-plans/$ID/stream" \
  -H "Authorization: Bearer $LINGARA_TOKEN"

TypeScript

for await (const ev of client.streamLessonPlan({ id: planId })) {
  if (ev.event === "result") console.log("ready:", ev.data.plan.title);
  if (ev.event === "pending") console.log("still", ev.data.status, "- try again later");
}

Rust

use lingara::models::StreamLessonPlanEvent;

let mut stream = client.stream_lesson_plan(&plan_id).await?;
while let Some(event) = stream.next().await {
    match event? {
        StreamLessonPlanEvent::Result(result) => println!("ready: {}", result.plan.title.unwrap_or_default()),
        StreamLessonPlanEvent::Pending(pending) => println!("still {:?} - try again later", pending.status),
        _ => {}
    }
}

Go

// Rejoin a plan still generating, with the plan_id from its started event.
s, err := client.StreamLessonPlan(ctx, "3f1c2a9e-5b7d-4e21-9a0c-6d8e4f2b1a37")
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.StreamLessonPlanEventResult:
		fmt.Println("ready:", e.Data.Plan.ID)
	case lingara.StreamLessonPlanEventPending:
		fmt.Println("still", e.Data.Status, "- rejoin later")
	}
}

Java

import com.getlingara.client.model.StreamLessonPlanEvent;

try (EventStream<StreamLessonPlanEvent> stream = client.streamLessonPlan(planId)) {
  for (StreamLessonPlanEvent event : stream) {
    if (event instanceof StreamLessonPlanEvent.Result result) {
      System.out.println(result.data().getPlan().getTitle());
    } else if (event instanceof StreamLessonPlanEvent.Pending pending) {
      // Still generating elsewhere: ask again later.
      System.out.println("pending: " + pending.data().getStatus());
    }
  }
}

Kotlin

import com.getlingara.kotlin.LingaraClient
import com.getlingara.kotlin.model.StreamLessonPlanEvent

client.streamLessonPlan(planId).use { stream ->
    stream.collect { event ->
        when (event) {
            is StreamLessonPlanEvent.Result -> println(event.data.plan.title)
            // Still generating elsewhere: ask again later.
            is StreamLessonPlanEvent.Pending -> println("pending: ${event.data.status}")
            else -> Unit
        }
    }
}

Ruby

client.stream_lesson_plan(plan_id) do |event|
  case event
  in Lingara::StreamLessonPlanEventResult => result then puts "ready: #{result.data.plan.title}"
  in Lingara::StreamLessonPlanEventPending => pending then puts "still #{pending.data.status}, try again later"
  else nil
  end
end

PHP

use Lingara\Stream\StreamLessonPlanEvent;

foreach ($client->streamLessonPlan($planId) as $event) {
    if ($event instanceof StreamLessonPlanEvent\Result) {
        echo 'ready: ', $event->data->getPlan()->getTitle(), "\n";
    } elseif ($event instanceof StreamLessonPlanEvent\Pending) {
        echo 'still ', $event->data->getStatus()->value, ", try again later\n";
    }
}

Prefer a library? See the Libraries section.

Example stream

event: pending
data: {"plan_id":"3f1c2a9e-5b7d-4e21-9a0c-6d8e4f2b1a37","status":"generating"}