Documents
Autocomplete
Get suggestions as the user types from any text database. There's nothing to set up. Vecstore learns words and phrases from the documents already in the database.
Note: autocomplete works with text databases only. It isn't available for image databases.
Request
Replace {id} in the path with your database ID and send what the user has typed so far.
{
"query": "wireless hea",
"limit": 5
}Query ·required
Options ·optional
Response
Returns suggestions, best first.
{
"suggestions": [
{ "text": "wireless headphones" },
{ "text": "wireless headset" }
],
"status": "ready",
"search_time": "0.42ms"
}text field with the suggested query How Suggestions Work
| Typed | Suggests | Why |
|---|---|---|
| wireless hea | wireless headphones | Completes the current word, using the word before it for context |
| wireless | wireless headphones | After a space, suggests the next word |
| headphnes | headphones | Allows one wrong letter in words of 4 to 20 characters |
Suggestions are ranked by how often they appear in your documents, and come from your content, not from what users have searched for. To show results when a user picks one, send it to Search Documents.
Index Building
The first time you call autocomplete on a database, Vecstore builds a word and phrase index from its documents. Until it's ready, the response has status: "building" and no suggestions.
{
"suggestions": [],
"status": "building",
"search_time": "0.05ms"
}After that, the index refreshes on its own as you add or delete documents. New documents show up in suggestions after the next refresh, not instantly.
Credits
Autocomplete costs 1 credit per 25 requests. Suggestions are served from memory without an embedding call, so you can call it on every keystroke. The dashboard's Autocomplete tab is billed the same way.