Skip to main content

Module api

Module api 

Source
Expand description

API-based embedding provider (OpenAI-compatible).

Calls a remote embedding endpoint (e.g. POST /v1/embeddings) and returns dense f32 vectors suitable for sqlite-vec KNN and HNSW ANN search.

§Why this exists

The default TfIdfEmbeddingProvider produces sparse vectors that EmbeddingVector::to_f32_dense() cannot convert to f32 (embedding.rs:99 returns None for Sparse), so SqliteMemoryStore::remember() silently skips the vector insert — memory_vectors_rowids stays empty.

GgufEmbeddingProvider (feature embedding-gguf) is aarch64-only and requires a 329MB model download.

API embeddings: zero-dep (reqwest already in tree), cross-platform, and the user already has API keys configured for LLM providers.

§Config

[embedding]
endpoint = "https://api.openai.com/v1/embeddings"
api_key  = ""               # empty → inherit from active LLM provider
model    = "text-embedding-3-small"
# dimensions = 1536         # optional; defaults per model

§Failure handling

Network errors / non-2xx responses return Err. Callers in the write path (SqliteMemoryStore::remember) must treat this as non-fatal — store the text+FTS5 row and skip the vector. See Phase 2b in the design doc.

Structs§

ApiEmbeddingProvider
API-based embedding provider.

Functions§

default_dimensions
Default well-known models and their output dimensions.