# Python client for train api (when creating a model for knn indexing)

**URL:** <https://forum.opensearch.org/t/python-client-for-train-api-when-creating-a-model-for-knn-indexing/12508>\
**Category:** OpenSearch Client Libraries\
**Tags:** opensearch-py\
**Created:** [February 14, 2023, 8:48pm UTC](https://forum.opensearch.org/t/python-client-for-train-api-when-creating-a-model-for-knn-indexing/12508 "2023-02-14T20:48:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rocket](https://avatars.discourse-cdn.com/v4/letter/r/e79b87/32.png) [@rocket](https://forum.opensearch.org/u/rocket)\
**Post date:** [February 14, 2023, 8:48pm UTC](https://forum.opensearch.org/t/python-client-for-train-api-when-creating-a-model-for-knn-indexing/12508/1 "2023-02-14T20:48:59Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):  
opensearch 1.0  
opensearch-py 2.1.1

**Describe the issue** :  
I’m trying to call the train API ([this](https://opensearch.org/docs/latest/search-plugins/knn/api/#train-model)) in order to generate a model for knn-based indexing using faiss and product quantization (based on [this](https://aws.amazon.com/blogs/big-data/choose-the-k-nn-algorithm-for-your-billion-scale-use-case-with-opensearch/)). However I can’t find a way to call the train api through the python client. Is there a way that I’m missing? If not, what are my other options, if I want to invoke it through a python script.  
Thanks

**Configuration** :

**Relevant Logs or Screenshots** :

---

<div class="post-metadata">

**Author:** ![wbeckler](https://avatars.discourse-cdn.com/v4/letter/w/9d8465/32.png) [@wbeckler](https://forum.opensearch.org/u/wbeckler)\
**Post date:** [February 20, 2023, 9:54pm UTC](https://forum.opensearch.org/t/python-client-for-train-api-when-creating-a-model-for-knn-indexing/12508/2 "2023-02-20T21:54:53Z")

</div>

You’re right , there is not coverage in the python client for the train API. There’s a recently opened issue in the github repo here: [[FEATURE] wrapper for train API for creating knn index models · Issue #291 · opensearch-project/opensearch-py · GitHub](https://github.com/opensearch-project/opensearch-py/issues/291)

Typically, when the client is missing a plugin integration, you can do a curl request in your application to the API to the plugin and manage the parameters and response processing manually.

I know it’s fiddly, and feel free to submit a PR on the client itself if it makes your life easier.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/33547ea01a5b12dcca2958411d3edd97ae2ea8c1.png) [@system](https://forum.opensearch.org/u/system)\
**Post date:** [April 21, 2023, 9:55pm UTC](https://forum.opensearch.org/t/python-client-for-train-api-when-creating-a-model-for-knn-indexing/12508/3 "2023-04-21T21:55:35Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
