> 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)
