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

# Image Tags and Search

> Tag images with what's in them, then search your media by tag

Dreep can look at an image and tell you what's in it: objects, scenes, colours
and activities, each with a confidence score. Tags are saved on the image, so you
can search your media by what it shows and build filters on top of it.

```json theme={null}
{
  "tags": [
    { "name": "sneaker", "confidence": 98.2, "source": "ai" },
    { "name": "red", "confidence": 91.0, "source": "ai" },
    { "name": "outdoors", "confidence": 76.4, "source": "ai" }
  ]
}
```

Tag names are lowercase. Dreep doesn't identify people.

The Node.js examples use the [Node SDK](https://docs.dreep.cloud/node-sdk/introduction.md):

```typescript theme={null}
import { Dreep } from "dreep";

const dreep = new Dreep({ apiKey: process.env.DREEP_API_KEY });
```

## Tag images as you upload them

Add `autoTag=true` to an upload. The upload returns straight away and tagging
happens in the background.

```typescript Node.js theme={null}
const asset = await dreep.upload({
  file: fs.createReadStream("sneaker.jpg"),
  folder: "products",
  autoTag: true,
});

asset.tagStatus; // "pending"

// Presigned uploads too: tagging starts once the upload is confirmed
const upload = await dreep.presignUpload({ contentType, sizeBytes, autoTag: true });
```

```bash cURL theme={null}
curl -X POST "https://api.dreep.cloud/api/v1/upload" \
  -H "Authorization: Bearer drp_live_xxxxx" \
  -F "file=@sneaker.jpg" \
  -F "folder=products" \
  -F "autoTag=true"
```

The response includes `"tagStatus": "pending"`. Presigned uploads take
`autoTag` too, and tagging starts once the upload is confirmed.

`tagStatus` then becomes one of:

| Status | Meaning |
| :- | :- |
| `pending` | Waiting to be tagged, or waiting for the upload to finish |
| `done` | Tags are saved on the image |
| `failed` | The image couldn't be tagged, or its upload never finished |
| `skipped` | The account had no credit left for tagging. The upload itself still succeeded |

```typescript Node.js theme={null}
const { tagStatus, tags } = await dreep.getMediaTags({ id: asset.id });
```

```bash cURL theme={null}
curl "https://api.dreep.cloud/api/v1/media/2f928a3f-1d2a-4a2b/tags" \
  -H "Authorization: Bearer drp_live_xxxxx"
```

## Tag an image that's already stored

```typescript Node.js theme={null}
const { tags } = await dreep.tagMedia({ id: asset.id });
// [{ name: "sneaker", confidence: 98.2, source: "ai" }, …]
```

```bash cURL theme={null}
curl -X POST "https://api.dreep.cloud/api/v1/media/2f928a3f-1d2a-4a2b/tags" \
  -H "Authorization: Bearer drp_live_xxxxx"
```

Running it again replaces Dreep's tags with fresh ones. Tags you set yourself are
kept.

## Set your own tags

Send the full list you want the image to have. Anything not in it is removed, and
an empty list removes every tag.

```typescript Node.js theme={null}
await dreep.setMediaTags({ id: asset.id, tags: ["red shoe", "summer sale"] });

// Remove every tag
await dreep.setMediaTags({ id: asset.id, tags: [] });
```

```bash cURL theme={null}
curl -X PUT "https://api.dreep.cloud/api/v1/media/2f928a3f-1d2a-4a2b/tags" \
  -H "Authorization: Bearer drp_live_xxxxx" \
  -H "Content-Type: application/json" \
  -d '{ "tags": ["red shoe", "summer sale"] }'
```

Tags may use letters, numbers, spaces and hyphens, up to 64 characters each and 50
per image. They're stored lowercase.

## Search by tag

Pass `tags` to [List Media](https://docs.dreep.cloud/api-reference/media/list-media.md). By default an image
needs every tag; add `match=any` to accept images with at least one.

```typescript Node.js theme={null}
// Images carrying every tag
const { assets } = await dreep.listMedia({ tags: ["dog", "beach"] });

// Images carrying at least one
const { assets: pets } = await dreep.listMedia({ tags: ["dog", "cat"], match: "any" });

assets[0].tags; // ["dog", "beach", "sand", …]
```

```bash cURL theme={null}
# Images carrying every tag
curl "https://api.dreep.cloud/api/v1/media?tags=dog,beach" \
  -H "Authorization: Bearer drp_live_xxxxx"

# Images carrying at least one
curl "https://api.dreep.cloud/api/v1/media?tags=dog,cat&match=any" \
  -H "Authorization: Bearer drp_live_xxxxx"
```

Every image in the media list carries a `tags` array. Files have no tags, so a
tag search never returns them.

To build filters or autocomplete, [List Tags](https://docs.dreep.cloud/api-reference/image-tags/list-tags.md)
returns every tag in the project with how many images carry it.

```typescript Node.js theme={null}
const tags = await dreep.listTags({ search: "sne" });
// [{ name: "sneaker", imageCount: 12 }, …]
```

```bash cURL theme={null}
curl "https://api.dreep.cloud/api/v1/tags?q=sne" \
  -H "Authorization: Bearer drp_live_xxxxx"
```

## Tag an image without storing it

[Tag Image](https://docs.dreep.cloud/api-reference/image-tags/tag-image.md) takes a file and returns its
tags without saving anything:

```typescript Node.js theme={null}
const { tags, cached } = await dreep.tagImage({
  file: fs.createReadStream("photo.heic"),
  minConfidence: 80,
});
```

```bash cURL theme={null}
curl -X POST "https://api.dreep.cloud/api/v1/image-tagging" \
  -H "Authorization: Bearer drp_live_xxxxx" \
  -F "file=@photo.heic" \
  -F "minConfidence=80"
```

Any image Dreep can read is accepted, HEIC and AVIF included. Large photos are
fine; Dreep shrinks them before tagging.

## Billing

Tagging is charged per image at your plan's usage rate, from your included usage
or your credit. It works on every plan, pay as you go included. You aren't
charged when:

* The same image was tagged before. Dreep reuses the earlier result, and the
  response says `"cached": true`
* Nothing could be found in the image
* Tagging fails

Reading tags, setting your own tags and searching are free.


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