`Image` search uses an **image as a search input** to perform vector similarity search.

:::accordion{title="Additional information"}
**Configure image search**

To use images as search inputs, configure an image vectorizer integration for your collection. See the model provider integrations page for a [list of available integrations](../model-provider-integrations/index.md).
:::

<!-- ## Named vectors -->

<!-- Any vector-based search on collections with [named vectors](../reference-configuration/collections.md#multiple-vector-embeddings-named-vectors) configured must include a `target` vector name in the query. This allows Weaviate to find the correct vector to compare with the query vector. -->

## By local image path

Use the `Near Image` operator to execute image search.

If your query image is stored in a file, you can use the client library to search by its filename.

:::code-group{sync="languages"}
```python title="Python" {1,5}
from pathlib import Path

dogs = client.collections.use("Dog")
response = dogs.query.near_image(
    near_image=Path("./images/search-image.jpg"),  # Provide a `Path` object
    return_properties=["breed"],
    limit=1,
    # targetVector: "vector_name" # required when using multiple named vectors
)

print(response.objects[0])
```

```typescript title="JavaScript/TypeScript"
const myCollection = client.collections.use('Dog');

// Query based on the image content
const result = await myCollection.query.nearImage('./images/search-image.jpg', {
  returnProperties: ['breed'],
  limit: 1,
  // targetVector: 'vector_name' // required when using multiple named vectors
})

console.log(JSON.stringify(result.objects, null, 2));
```

```go title="Go"
response, err := client.GraphQL().Get().
  WithClassName("Dog").
  WithFields(graphql.Field{Name: "breed"}).
  WithNearImage((&graphql.NearImageArgumentBuilder{}).WithImage("image.jpg")).
  WithLimit(1).
  Do(ctx)
```

```java title="Java" {3}
CollectionHandle<Map<String, Object>> dogs = client.collections.use("Dog");
var response = dogs.query.nearImage(
    QUERY_IMAGE_PATH,
    q -> q.returnProperties("breed").limit(1)
// targetVector: "vector_name" // required when using multiple named vectors
);

if (!response.objects().isEmpty()) {
  System.out.println(response.objects().get(0));
}
```

```csharp title="C#"
// Coming soon
```
:::

:::accordion{title="Example response"}
```json
{
  "data": {
    "Get": {
      "Dog": [
        {
          "breed": "Corgi"
        }
      ]
    }
  }
}
```
:::

## By the base64 representation

You can search by a base64 representation of an image:

:::code-group{sync="languages"}
```python title="Python" {1,7-8}
base64_string="SOME_BASE_64_REPRESENTATION"

# Get the collection containing images
dogs = client.collections.use("Dog")

# Perform query
response = dogs.query.near_image(
    near_image=base64_string,
    return_properties=["breed"],
    limit=1,
    # targetVector: "vector_name" # required when using multiple named vectors
)

print(response.objects[0])
```

```typescript title="JavaScript/TypeScript" {5,8-12}
import { toBase64FromMedia } from 'weaviate-client';

const myCollection = client.collections.use('Dog');
const filePath = './images/search-image.jpg'
const base64String = await toBase64FromMedia(file.path)

// Perform query
const result = await myCollection.query.nearImage(base64String, {
  returnProperties: ['breed'],
  limit: 1,
  // targetVector: 'vector_name' // required when using multiple named vectors
})

console.log(JSON.stringify(result.objects, null, 2));
```

```go title="Go"
response, err := client.GraphQL().Get().
  WithClassName("Dog").
  WithFields(graphql.Field{Name: "breed"}).
  WithNearImage((&graphql.NearImageArgumentBuilder{}).WithImage(base64String)).
  WithLimit(1).
  Do(ctx)
```

```java title="Java" {1,7}
String base64String = fileToBase64(QUERY_IMAGE_PATH); // This would be a real base64 string

// Get the collection containing images
CollectionHandle<Map<String, Object>> dogs = client.collections.use("Dog");

// Perform query
var response = dogs.query.nearImage(base64String,
    q -> q.returnProperties("breed").limit(1)
// targetVector: "vector_name" // required when using multiple named vectors
);

if (!response.objects().isEmpty()) {
  System.out.println(response.objects().get(0));
}
```

```csharp title="C#" {1-2}
// The C# client's NearImage method takes a byte array directly.
var imageBytes = await FileToByteArray(QUERY_IMAGE_PATH);

// Get the collection containing images
var dogs = client.Collections.Use("Dog");

// Perform query
var response = await dogs.Query.NearMedia(
    query => query.Image(imageBytes).Build(),
    returnProperties: ["breed"],
    limit: 1
);

if (response.Objects.Any())
{
    Console.WriteLine(JsonSerializer.Serialize(response.Objects.First()));
}
```
:::

:::accordion{title="Example response"}
```json
{
  "data": {
    "Get": {
      "Dog": [
        {
          "breed": "Corgi"
        }
      ]
    }
  }
}
```
:::

## Create a base64 representation of an online image

You can create a base64 representation of an online image, and use it as input for similarity search [as shown above](#by-the-base64-representation).

:::code-group{sync="languages"}
```python title="Python"
import base64, requests

def url_to_base64(url):
    image_response = requests.get(url)
    content = image_response.content
    return base64.b64encode(content).decode("utf-8")

base64_img = url_to_base64("https://upload.wikimedia.org/wikipedia/commons/thumb/1/14/Deutsches_Museum_Portrait_4.jpg/500px-Deutsches_Museum_Portrait_4.jpg")
```

```typescript title="JavaScript/TypeScript"
const imageURL = 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/14/Deutsches_Museum_Portrait_4.jpg/500px-Deutsches_Museum_Portrait_4.jpg'

async function urlToBase64(imageUrl: string) {
  const response = await fetch(imageUrl);
  const content = await response.buffer();
  return content.toString('base64');
}

const base64 = await urlToBase64(imageURL)
console.log(base64)
```

```go title="Go"
resp, err := http.Get(url)
if err != nil {
  return "", err
}
defer resp.Body.Close()

content, err := ioutil.ReadAll(resp.Body)
if err != nil {
  return "", err
}

base64string := base64.StdEncoding.EncodeToString(content)
```

```javaraw title="Java"
private static String urlToBase64(String url)
    throws IOException, InterruptedException {
  HttpClient httpClient = HttpClient.newHttpClient();
  HttpRequest request = HttpRequest.newBuilder().uri(URI.create(url)).build();
  HttpResponse<byte[]> response =
      httpClient.send(request, HttpResponse.BodyHandlers.ofByteArray());
  byte[] content = response.body();
  return Base64.getEncoder().encodeToString(content);
}

private static String fileToBase64(String path) throws IOException {
  byte[] content = Files.readAllBytes(Paths.get(path));
  return Base64.getEncoder().encodeToString(content);
}
```

```csharp title="C#"
private static async Task<string> UrlToBase64(string url)
{
    using var httpClient = new HttpClient();
    var imageBytes = await httpClient.GetByteArrayAsync(url);
    return Convert.ToBase64String(imageBytes);
}

private static async Task<byte[]> FileToByteArray(string path)
{
    return await File.ReadAllBytesAsync(path);
}
```
:::

## Combination with other operators

A `Near Image` search can be combined with any other operators (like filter, limit, etc.), just as other similarity search operators.

See the [`similarity search`](similarity.md) page for more details.

## Related pages

- [Connect to Weaviate](../connect-to-weaviate/index.md)

## Questions and feedback

Have a question or feedback? Here's how to reach us.

::::card-grid
:::card{title="Community Forum" href="https://forum.weaviate.io/c/support" icon="messages-square"}
Ask questions and connect with other developers on our **Community forum**.
:::

:::card{title="Support" href="/guides/support-overview" icon="life-buoy"}
Weaviate Cloud user or customer? Find the right channel on the **Support page**.
:::
::::

## Related pages

- [Agents](./agents-index.md)
- [AI-assisted Weaviate code generation](./ai-assisted-vibe-coding-index.md)
- [APIs](./apis-index.md)
- [Authorization and authentication](./authorization-and-authentication-index.md)
- [Benchmarks](./benchmarks-index.md)
- [Best practices](./best-practices-index.md)
- [Client libraries](./clients-index.md)
- [Client Libraries / SDKs](./client-libraries-index.md)
- [Cloud](./cloud-index.md)
- [Cloud account management](./cloud-account-management-index.md)

# Agent Instructions

This portal answers questions programmatically. To receive a synthesized,
source-cited answer instead of crawling page by page, append the `?ask=`
query parameter to any page URL on this site:

    /guides/quickstart?ask=how+do+I+authenticate

Optional parameters:

- `&goal=<what-you-are-trying-to-do>` steers the answer toward your
  objective (e.g. `&goal=write+a+python+client`).
- `&version=<label>` scopes the answer to a mounted version when the
  portal publishes more than one.

The response is `text/markdown`: the answer followed by a `# Sources` list
of the portal pages it was grounded in. Status codes are the contract:

- `200` — the answer; `402` — the portal owner’s plan or answer credits are
  exhausted (surface this to your operator; do NOT retry); `429` — you are
  rate-limited; back off for the `Retry-After` seconds; `503` — the answer
  lane is temporarily unavailable; fall back to crawling the `.md` pages.

For the full corpus map read `llms.txt` at the site root; for the tool
surface (search + page fetch as MCP tools) see `/mcp`.
