> For the complete documentation index, see [llms.txt](https://docs.neuralens.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.neuralens.ai/reference/api-reference/autocomplete.md).

# Autocomplete

## Autocomplete API

The Autocomplete API returns suggestions for the autocompleter, as the user types the query in the search bar. It is suggested to wait at least 300ms between keystrokes before calling the API.&#x20;

<mark style="color:green;">`POST`</mark> `https://api.neuralens.ai/search/autocomplete`

Autocomplete API can return lists of query suggestions, and products that match the query. Use appropriate `limit` values as per use case.

### Request Headers

| Header                     | Value                       |
| -------------------------- | --------------------------- |
| X-Neuralens-API-Key        | Bearer YOUR\_API\_KEY\_HERE |
| X-Neuralens-Application-ID | YOUR\_APPLICATION\_ID       |

### Request Params

<table><thead><tr><th width="138">Param</th><th>Value</th></tr></thead><tbody><tr><td>partition</td><td>Partition field's value (required in case partitioning is done)</td></tr></tbody></table>

Let's say `partition` is enabled on field "continent", then when sending request for the continent "asia", partition will be `asia`

### Request Body

```json
{
    "query": "appl",
    "limit": {
        "text": 10,
        "products": 10
    },
    "fields": ["id","title","images","productUrl"],
    "analytics": {
        "userId": "87023"
    }
}
```

`query` The text typed by the user

`limit` *text* limit and *products* limits are the number of text results and product results required in response. One of these is required.

`fields` Fields required in response

`analytics` For personalization and performance tuning

### Response

```json
{
    "qid": "4fcb0b58-e040-4aa0-96cf-859692f77f53",
    "results": {
        "text": [
            {
                "title": "Apple",
                "images": ["https://cdn.example.com/123"],
            },
            ...
        ],
        "products": [
            {
                "id": "AD176",
                "type": "product",
                "title": "Apple - Fuji",
                "images": ["https://cdn.example.com/123", "https://cdn.example.com/789"],
                "productUrl": "https://example.com/product/AD176"
            },
            ...
        ]
    }
}
```


---

# 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://docs.neuralens.ai/reference/api-reference/autocomplete.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.
