Skip to main content
A session is a local, in-process index you read and write in real time, with no cloud round trip on any operation. Sessions are how the Python SDK does indexing during a live interaction: indexing transcript turns mid-call, building a per-user working set, or accumulating context that is handed off between agents. A session is a SessionIndex, created from client.session(). For the full method list, see the SDK reference.

Create or resume

client.session(index_name=...) returns a SessionIndex. If a cloud index with that name already exists, it auto-loads into the session (no re-embedding); otherwise the session starts empty. The workflow is identical in both cases, so you do not branch on whether the index exists.

Mutate and query locally

add_docs, delete_docs, and get_docs run in-memory; add_docs embeds locally via the Rust core with no network call. query also runs entirely in-memory (~1-10 ms) and supports the same metadata filter syntax as client.query().

Persist to the cloud

push_index() uploads the session - documents and their locally-computed embeddings - to the cloud under the session’s name, creating or replacing that index. No server-side re-embedding occurs.

Extend an existing index

Because session() resumes by name, the same code extends an index across runs. Resume, append new documents, then push back to overwrite the cloud copy with the combined set.

Live-call context: short-term plus long-term

A session is short-term context - the working set for the current interaction. A persistent cloud index loaded with load_index() is long-term context - durable knowledge shared across interactions. A typical live call loads a cloud FAQ index for long-term context and opens a session for short-term context, then queries both for each turn.

Behavior notes

  • The session’s embedding model is set by model_id on session() (default "moss-minilm"; also "moss-mediumlm" or "custom"). When resuming an existing cloud index, omit model_id to adopt the stored model - passing a different one raises a ValueError. All participants resuming the same index must use the same model.
  • With model_id="custom", each document must carry its own .embedding and every query must pass QueryOptions.embedding. See Custom embeddings.
  • Project credentials are validated when the session is opened; session() raises if they are invalid.

SessionIndex reference

Every session method and property.

Metadata filtering

Filter inside a session query.