Concepts
SemiLayer is an intelligence layer that sits between your application and your database. It reads your existing data, embeds it into vectors, and exposes semantic operations — search, similarity, live streaming, and direct queries — through a typed client or REST API.
Your database stays where it is. SemiLayer never writes to it.
Architecture
Search and similar go through SemiLayer's index — your source is NOT hit at query time.
Query goes through the bridge — it reads directly from your source with your declared
WHERE filters. Enable it explicitly with rules.query in your lens config.
Multi-Tenancy Hierarchy
Organization
Top-level scope — your company or team. Billing, member management, and encryption keys are per-Organization.
Project
A logical application within an Organization. Provides namespace isolation for Lenses and API keys. You might have one Project per product or per microservice.
Environment
A deployment stage within a Project. Default is development. Production apps typically
use development, staging, and production environments, each with their own Sources,
Lenses, and API keys.
Use semilayer init to select or create your context. The selection is stored in
.semilayerrc so subsequent CLI commands know where to operate.
Sources and Bridges
A Source is a connection to an existing data source. You manage Sources via the CLI or Console. Credentials are stored encrypted per-organization.
A Bridge is the adapter that knows how to read from a specific data source type. The @semilayer/bridge-postgres
bridge ships first-party. Additional bridges are available via the Bridge SDK ecosystem.
In your config, a Source names the bridge to use:
The Bridge interface is simple: connect, read pages of records, and count. Bridges handle connection pooling and cursor-based pagination internally.
Lenses
A Lens is the core concept in SemiLayer — a declaration of intelligence over a table or collection. You define which fields to embed, which facets to enable, and who can access them.
Field Types
| Type | Purpose |
|---|---|
text | Free-form string |
number | Integer or float |
boolean | true/false |
date | ISO date/datetime |
json | Arbitrary JSON |
enum | One of a declared set of values |
relation | Foreign key reference |
Mark fields for embedding with searchable: true. Embedded fields are concatenated
and converted to a vector during ingest. At query time, the search text is embedded
and compared against these vectors via cosine similarity.
You can weight fields to boost relevance:
Field Mapping
When your source column name differs from the output field name, use from:
See Schema (Config) for the complete mapping and transform reference.
Lens Status
| Status | Meaning |
|---|---|
paused | Schema registered, no ingest running (default after push) |
indexing | Ingest is actively reading, embedding, and indexing |
ready | Ingest complete, all records indexed, queries enabled |
error | Ingest failed — check semilayer status for details |
Facets
Facets are the semantic operations available on a Lens. Declare them in your config.
search — Semantic search. Embeds the query text and finds the nearest vectors.
Supports semantic, keyword (fulltext), and hybrid modes.
similar — Find records similar to a given record by its stored vector. Takes a
source record ID, returns nearest neighbors.
feed — Personalized or curated lists. Combines vector similarity with recency
and diversity signals. (v0.2)
dedup — Identify near-duplicate records. Useful for deduplicating user-generated
content or imported data. (v0.2)
classify — Assign records to categories using vector proximity to labeled examples.
Zero-shot or few-shot. (v0.2)
The Beam Client
The Beam is a generated, typed client. Run semilayer generate to create it from
your config. It lives in a semilayer/ directory alongside your application code.
The generated module exports a Beam class and a createBeam factory:
Every Lens in your config becomes a property on the Beam instance, fully typed based
on your field declarations:
See Beam Client for the full class reference.
API Keys
API keys authenticate requests. Each Environment has its own set.
| Prefix | Type | Use |
|---|---|---|
sk_dev_ | Secret, development | Backend, local dev |
sk_live_ | Secret, production | Backend, production |
pk_dev_ | Public, development | Client-side, local dev |
pk_live_ | Public, production | Client-side, production |
ik_dev_ | Ingest, development | Webhook ingest only |
ik_live_ | Ingest, production | Webhook ingest only |
Secret keys (sk_) have full access. Public keys (pk_) are restricted to read-only
queries and are safe in frontend bundles. Ingest keys (ik_) can only trigger ingest —
not query.
The Ingest Pipeline
Ingest runs as a background worker, coordinated through a durable job queue.
Full ingest (push --rebuild) re-indexes all records from scratch.
Incremental ingest (push --resume-ingest) picks up from the last cursor.
Use syncInterval or webhooks to keep the index fresh as your data changes.
See Push & Ingest for the full sync options.
Ready to get started? Head to the Quickstart to be up and running in under 5 minutes.