Skip to main content
The Moss Elixir SDK (moss on Hex.pm) brings semantic search to Elixir applications. Documents are embedded and queried on-device through a high-performance Rust core, with optional cloud sync. The SDK ships built-in embedding models, hybrid (semantic + keyword) search, and per-session indexing for real-time workflows.

Requirements

  • Elixir 1.15 or higher
  • OTP 26 or higher
  • Valid Moss project credentials (project_id and project_key)

Install

Add moss to your dependencies in mix.exs:
Then fetch it:
Sign up at the Moss portal to get your project_id and project_key. The Elixir SDK exposes two entry points:
  • Moss.Client - the entry point. Construct it with your credentials, manage cloud indexes, and load indexes into memory for fast local querying.
  • Moss.Session - a local, in-session index. Index documents in memory during a live workflow with no cloud round trips, then push to the cloud when done.

Load before query

Querying always runs against an index that has been loaded into memory. Call Moss.Client.load_index/3 first, then Moss.Client.query/4. Queries run entirely in-memory with no network round trip. There is no query path that runs without first loading the index (or opening a session).

Quick start

Create a client, create and populate a cloud index, load it, and query:

Sessions

For real-time indexing during live workflows (voice AI agents, chat), open a session. Documents are indexed in memory with no cloud round trip, and you can push the index to the cloud when done:

Models

Two built-in embedding models run entirely in the Rust core:
  • moss-minilm - lightweight, optimized for speed (the default).
  • moss-mediumlm - higher accuracy with reasonable performance.
Pass model_id: "custom" to supply your own pre-computed embeddings via DocumentInfo.embedding. With a custom model, each document must set embedding, and queries must pass an embedding: option.

Reference