feat: add ltx2.h public C API for LTX-2 text-to-video and image-to-video - #48
Open
kamalbuilds wants to merge 3 commits into
Open
kamalbuilds wants to merge 3 commits into
kamalbuilds wants to merge 3 commits into
Conversation
Brings ltx2_new_ctx/ltx2_free_ctx/ltx2_generate_t2v/ltx2_generate_i2v from feat/ltx2-video-generation. No API drift against the base stable-diffusion.h: generate_video is already 5-arg with sd_audio_t**, LTX2_SCHEDULER already exists in scheduler_t, and llm_path already loads under the text_encoders.llm. prefix this facade relies on.
Same install path as stable-diffusion.h. src/ltx2_api.cpp needs no CMake change: src/*.cpp is already globbed into SD_LIB_SOURCES.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
include/ltx2.h, a small public C API for LTX-2 video generation, so a program can run text-to-video and image-to-video without going throughsd-cli:ltx2_new_ctx()/ltx2_free_ctx(): create a context from the diffusion model, VAE, Gemma text encoder and embeddings-connector paths.ltx2_generate_t2v()andltx2_generate_i2v(): return RGB frames (plus audio when the model produces it).src/ltx2_api.cppis a thin wrapper over the existingnew_sd_ctx()/generate_video()entry points with LTX-2 defaults (LTX2_SCHEDULER, 8k+1 frame count, 32-aligned dimensions). It adds no new model code and changes no existing behaviour.src/*.cppis already globbed, so the only build change is listingltx2.hinSD_PUBLIC_HEADERS.Related Issue / Discussion
Part of the scope of the Tether bounty "LTX-2 Video Generation, qvac-ext-stable-diffusion.cpp + Bare Addon" (https://tether.dev/grants/bounties/2885262943/), which asks for a C API usable without the CLI. It builds on the LTX-2.3 engine already on
2026-06-04(#13).Additional Information
Verified on Apple M3, macOS 26.4.1, Metal build (
cmake -DSD_METAL=ON -DCMAKE_BUILD_TYPE=Release):stable-diffusionbuilds with no errors;ltx2_api.cpphas 0 warnings under-Wall -Wextra.nm libstable-diffusion.aexportsltx2_new_ctx,ltx2_free_ctx,ltx2_generate_t2v,ltx2_generate_i2v.ltx2_new_ctx()with missing model paths. It getsNULLback cleanly:ltx2-capi-smoke: PASS (ltx2_new_ctx rejected missing model files). I confirmed the check fails when inverted..clang-format.Not verified in this PR: a full generation run through the C API with real LTX-2.3 weights. Happy to add one if you point me at the checkpoint and quant you test with.
Checklist
🤖 Generated with Claude Code