SigLIP 2 FASTAPI MICROSERVICE

Turn images into meaning.

A small, secured service that embeds any product photo into a 768-dimensional, L2-normalized vector. Store them once, then let shoppers search your catalogue with a single picture — cosine similarity in the same latent space.

768
DIMENSIONS
1 · 16
PER BATCH
L2
NORMALIZED
product.jpg
INPUT · IMAGE
siglip2-base
ENCODER
COSINE SIMILARITY
0.94 match
ONE SHARED SPACE

Ingestion and search speak the same language.

Both workflows call this one service — powered by SigLIP 2 — so stored vectors and query vectors always live in the same latent space. Cosine similarity is just a dot product, because every vector is unit-normalized.

01 / INGESTION

A product is added

The API fetches each product image, embeds it, and upserts one row per image into product_embeddings. Re-runs are safe.

  1. Download image from CDN
  2. Encode to 768-d vector
  3. Upsert into pgvector
02 / SEARCH

A shopper uploads a photo

One call to /products/search embeds the query image and ranks every stored product by its closest image — so a product is returned at most once.

  1. POST /products/search
  2. Rank by cosine distance (pgvector)
  3. Return the closest product ids
THE API SURFACE

Five endpoints. No noise.

Every embedding route is guarded by X-API-Key. Only the health probe stays open.

HARDENED BY DESIGN

Built to be called server-to-server — never by a browser.

Deploy behind a TLS-terminating proxy on a private network. Keys live in your secret manager; docs vanish in production.

GET RUNNING

From zero to a
vector in minutes.

Spin it up with uv, point it at your Postgres, and start embedding. The first launch caches the SigLIP 2 weights (~400 MB) locally.

01

Copy the env — set CLIP_API_KEYS and CLIP_ENVIRONMENT=development.

02

Sync & runuv sync then uv run fastapi dev app/main.py.

03

Embed an image — POST it with your key and read back 768 floats.


                        

Response: { model, dimensions: 768, embedding: [...] }

SEARCH-BY-IMAGE, SOLVED

Give your catalogue a sense of sight.

One microservice, one embedding space, a thousand product matches. Wire it into your Laravel API and let a photo do the searching.