> For the complete documentation index, see [llms.txt](https://learn.getvectorai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.getvectorai.com/what-are-vectors/what-is-vector-search/vector-search-with-vector-ai.md).

# Vector search with code

**Assumed Knowledge**: Vectors, Vector Search, Python (Basic level)\
**Target Audience**: General developer, Data scientist, Python developer\
**Reading Time:** 5 minutes\
**Requirements**: Python 3.6 or Python 3.7

Below, we build a simple example of image search with Vector AI

1. We get the data on a document-based approach.&#x20;

```
collection_name = 'pokemon_images'

documents = []
for i in range(1, 20):
    documents.append({
        'image': 'https://assets.pokemon.com/assets/cms2/img/pokedex/full/{}.png'.format(f'{i:03}'),
        'pokemon_id' : str(i),
        '_id': i
    })
```

2\. We encode the images and instantiate the Vector AI client. If you do not have a username or API key, simply request one Pythonically from this link.

```
from vectorai.client import ViClient
vi_client = ViClient(username, api_key, url)
from vectorai.models.deployed import ViImage2Vec
image_encoder = ViImage2Vec(username, api_key, url)
for doc in documents:
    doc['image_vector_'] = image_encoder.encode(doc['image'])
```

3\. Add your documents to your index using `insert_documents`.

```
vi_client.insert_documents(collection_name, documents)
```

4\. Search your documents using `search.`

```
# Search the application
image_url = 'https://assets.pokemon.com/assets/cms2/img/pokedex/full/003.png')
search_results = vi_client.search(
collection_name,
image_encoder.encode(image_url), search_fields=['image_vector_'],
page_size=5)

# Show the results!
vi_client.show_json(search_results, image_fields=['image'], image_width=150)
```

![](/files/-MUJvFbfiAsArr01oXxp)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://learn.getvectorai.com/what-are-vectors/what-is-vector-search/vector-search-with-vector-ai.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
