Expand description
§entelix-memory-openai
Concrete entelix_memory::Embedder implementation backed by
OpenAI’s /v1/embeddings endpoint. Ships the
text-embedding-3-{small,large} models plus operator-supplied
custom model identifiers for forward compatibility.
Companion to the trait-only entelix_memory crate (invariant
13’s “trait-only entelix-memory” principle): concrete vendor
impls live in their own crate so the core memory trait surface
ships without pulling reqwest + secrecy for users who
provide their own embedder.
§One-call setup
ⓘ
use std::sync::Arc;
use entelix_core::auth::ApiKeyProvider;
use entelix_memory_openai::OpenAiEmbedder;
let credentials = Arc::new(ApiKeyProvider::new(
"authorization",
format!("Bearer {}", std::env::var("OPENAI_API_KEY")?),
)?);
let embedder = OpenAiEmbedder::small().with_credentials(credentials).build()?;§Invariant alignment
- Invariant 10 — credentials never reach
Tool::execute. The embedder holds anArc<dyn CredentialProvider>and resolves per-call; no token enters request scope state. - F10 —
Embedderis wrapped inArcat the call boundary. Cloning the embedder is cheap (Arc::cloneof the innerreqwest::Clientplus a credential handle). - F4 —
EmbeddingUsageis populated only on theOkbranch ofembed/embed_batch; failed calls produce no phantom token charge in downstream meters.
Structs§
- Open
AiEmbedder - Concrete
Embedderbacked by OpenAI’s/v1/embeddingsHTTPS endpoint. Stateless beyond the connection pool insidereqwest::Client; clone freely or wrap inArcper F10. - Open
AiEmbedder Builder - Builder for
OpenAiEmbedder.
Enums§
- Open
AiEmbedder Error - Errors that can surface from
OpenAiEmbedder.
Constants§
- DEFAULT_
BASE_ URL - Default OpenAI API base URL. Override via
OpenAiEmbedderBuilder::with_base_urlfor proxies, regional endpoints, or test fixtures. - TEXT_
EMBEDDING_ 3_ LARGE - OpenAI’s higher-quality embedding model. Native dimension 3072;
can be reduced via the
dimensionsrequest parameter. - TEXT_
EMBEDDING_ 3_ LARGE_ DIMENSION - Native dimension of
TEXT_EMBEDDING_3_LARGE. - TEXT_
EMBEDDING_ 3_ SMALL - OpenAI’s lower-cost embedding model. Native dimension 1536; can
be reduced via the
dimensionsrequest parameter (operatorwith_dimensionon the builder). - TEXT_
EMBEDDING_ 3_ SMALL_ DIMENSION - Native dimension of
TEXT_EMBEDDING_3_SMALL.
Type Aliases§
- Open
AiEmbedder Result - Result alias used inside
entelix-memory-openai.