Skip to Content
AeroSearch Docs
Quickstarts

LlamaIndex quickstart

Drive a LlamaIndex-style retriever against Collection search.

Goal: call POST /v1/collections/{collection}/search from a LlamaIndex-style retriever and receive HTTP 200 in under five minutes.

Set AEROSEARCH_BASE_URL to your Cell search host (without a route), AEROSEARCH_API_KEY to a Project search key, and AEROSEARCH_COLLECTION to its Collection id. Set AEROSEARCH_END_USER_TOKEN only when your server supplies a real end-user token.

Sample

# generated-from-contract: contracts/openapi/v1.yaml
# LlamaIndex query-engine shape — searchCollectionPost
# POST /v1/collections/col_help/search  (SearchRequest from contracts/openapi/v1.yaml)

import os
import json
import urllib.request

BASE = os.environ.get("AEROSEARCH_BASE_URL", "https://api.aerosearch.team").rstrip("/").removesuffix("/v1")
COLLECTION = os.environ.get("AEROSEARCH_COLLECTION", "col_help")
API_KEY = os.environ.get("AEROSEARCH_API_KEY", "ask_YOUR_PROJECT_SEARCH_KEY")

def aerosearch_search(query: str) -> dict:
    """Callable a LlamaIndex retriever would wrap."""
    headers = {
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json",
    }
    end_user_token = os.environ.get("AEROSEARCH_END_USER_TOKEN")
    if end_user_token:
        headers["X-AeroSearch-End-User-Token"] = end_user_token
    req = urllib.request.Request(
        f"{BASE}/v1/collections/{COLLECTION}/search",
        data=json.dumps({"query": query, "limit": 10}).encode(),
        method="POST",
        headers=headers,
    )
    with urllib.request.urlopen(req) as res:
        assert res.status == 200
        return json.loads(res.read().decode())

# Usage:
print(json.dumps(aerosearch_search("reset password")))

# Wire this into a custom LlamaIndex BaseRetriever that maps hits → Nodes.

Verify

From this repository, the local double verification executes the generated sample:

AEROSEARCH_BASE_URL=http://127.0.0.1:4418 AEROSEARCH_API_KEY=ask_search AEROSEARCH_COLLECTION=col_quickstart \
node tests/harness/quickstarts-daily/run.mjs llamaindex

On this page