> ## Documentation Index
> Fetch the complete documentation index at: https://docs.topk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

TopK is a **hybrid retrieval engine** built on object storage for **10x lower cost** and **massive scale**. It supports dense/sparse vector search, multi-vector retrieval, powerful filtering, custom ranking, and managed inference in one API.

## Get Started

<Info>
  **Prerequisites**

  * TopK account ([Sign up here](https://console.topk.io/login))
  * TopK API key ([Get an API key here](https://console.topk.io/api-key))
</Info>

### Hybrid Search

Simple example to get you started with TopK. Check out our [guides](/guides) for more complex examples.

<Tabs>
  <Tab title="Python SDK" icon="https://mintcdn.com/topk/8NBkS0nek3e9o6Vi/icons/python.svg?fit=max&auto=format&n=8NBkS0nek3e9o6Vi&q=85&s=97cbee7891538170fd752e1afbc98095" width="128" height="128" data-path="icons/python.svg">
    <Steps>
      <Step title="Install Python SDK">
        <CodeGroup>
          ```bash pip theme={null}
          pip install topk-sdk
          ```

          ```bash uv theme={null}
          uv add topk-sdk
          ```
        </CodeGroup>
      </Step>

      <Step title="Initialize the client">
        Setup the TopK client with your API key and region.

        <CodeGroup>
          ```python Sync theme={null}
          import os
          from topk_sdk import Client

          client = Client(
              api_key=os.environ["TOPK_API_KEY"],
              region=os.environ.get("TOPK_REGION", "aws-us-east-1-elastica"),
          )
          ```

          ```python Async theme={null}
          import os
          from topk_sdk import AsyncClient

          client = AsyncClient(
              api_key=os.environ["TOPK_API_KEY"],
              region=os.environ.get("TOPK_REGION", "aws-us-east-1-elastica"),
          )
          ```
        </CodeGroup>

        <Info>See [available regions](/regions) for a full list of supported regions.</Info>
      </Step>

      <Step title="Create a collection">
        <CodeGroup>
          ```python Sync theme={null}
          client.collections().create(
            "quickstart",
            schema={
              "title": text().required().index(keyword_index()),
              "content": text().index(semantic_index()),
            }
          )
          ```

          ```python Async theme={null}
          await client.collections().create(
            "quickstart",
            schema={
              "title": text().required().index(keyword_index()),
              "content": text().index(semantic_index()),
            }
          )
          ```
        </CodeGroup>
      </Step>

      <Step title="Upsert documents">
        <CodeGroup>
          ```python Sync theme={null}
          client.collection("quickstart").upsert([
            {
                "_id": "1",
                "title": "Catcher in the Rye",
                "content": "IF YOU REALLY WANT TO HEAR about it, the first thing you'll probably want to know is ...",
                "author": "J.D. Salinger",
                "year": 1951,
            },
            {
                "_id": "2",
                "title": "1984",
                "content": "It was a bright cold day in April, and the clocks were striking thirteen. Winston Smith, ...",
                "author": "George Orwell",
                "year": 1949,
            },
            ...
          ])
          ```

          ```python Async theme={null}
          await client.collection("quickstart").upsert([
            {
                "_id": "1",
                "title": "Catcher in the Rye",
                "content": "IF YOU REALLY WANT TO HEAR about it, the first thing you'll probably want to know is ...",
                "author": "J.D. Salinger",
                "rating": 3.8
            },
            {
                "_id": "2",
                "title": "1984",
                "content": "It was a bright cold day in April, and the clocks were striking thirteen. Winston Smith, ...",
                "author": "George Orwell",
                "rating": 4.7
            },
            ...
          ])
          ```
        </CodeGroup>
      </Step>

      <Step title="Query indexed data">
        <CodeGroup>
          ```python Sync theme={null}
          from topk_sdk.query import select, field, fn

          client.collection("quickstart").query(
            select(
              # Select document fields to return
              "_id", "title", "author",
              # Compute semantic similarity of content field with the query
              similarity_score = fn.semantic_similarity(
                "content",
                "What is the meaning of life?",
              )
            )
            # Filter documents by metadata
            .filter(field("rating") >= 3.0)
            # Rank using the computed similarity score and rating
            .sort(field("rating") * field("similarity_score"), asc=False)
            # Get top 10 highest ranked documents
            .limit(10)
          )
          ```

          ```python Async theme={null}
          from topk_sdk.query import select, field, fn

          await client.collection("quickstart").query(
            select(
              # Select document fields to return
              "_id", "title", "author",
              # Compute semantic similarity of content field with the query
              similarity_score = fn.semantic_similarity(
                "content",
                "What is the meaning of life?",
              )
            )
            # Filter documents by metadata
            .filter(field("rating") >= 3.0)
            # Rank using the computed similarity score and rating
            .sort(field("rating") * field("similarity_score"), asc=False)
            # Get top 10 highest ranked documents
            .limit(10)
          )
          ```
        </CodeGroup>

        <Note>
          To learn more about how to use the Python SDK, see the [Python SDK documentation](/sdk/topk-py).
        </Note>
      </Step>
    </Steps>
  </Tab>

  <Tab title="JavaScript SDK" icon="https://mintcdn.com/topk/8NBkS0nek3e9o6Vi/icons/js.svg?fit=max&auto=format&n=8NBkS0nek3e9o6Vi&q=85&s=7642cf18b45f52a70f141214b3d0eca1" width="24" height="24" data-path="icons/js.svg">
    <Steps>
      <Step title="Install JavaScript SDK">
        <CodeGroup>
          ```bash npm theme={null}
          npm install topk-js
          ```

          ```bash yarn theme={null}
          yarn add topk-js
          ```

          ```bash pnpm theme={null}
          pnpm add topk-js
          ```
        </CodeGroup>
      </Step>

      <Step title="Initialize the client">
        Setup the TopK client with your API key and region.

        ```typescript theme={null}
        import { Client } from "topk-js";

        const client = new Client({
          apiKey: process.env.TOPK_API_KEY!,
          region: process.env.TOPK_REGION ?? "aws-us-east-1-elastica",
        });
        ```

        <Info>See [available regions](/regions) for a full list of supported regions.</Info>
      </Step>

      <Step title="Create a collection">
        ```typescript theme={null}
        import { text, keywordIndex, semanticIndex } from "topk-js/schema";

        await client.collections().create("quickstart", {
          title: text().required().index(keywordIndex()),
          content: text().index(semanticIndex()),
        });
        ```
      </Step>

      <Step title="Upsert documents">
        ```typescript theme={null}
        await client.collection("quickstart").upsert([
          {
            _id: "1",
            title: "Catcher in the Rye",
            content: "IF YOU REALLY WANT TO HEAR about it, the first thing you'll probably want to know is ...",
            author: "J.D. Salinger",
            rating: 3.8,
          },
          {
            _id: "2",
            title: "1984",
            content: "It was a bright cold day in April, and the clocks were striking thirteen. Winston Smith, ...",
            author: "George Orwell",
            rating: 4.7,
          },
          // ...
        ]);
        ```
      </Step>

      <Step title="Query indexed data">
        ```typescript theme={null}
        import { select, field, fn } from "topk-js/query";

        await client.collection("quickstart").query(
          select({
            title: field("title"),
            author: field("author"),
            // Compute semantic similarity of content field with the query
            similarity_score: fn.semanticSimilarity(
              "content",
              "What is the meaning of life?",
            ),
          })
          // Filter documents by metadata
          .filter(field("rating").gte(3.0))
          // Rank using the computed similarity score and rating
          .sort(field("rating").mul(field("similarity_score")), false)
          // Get top 10 highest ranked documents
          .limit(10)
        );
        ```

        <Note>
          To learn more about how to use the JavaScript SDK, see the [JavaScript SDK documentation](/sdk/topk-js).
        </Note>
      </Step>
    </Steps>
  </Tab>

  <Tab title="SQL" icon="database">
    <Steps>
      <Step title="Connect">
        Connect using any PostgreSQL client. Use your API key as the password.

        ```bash theme={null}
        psql "host=<region>.sql.topk.io port=5432 user=topk password=$TOPK_API_KEY dbname=topk"
        ```
      </Step>

      <Step title="Create a collection">
        ```sql theme={null}
        CREATE TABLE quickstart (
          title   TEXT NOT NULL INDEX keyword_index(),
          content TEXT          INDEX semantic_index(),
          rating  FLOAT
        );
        ```
      </Step>

      <Step title="Upsert documents">
        ```sql theme={null}
        INSERT INTO quickstart (_id, title, content, author, rating)
        VALUES
          ('1', 'Catcher in the Rye',
           'IF YOU REALLY WANT TO HEAR about it, the first thing you''ll probably want to know is ...',
           'J.D. Salinger', 3.8),
          ('2', '1984',
           'It was a bright cold day in April, and the clocks were striking thirteen. Winston Smith, ...',
           'George Orwell', 4.7);
        ```
      </Step>

      <Step title="Query indexed data">
        ```sql theme={null}
        SELECT
          _id,
          title,
          semantic_similarity(content, 'What is the meaning of life?') AS similarity_score
        FROM quickstart
        WHERE rating >= 3.0
        ORDER BY similarity_score * rating DESC
        LIMIT 10;
        ```
      </Step>
    </Steps>
  </Tab>
</Tabs>

## Integrations

<CardGroup cols={2}>
  <Card title="Python SDK" icon="https://mintcdn.com/topk/8NBkS0nek3e9o6Vi/icons/python.svg?fit=max&auto=format&n=8NBkS0nek3e9o6Vi&q=85&s=97cbee7891538170fd752e1afbc98095" href="/sdk/topk-py/overview" width="128" height="128" data-path="icons/python.svg">
    Full Python SDK reference.
  </Card>

  <Card title="JavaScript SDK" icon="https://mintcdn.com/topk/8NBkS0nek3e9o6Vi/icons/js.svg?fit=max&auto=format&n=8NBkS0nek3e9o6Vi&q=85&s=7642cf18b45f52a70f141214b3d0eca1" href="/sdk/topk-js/overview" width="24" height="24" data-path="icons/js.svg">
    Full TypeScript/JavaScript SDK reference.
  </Card>

  <Card title="CLI" icon="terminal" href="/cli">
    The command-line interface for TopK.
  </Card>
</CardGroup>

## Security & Compliance

TopK is **SOC 2 Type I** certified. Visit the [trust center](https://trust.topk.io) for full details.

<CardGroup cols={1}>
  <Card title="Data encryption" icon="lock" horizontal>
    All data is encrypted in transit and at rest.
  </Card>

  <Card title="Access control" icon="shield-check" horizontal>
    Role-based access control with full auditability.
  </Card>

  <Card title="Private Deployment" icon="server" horizontal>
    Deploy inside your own VPC for complete isolation and data residency. [Contact us](https://topk.io/contact) for more details.
  </Card>
</CardGroup>

## Learn More

<CardGroup cols={2}>
  <Card title="Architecture" icon="server" href="/architecture">
    Learn about TopK's architecture and how it works.
  </Card>

  <Card title="Concepts" icon="info" href="/concepts">
    Discover core concepts and how they work together.
  </Card>
</CardGroup>
