libmoss is the native C library at the core of Moss. It exposes the same API
surface as the Python moss-session and Elixir moss_session packages through
a plain C ABI, so you can embed real-time semantic search directly into C, C++,
or any language with a C FFI.
It provides two handles:
MossClient- the entry point. Construct it with your credentials, manage cloud indexes, load an index for querying, and open sessions.MossSession- a local index. Add and query documents on the same machine with no per-query network calls, then push to the cloud or pull an existing cloud index in.
Install
libmoss ships as prebuilt binary release tarballs on GitHub, one per target
triple. Download the tarball for your platform from the
releases page and extract it:
libmoss.dylib(macOS) /libmoss.so(Linux) - the shared librarylibmoss.a- the static librarylibmoss.h- the C header
libmoss is distributed only as GitHub binary releases. It is not published to
crates.io.Link
Point your compiler at the extractedlibmoss directory for both the header
(-I) and the libraries (-L).
Static linking
To produce a self-contained binary, replace-lmoss with the full path to
libmoss.a and add the platform libraries. No DYLD_LIBRARY_PATH /
LD_LIBRARY_PATH is needed at runtime.
Quick start
Open a session, add documents (embedded locally with the built-in model), query, and push the index to the cloud:MossClient instead, load it into memory first
with moss_client_load_index and then call
moss_client_query. A MossClient query always runs
against a loaded index, so the load step is required.
Every fallible call returns a
MossResult code. The quick start omits the
checks for brevity; production code should inspect the return value and call
moss_last_error() on failure. See the
examples for the full pattern.Embedding models
Pass the model viaMossSessionOptions.model_id when opening a session. The
default (NULL) uses the built-in model and embeds documents and queries
locally.
| Model | Behavior |
|---|---|
moss-minilm (default) | Auto-embeds documents and queries locally. |
moss-mediumlm | Higher quality, slightly slower. |
custom | You supply embeddings via MossDocumentInfo.embedding and MossQueryOptions.embedding. |
Next steps
- API reference - every
MossClientandMossSessionfunction, memory-management rules, error handling, and the metadata-filter format. - Examples - runnable session, cloud CRUD, and metadata-filtering programs.