# Prism 2 (`prism-2`): Image tagging and image embeddings

Sharper image tags and image search, with 768-number embeddings.

Prism 2 scores an image against labels you choose ("invoice", "receipt", "selfie", "screenshot") with no training, and can return an image embedding and embed text queries into the same space. It takes the same options and returns the same fields as Prism 1, so you switch by changing the model id.

It is much more accurate. In our tests it tagged everyday photos with 0.883 mean average precision (Prism 1: 0.719), named the right breed for 94.7% of photos across 37 cat and dog breeds (Prism 1: 86.5%), and found the right caption for a photo first 90% of the time (Prism 1: 75%).

Choose Prism 1 instead when speed matters more than accuracy (it runs about 2.5 times faster per image), when your labels or queries aren't in English, or when you already store Prism 1 embeddings: the two models' vectors live in different spaces and can't be mixed.

- **Price:** $0.25 per 1,000 images. One unit per image; every 10 `texts` add one unit.
- **Languages:** Labels and text queries in English
- **Input:** An image: an https URL, a data URL (`data:image/png;base64,...`), or a file in a multipart upload. JPEG, PNG, WebP, GIF, AVIF or TIFF, up to 10 MB.
- **Batch:** no, one input per call
- **Status:** live

## Request

```bash
curl https://labs.greatwork.company/v1/run \
  -H "Authorization: Bearer $GWL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"prism-2","input":"https://labs.greatwork.company/examples/receipt.png","labels":["a receipt","a selfie","a screenshot","a landscape photo","a pet"]}'
```

Upload a local file with multipart: `curl https://labs.greatwork.company/v1/run -H "Authorization: Bearer $GWL_API_KEY" -F model=prism-2 -F input=@file`

## Options

| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| `input` | image (URL, data URL or upload) | yes | | An image: an https URL, a data URL (`data:image/png;base64,...`), or a file in a multipart upload. JPEG, PNG, WebP, GIF, AVIF or TIFF, up to 10 MB. |
| `labels` | string[] | no |  | 2 to 50 labels to score. Plain nouns work best ("a dog", "a cat"). |
| `template` | string | no | `"a photo of {label}"` | Sentence each label is placed in. |
| `embed` | boolean | no | `false` | Return the image's 768-number embedding. |
| `texts` | string[] | no |  | Text queries to embed into the same space (for image search), up to 100. |

## Output

| Field | Type | Description |
|---|---|---|
| `label` | string | Best label (when `labels` is sent). |
| `score` | number | Its probability among your labels. |
| `labels` | object[] | Every label with `score` and raw `similarity`. |
| `embedding` | number[] | 768 floats, normalized (with `embed: true`). |
| `text_embeddings` | number[][] | One 768-float vector per entry in `texts`. |

The response envelope is always `{"id", "object": "run", "model", "created", "output", "usage": {"units", "unit", "cost_usd", "cost_micros"}, "latency_ms"}`.

## Examples (real outputs from our servers)

### Upload type

```json
{
  "model": "prism-2",
  "input": "https://labs.greatwork.company/examples/receipt.png",
  "labels": [
    "a receipt",
    "a selfie",
    "a screenshot",
    "a landscape photo",
    "a pet"
  ]
}
```

```json
{
  "label": "a receipt",
  "score": 0.9986,
  "labels": [
    {
      "label": "a receipt",
      "score": 0.9986,
      "similarity": 0.1528
    },
    {
      "label": "a screenshot",
      "score": 0.0014,
      "similarity": 0.0872
    },
    {
      "label": "a landscape photo",
      "score": 0,
      "similarity": 0.0296
    },
    {
      "label": "a pet",
      "score": 0,
      "similarity": 0.0238
    },
    {
      "label": "a selfie",
      "score": 0,
      "similarity": 0.0231
    }
  ],
  "width": 560,
  "height": 760
}
```

302 ms, $0.00025.

### Scene

```json
{
  "model": "prism-2",
  "input": "https://labs.greatwork.company/examples/street.jpg",
  "labels": [
    "a city street",
    "a beach",
    "a forest",
    "an office"
  ]
}
```

```json
{
  "label": "a city street",
  "score": 0.9982,
  "labels": [
    {
      "label": "a city street",
      "score": 0.9982,
      "similarity": 0.1275
    },
    {
      "label": "an office",
      "score": 0.0017,
      "similarity": 0.064
    },
    {
      "label": "a beach",
      "score": 0,
      "similarity": 0.0271
    },
    {
      "label": "a forest",
      "score": 0,
      "similarity": 0.0064
    }
  ],
  "width": 1024,
  "height": 1024
}
```

266 ms, $0.00025.

### Pet or not

```json
{
  "model": "prism-2",
  "input": "https://labs.greatwork.company/examples/dog.jpg",
  "labels": [
    "a dog",
    "a cat",
    "a bird",
    "no animal"
  ]
}
```

```json
{
  "label": "a dog",
  "score": 0.9934,
  "labels": [
    {
      "label": "a dog",
      "score": 0.9934,
      "similarity": 0.1187
    },
    {
      "label": "no animal",
      "score": 0.0038,
      "similarity": 0.063
    },
    {
      "label": "a cat",
      "score": 0.0017,
      "similarity": 0.0548
    },
    {
      "label": "a bird",
      "score": 0.0012,
      "similarity": 0.0514
    }
  ],
  "width": 1024,
  "height": 765
}
```

253 ms, $0.00025.

### Room type

```json
{
  "model": "prism-2",
  "input": "https://labs.greatwork.company/examples/desk.jpg",
  "labels": [
    "a home office",
    "a kitchen",
    "a bedroom",
    "a store"
  ]
}
```

```json
{
  "label": "a home office",
  "score": 0.9991,
  "labels": [
    {
      "label": "a home office",
      "score": 0.9991,
      "similarity": 0.1332
    },
    {
      "label": "a bedroom",
      "score": 0.0004,
      "similarity": 0.0553
    },
    {
      "label": "a kitchen",
      "score": 0.0003,
      "similarity": 0.052
    },
    {
      "label": "a store",
      "score": 0.0001,
      "similarity": 0.0449
    }
  ],
  "width": 1024,
  "height": 765
}
```

248 ms, $0.00025.

## Good for

- Tag product photos by style with labels you choose
- Text-to-image search over a photo library
- Sort uploads into documents, photos and screenshots
- Find near-duplicate images

## Limits and caveats

- Scores are relative to the labels you send: always include a catch-all like "something else".
- Embeddings are not compatible with Prism 1's: re-embed your library (images and text queries) when you switch.
- Labels and queries in English only; use Prism 1 for other languages.
- Not reliable for counting or reading text in images (use Scout and Ink).
