> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quivr.thevibecompany.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Search images

> Find a photo by its caption, a description of the scene, or a similar photo.

Add a photo to a collection and find it by caption, by describing what it shows, or with another image.

Quivr can match a photo using its caption, a description of the scene, or a similar image.

![Flow diagram showing how to add a photo and search by caption, scene description or a similar image.](https://mintcdn.com/thevibecompany/WNQ2Bou8YdEKtZhv/images/diagrams/guide-search-images.png?fit=max\&auto=format\&n=WNQ2Bou8YdEKtZhv\&q=85\&s=dc0954a41723b292a01afb51b5ee5416)

## Prerequisites

* [A running Quivr](https://docs.quivr.thevibecompany.co/get-started/launch-quivr.md) and a collection ID in `CORPUS_ID`. If you need to [create a collection](https://docs.quivr.thevibecompany.co/guides/add-content.md#send-an-article-with-a-title), use a key with `corpora:write` and access to all collections.
* Set `QUIVR_API_URL` and `QUIVR_API_KEY`. The key needs `blobs:write` to upload the image, `content:write` to add it to the collection, and `content:read` and `search:query` to find it.
* A deployment that routes your image media type to [Image metadata](https://docs.quivr.thevibecompany.co/plugins/image-metadata.md). For scene and similar-image search, the collection also needs an active vector space that indexes images, served by [EmbeddingGemma 2](https://docs.quivr.thevibecompany.co/plugins/multimodal-embed.md) through an image-capable endpoint. The Single Machine text-only encoder cannot run this path. See [Vector model](https://docs.quivr.thevibecompany.co/operate/vector-model.md).
* Bash, `curl`, `jq` and `sha256sum`. Run `command -v curl jq sha256sum` to check them. Have a JPEG named `ferry.jpg` showing a ferry docking. For the caption example, embed a caption with the word “ferry” in the file.

## Find the ferry photo

**1. Upload the photo**

These requests use your JPEG and image-enabled deployment. Quivr verifies the length and checksum before returning a Blob ID, which identifies the stored bytes.

```bash theme={null}
FILE=ferry.jpg
jq -n --argjson size "$(wc -c < "$FILE" | tr -d ' ')" \
  --arg sha "$(sha256sum "$FILE" | cut -d' ' -f1)" \
  '{size_bytes: $size, sha256: $sha, media_type: "image/jpeg"}' \
  | curl -fsS -X POST "$QUIVR_API_URL/v0/uploads" \
      -H "Authorization: Bearer $QUIVR_API_KEY" -H "Content-Type: application/json" \
      --data-binary @- > upload.json

if [ "$(jq -r .state upload.json)" = awaiting_upload ]; then
  headers=()
  while IFS= read -r header; do
    headers+=(-H "$header")
  done < <(jq -r '.upload_headers | to_entries[] | "\(.key): \(.value)"' upload.json)
  curl -fsS -X PUT "$(jq -r .upload_url upload.json)" \
    "${headers[@]}" --data-binary @"$FILE"
fi
```

Confirm the upload and poll while verification is in progress. The command exports `BLOB_ID` only after Quivr reports `verified`.

```bash theme={null}
unset BLOB_ID
upload_id=$(jq -er .upload_id upload.json)
if upload_status=$(
  for attempt in {1..30}; do
    status=$(curl -fsS --max-time 10 -X POST \
      "$QUIVR_API_URL/v0/uploads/$upload_id/confirm" \
      -H "Authorization: Bearer $QUIVR_API_KEY") || exit "$?"
    [ "$(jq -r .state <<< "$status")" = verifying ] || break
    sleep 1
  done
  printf '%s\n' "$status"
); then
  jq '{state, blob_id, error}' <<< "$upload_status"
  if BLOB_ID=$(jq -er 'select(.state == "verified") | .blob_id | strings' <<< "$upload_status"); then
    export BLOB_ID
  fi
else
  printf '%s\n' 'The upload confirmation request failed.' >&2
fi
```

If verification is still in progress after the last attempt, run this confirmation block again. If the session is rejected or expired, check `error` and upload a corrected file or a fresh export of the image. Sending the same bytes with the same media type reuses the existing session.

**2. Add the photo to your collection**

Submit a Record that refers to the Blob. The source label and Record Key identify this photo within the collection.

```bash theme={null}
test -n "${BLOB_ID:-}" && curl -fsS -X POST "$QUIVR_API_URL/v0/records" \
  -H "Authorization: Bearer $QUIVR_API_KEY" -H "Content-Type: application/json" \
  -d @- <<EOF | jq '{receipt_id}'
{
  "idempotency_key": "gallery-ferry-jpeg",
  "source": {"corpus_id": "$CORPUS_ID", "namespace": "gallery", "record_key": "ferry"},
  "content": {"kind": "blob", "blob_id": "$BLOB_ID", "media_type": "image/jpeg"}
}
EOF
```

Export the returned ID as `RECEIPT_ID` and poll until the receipt reports that the photo is searchable.

```bash theme={null}
export RECEIPT_ID='<the receipt_id above>'
```

```bash theme={null}
(
  receipt='{}'
  for attempt in {1..30}; do
    receipt=$(curl -fsS --max-time 10 "$QUIVR_API_URL/v0/ingestion-receipts/$RECEIPT_ID" \
      -H "Authorization: Bearer $QUIVR_API_KEY") || exit "$?"
    if jq -e '.availability.searchable == true
         or .outcome == "conflict"
         or .availability.state == "quarantined"
         or (.availability.state == "retrieval_ready" and .availability.is_current == false)
         or .processing.state == "blocked"' <<< "$receipt" >/dev/null; then
      break
    fi
    sleep 1
  done
  jq '{state, outcome, processing, availability, diagnostics}' <<< "$receipt"
)
```

When `availability.searchable` is true, you can search indexed captions by keyword. If the photo is still processing after the last poll, run the polling block again. If it shows a conflict, quarantine or blocked processing, check the diagnostics and the media type route. A ready Version with `is_current: false` is no longer the one search can return.

**3. Describe the scene**

Search the `gallery` source for a description. Check the returned Record IDs and thumbnails. Scene and similar-image search rely on image enrichment. The receipt can already report `availability.searchable: true` while enrichment is running or blocked. When `processing.phase` is `enrichment`, wait if it is queued, running or retrying. If `processing.state` is `blocked`, check the diagnostics and fix the cause before running either image search.

```bash theme={null}
curl -fsS -X POST "$QUIVR_API_URL/v0/search" \
  -H "Authorization: Bearer $QUIVR_API_KEY" -H "Content-Type: application/json" \
  -d @- <<EOF | jq '.items[] | {record_id, version_id, media}'
{
  "corpus_ids": ["$CORPUS_ID"],
  "query": "a passenger boat coming in to dock",
  "mode": "semantic",
  "filter": {"source_namespaces": ["gallery"], "modalities": ["image"]},
  "include_media": true
}
EOF
```

To match the embedded caption instead, use `"query": "ferry"` with `"mode": "lexical"` and remove the `modalities` filter so Quivr can match indexed caption text. To find similar images, replace `query` with `"query_blob_id": "$BLOB_ID"` and keep `semantic` mode. You can upload and verify a different photo as the query without adding it to a collection.

## What happened

Image metadata read the embedded text and prepared a thumbnail. EmbeddingGemma 2 encoded the picture for meaning search. [Core search](https://docs.quivr.thevibecompany.co/plugins/core-retrieve.md) can rank photo matches from a text or image query when the deployment serves an image-capable space. With `include_media: true`, hits with thumbnails can return a signed `media.thumbnail_url` that works until `media.thumbnail_expires_at`, even if the photo is withdrawn in the meantime.

If an image query returns `422 unsupported_search`, check that your collection serves an image-capable space and your retrieval plugin accepts image queries. If Quivr returns `422 unverified_blob`, upload and confirm the query file before searching. If it returns `422 invalid_query` for a verified non-image file, upload an image instead. Pass either `query` or `query_blob_id`. If `422 modality_filter_unavailable` appears, ask the operator to rebuild the collection’s search index once to enable the image filter.

To clean up, [withdraw the photo](https://docs.quivr.thevibecompany.co/guides/add-content.md#withdraw-an-article) using `gallery` and `ferry` as its source label and key. This removes it from future search results. You can delete the local `upload.json` after confirming the upload.

## Next

* [Search text](https://docs.quivr.thevibecompany.co/guides/search.md) with profiles and filters.
* [Check the media fields and errors](https://docs.quivr.thevibecompany.co/reference/api.md) in the search API.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.