---
title: "Deploy SigLIP 2 | (Just Updated) Image + Text Embedding API, Zero-Shot Classifier, API Key Pre-Set"
description: "SigLIP 2 image embedding API: CLIP alternative, text search, zero-shot, CPU"
category: "AI/ML"
url: https://railway.com/deploy/siglip-2-or-just-updated-image-text-embe
---

# Deploy SigLIP 2 | (Just Updated) Image + Text Embedding API, Zero-Shot Classifier, API Key Pre-Set

SigLIP 2 image embedding API: CLIP alternative, text search, zero-shot, CPU

**[Deploy SigLIP 2 | (Just Updated) Image + Text Embedding API, Zero-Shot Classifier, API Key Pre-Set on Railway](https://railway.com/template/siglip-2-or-just-updated-image-text-embe)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/siglip-2-or-just-updated-image-text-embe/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** AI/ML

## Template content

### siglip2

- **Image:** ghcr.io/bon5co/siglip2-railway:1.0.0@sha256:909da484016f2d64fedc6e80aee51eb2c661ae65d5134428fbcafa77871316d8
- **Health check:** /health
- **Public domain:** Yes

## Documentation

# Deploy and Host SigLIP 2 (Image and Text Embedding API) on Railway

An image embedding API turns pictures and text into vectors in one shared space, so you can search photos with a sentence, find similar images, or classify an image against labels you invent at request time. This template serves Google's SigLIP 2 (`siglip2-base-patch16-224`), a CLIP-style model, on CPU behind one authenticated HTTP API. The weights are already inside the image, an API key is generated for you at deploy, and no GPU is needed.

## About Hosting SigLIP 2

The service runs `google/siglip2-base-patch16-224` (Apache-2.0, 768-dimensional embeddings, 224 px input, pre-trained on WebLI) with PyTorch 2.15.0 and transformers 5.24.0 behind a small FastAPI server. `POST /embed/image` takes up to 16 images per request, as multipart `file` parts or one raw `image/*` body, and returns one L2-normalised 768-number vector per image. `POST /v1/embeddings` (alias `/embed/text`) takes `{"input": "text"}` or a list of strings and returns the OpenAI embeddings response shape, so existing clients work after changing the base URL. Image and text vectors share one space: the dot product of a text vector and an image vector is their similarity, which is what text-to-image search over a vector database needs. `POST /classify` takes one image and a list of `labels` (comma-separated or a JSON array) and returns each label's probability, best first, with no training step. SigLIP scores every label on its own with a sigmoid, so the probabilities do not add up to 1 and an image can match several labels, or none; a `softmax` over the labels is returned as well for the pick-one case. `GET /v1/models` lists the model and the limits in force.

The weights are baked into the image and verified by sha256 at build time, so nothing downloads at boot and the model is ready about 5 seconds after the container starts. The service sizes its thread pool from the container's own CPU quota, handles one request at a time so memory stays bounded, accepts JPEG, PNG, WebP, GIF, BMP and TIFF checked by their magic bytes, refuses an image over 10 MiB or 50 million pixels (`413`), and answers `415` for any other content type. Images and text are held in memory for the length of one request and are never logged or written to disk.

**Measured on Railway, 8 vCPU:** model time (the `X-Processing-Seconds` header) was **about 0.08 s** for a 640x480 or 1920x1080 JPEG embedding and **0.18 to 0.20 s** for a 5184x3456 (5 MB) classify call with two labels, which a whole request over the public URL finished in **0.8 to 1.0 s** including the upload. Embedding three short texts took **0.05 s**. Twenty concurrent 1080p image uploads finished in **2.1 s** wall clock, about **10 images per second**, and twenty concurrent requests of three texts each in **1.6 s**. The model loaded in **4.5 s**. Resident memory was **1.43 GB** after boot and peaked at **1.49 GB**.

**What it does not do.** Retrieval accuracy was not benchmarked here: the checks were that the service loads, that its image and text vectors match the Hugging Face reference processor on the same inputs (cosine similarity 0.9999995 for an image and 1.0 for a text), that a labelled photo of a bee on a flower ranks "bee on the flower" above "a car", and that bad input and bad keys are refused. This is the base model at 224 px, so fine detail and small text in a large photo are lost when it is resized; text is cut to 64 tokens. SigLIP 2 is trained on web image-text pairs, so it inherits their biases; check the model card before using it to label people. The probability numbers are uncalibrated: a good match can score 0.2, so rank labels against each other rather than against a fixed 0.5.

### Agent contract

- Public URL: `https://RAILWAY_PUBLIC_DOMAIN` (the generated domain of the `siglip2` service)
- Private URL: `http://siglip2.railway.internal:8080`
- Credentials: the `API_KEY` variable of the `siglip2` service
- Auth: send `Authorization: Bearer $API_KEY` on every route except `GET /health`; a call without the key or with a wrong one answers `401`
- Health: `GET /health` returns 200 once the model is loaded (503 while it loads)

```bash
# needs: RAILWAY_PUBLIC_DOMAIN, API_KEY (a variable of the siglip2 service); also curl and base64.
# signup: none - the API has no user accounts, only the API_KEY bearer
R="https://$RAILWAY_PUBLIC_DOMAIN"
echo iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg== | base64 -d | tee /tmp/px.png | wc -c
n=0; until [ "$(curl -s -o /dev/null -w '%{http_code}' "$R/health")" = 200 ]; do n=$((n+1)); [ "$n" -le 60 ] || break; sleep 5; done
curl -s -o /dev/null -w "health: %{http_code}\n" "$R/health"
curl -s -o /dev/null -w "write without key: %{http_code}\n" -X POST "$R/classify?labels=a%20photo,a%20diagram" -F file=@/tmp/px.png
curl -s -o /dev/null -w "write wrong key: %{http_code}\n" -X POST "$R/classify?labels=a%20photo,a%20diagram" -H "Authorization: Bearer not-the-key" -F file=@/tmp/px.png
curl -s -X POST "$R/classify?labels=a%20photo,a%20diagram" -H "Authorization: Bearer $API_KEY" -F file=@/tmp/px.png
curl -s -X POST "$R/v1/embeddings" -H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" -d '{"input":"a bee on a flower"}' | head -c 160; echo
```

A fresh deploy prints `health: 200`, `write without key: 401`, `write wrong key: 401`, a JSON result whose `results` lists both labels with a `probability` and a `softmax` and a `best` label, and the start of a 768-number embedding under `data[0].embedding`. A file that is not an image answers `422`, an image over the size or pixel limit answers `413`, a content type that is neither multipart nor `image/*` answers `415`, and an empty text or a missing `labels` answers `422`. The API only reads the image and text you send and never fetches a URL, so it cannot be pointed at an address inside your network.

## Why Deploy SigLIP 2 on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying SigLIP 2 on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

- **Your images stay in your container** — embedding runs in your own service, not in a hosted vision API that sees every upload.
- **One model for image and text** — the same 768-dimensional space serves text-to-image search, image-to-image search and zero-shot labels.
- **No GPU bill and no per-image fee** — you pay for the container, not for each embedding.
- **OpenAI-shaped text endpoint** — `POST /v1/embeddings` returns the familiar response, so a client library needs only a new base URL.
- **Open weights, commercial use** — the model card declares the Apache-2.0 licence.
- **Private by default** — a generated bearer key guards every route but the health check, and the container refuses to start without one.

## Common Use Cases

- **Semantic photo search** — embed every image once, store the vectors in pgvector, Qdrant or Milvus, and embed the user's sentence to find the closest photos.
- **Zero-shot tagging** — send an image with the labels you care about today ("receipt", "screenshot", "product photo") and change them tomorrow without retraining.
- **Duplicate and near-duplicate detection** — compare image vectors by cosine similarity to group visually similar uploads.

## Dependencies for SigLIP 2 Hosting

- A service with **at least 2 GB of RAM** (resident memory measured at 1.43 GB after boot and 1.49 GB at peak) and 8 vCPU for the speeds above; fewer vCPU embed proportionally slower.
- No volume: the service keeps no state and the model is in the image.

### Deployment Dependencies

- [google/siglip2-base-patch16-224](https://huggingface.co/google/siglip2-base-patch16-224) — the model, Apache-2.0 per its model card, pinned to commit 75de2d55ec2d0b4efc50b3e9ad70dba96a7b2fa2
- [SigLIP 2 paper](https://arxiv.org/abs/2502.14786) — Tschannen et al., 2025
- [bon5co/siglip2-railway](https://github.com/bon5co/siglip2-railway) — the Railway wrapper image this template deploys, Apache-2.0
- Licences: the Hugging Face model card declares `license: apache-2.0`; the repository carries no separate LICENSE file, so the card metadata is the licence statement. PyTorch is BSD-3-Clause and transformers is Apache-2.0. The notices travel with the image at `/app/NOTICE`.


## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [Weaviate](https://railway.com/deploy/weaviate-1) — Vector database with hybrid search and an API key-protected API
- [Möbius Personal AI OS](https://railway.com/deploy/mobius-v01-personal-ai-os) — Self-hosted AI agent that builds and runs apps for you, with memory.

Open this page in a browser: https://railway.com/deploy/siglip-2-or-just-updated-image-text-embe
