Skip to content

Integrating OpenL2

OpenL2 separates curriculum and language-knowledge definitions from learner delivery. Learning apps, flashcard tools, audio generators, and media analyzers can all consume the same compiled courses.

  • OpenL2 owns: Concept and Skill identities, prerequisite and introduction order, authored Tasks/Lessons/Exercises, annotations, and quality validation.
  • Your application owns: Learner state (recognition vs. production mastery), spaced-repetition scheduling, modality selection, speaking/roleplay coaching, and runtime L1 adaptation.

Use compile_level_export to load a resolved, validated level with its compiled tasks, concepts, and teaching plans:

from pathlib import Path
from openl2.courses.exports.compiler import compile_level_export
level = compile_level_export(Path("courses/calling-in-sick"))
print(level.language, level.level, len(level.tasks))
for task in level.tasks:
print(task.task_id, "→", task.outcome)
for concept in task.concepts:
print(" ", concept.ref, f"({concept.kind})", "sources:", len(concept.sources))

Key compiled types (openl2.courses.exports.models)

Section titled “Key compiled types (openl2.courses.exports.models)”
  • CompiledLevel:
    • level_dir, framework, language, level, validation_closure, exercise_source
    • tasks: tuple[CompiledTask, ...] (also level.task_by_id)
    • level_outcomes: tuple[LevelOutcome, ...]
    • skills, skill_records, concept_catalog, target_inventory
  • CompiledTask:
    • task_id, index, outcome, register, source_path, task_source
    • concepts: tuple[CompiledConcept, ...] (also task.concept_refs, task.concept_by_ref)
    • level_outcome_refs, integrative_modalities, prior_teaching, prerequisites_by_ref, teaching_plan
  • CompiledConcept:
    • ref, kind, concept, concept_key, sense, pos, support_only
    • skill, skill_type, skill_key, realizes_concept
    • sources: tuple[ConceptSource, ...] (every presentation, utterance, or dialogue turn where the Concept appears)

Key learner mastery state on (language, concept_key) (or (library, concept_key)), not on a bare concept_key alone. Concept keys are canonical within one language library, not globally across languages—for example, both English and Dutch export payment-card (card in English vs. met pin in Dutch). For Skill Concepts, pair language with skill_key and concept_key.

Because CompiledConcept preserves kind, sense, and realizes_concept, and CompiledTask preserves prerequisites_by_ref and prior_teaching, your runtime can track recognition vs. production separately and select targeted practice for gaps.

List registered exporter plugins in your environment:

Terminal window
openl2 plugins list
  • Using built-in exporters (static site, Anki .apkg/AnkiConnect, Book, Jetway): see Export & publish a course.
  • Building & registering a third-party plugin (Python entry points, MCP plugins, openl2-study): see Building plugins, and src/openl2/plugins/anki/, src/openl2/plugins/book/, and src/openl2/plugins/jetway/ for reference implementations.

When integrating with Jetway or mirroring its export format, note that Jetway’s exported concept_sets[].depends_on_concept_set_keys carries Concept Set–level dependencies only. Individual Concept prerequisites declared on a set (such as requiring I and you before a have possession set) are enforced by OpenL2 during validation and compilation (CompiledTask.prerequisites_by_ref) and are filtered out of depends_on_concept_set_keys. If your runtime needs Concept-level prerequisite edges for adaptive sequencing, read CompiledTask.prerequisites_by_ref directly from compile_level_export.