# Search images

> Find ranked images from across the live web by text or by a reference image, each with its source page and dimensions.

Source: https://docs.generalinput.com/api/platform/image-search



<Endpoint method="POST" path="/v1/platform/image-search" />

<Access scope="platform:use" />

Finds images on the live web and returns them ranked, structured for code or a model to use. Search with words, or pass a reference image to find images that look like it.

## Body [#body]

Send exactly one of `query` or `referenceImage`. A request with both, or neither, is a `400`.

| Field            | Type    | Required     | Notes                                                                                      |
| ---------------- | ------- | ------------ | ------------------------------------------------------------------------------------------ |
| `query`          | string  | one of these | What to find, up to 500 characters.                                                        |
| `referenceImage` | object  | one of these | `{ "url": "https://…" }` for a public image, or `{ "data": "<base64>" }` for one you hold. |
| `maxResults`     | integer | no           | 1 to 10. Default 5.                                                                        |

A reference image can be JPEG, PNG, WEBP, BMP, or TIFF, up to 5 MB. A `url` must be `https` on a domain name, since a plain `http` link or a bare IP address is a `400`. `data` also accepts a data URI.

Text searches walk the workspace's provider order, set in Settings → Built-in services. A reference image goes only to a provider that can read one. Providers filter adult content where they support it; a fallback provider may not.

## Response [#response]

```json
{
  "results": [
    {
      "title": "Red sports coupe",
      "imageUrl": "https://example.com/photo.jpg",
      "sourcePageUrl": "https://example.com/gallery",
      "description": "A red coupe parked on a coastal road.",
      "width": 2560,
      "height": 1920,
      "thumbnailUrl": "https://cdn.example.com/thumb.jpg"
    }
  ],
  "responseTime": 0.64
}
```

`description`, `width`, `height`, and `thumbnailUrl` are `null` when the provider that served the search doesn't return them. `thumbnailUrl` can stop working within hours, so keep `imageUrl`.

An image the provider can't read, such as a dead link or a page that isn't an image, usually returns an empty `results` list rather than an error, and that search is still billed.

Images belong to the sites they came from. Check the rights on `sourcePageUrl` before you publish one.

## Errors [#errors]

| Status | Meaning                                                      |
| ------ | ------------------------------------------------------------ |
| `400`  | The request is invalid.                                      |
| `403`  | Image search is turned off for this workspace.               |
| `422`  | A provider refused the request, usually an unreadable image. |
| `502`  | No provider could answer. Try again shortly.                 |

## Example [#example]

```sh
curl -s -X POST https://cloud.generalinput.com/v1/platform/image-search \
  -H "Authorization: Bearer $GI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"DJI Mavic 4 Pro in flight","maxResults":5}'
```

Find images that look like one you have:

```sh
curl -s -X POST https://cloud.generalinput.com/v1/platform/image-search \
  -H "Authorization: Bearer $GI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"referenceImage":{"url":"https://example.com/product.jpg"}}'
```
