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

# Cyborg Vector Search Quickstart

Get started with Cyborg Vector Search in minutes.

<Steps>
  <Step title="Install Cyborg Vector Search">
    Install Cyborg Vector Search on your machine:

    <CodeGroup>
      ```bash Python theme={null}
      # Ensure that Python 3.11 or 3.12 is installed
      # Or create a virtual environment with Python 3.11 or 3.12:
      conda create -n cyborg-env python=3.12

      # Activate the virtual environment:
      conda activate cyborg-env

      # Install Cyborg Vector Search:
      pip install cyborg_vector_search_py -i https://dl.cloudsmith.io/<token>/cyborg/cyborg-vector-search/python/simple/
      ```

      ```bash C++ theme={null}
      # Ensure that Conan is installed

      # Add the repository to your Conan remotes:
      conan remote add cyborg-vector-search https://dl.cloudsmith.io/<token>/cyborg/cyborg-vector-search/conan
      conan remote login cyborg-vector-search -p <token> cyborg

      # Install Cyborg Vector Search:
      conan install cyborg_vector_search -r cyborg-vector-search
      ```
    </CodeGroup>

    <Note>You will need to replace `<token>` with your token provided by Cyborg.</Note>
  </Step>

  <Step title="Create a Client">
    Create a Cyborg Vector Search client:

    <CodeGroup>
      ```python Python theme={null}
      import cyborg_vector_search_py as cvs
      import secrets

      # Using `memory` storage for this example
      # `redis` and `postgres` are also supported

      index_location = cvs.DBConfig("memory")  # Where encrypted index is stored (for queries)
      config_location = cvs.DBConfig("memory") # Where encrypted index config is stored (for config/loading)
      items_location = cvs.DBConfig("memory")  # Where item contents are stored (for upsert/get)

      # Create a client
      client = cvs.Client(index_location, config_location, items_location)
      ```

      ```cpp C++ theme={null}
      #include "cyborg_vector_search/client.hpp"
      #include "cyborg_vector_search/encrypted_index.hpp"
      #include <array>
      #include <random>

      // Using `memory` storage for this example
      // `redis` and `postgres` are also supported

      cyborg::LocationConfig index_location(Location::kMemory);  // Where encrypted index is stored (for queries)
      cyborg::LocationConfig config_location(Location::kMemory); // Where encrypted index config is stored (for config/loading)
      cyborg::LocationConfig items_location(Location::kMemory);  // Where item contents are stored (for upsert/get)

      // Create a client
      cyborg::Client client(index_location, config_location, items_location);
      ```
    </CodeGroup>

    For more info, refer to [Create a Client](../encrypted-indexes/create-client).
  </Step>

  <Step title="Create an Encrypted Index">
    Create an encrypted index with Cyborg Vector Search:

    <CodeGroup>
      ```python Python theme={null}
      # ... Continuing from the previous step

      # Create an IVFFlat index config (can also be IVF/IVFPQ)
      # Using an example vector dimension of 128, and number of lists of 1024
      index_config = cvs.IndexIVFFlat(dimension=128, n_lists=1024)

      # Generate an encryption key for the index
      index_key = secrets.token_bytes(32)

      # Create an encrypted index
      index = client.create_index("my_index", index_key, index_config)
      ```

      ```cpp C++ theme={null}
      /// ... Continuing from the previous step

      // Create an IVFFlat index config (can also be IVF/IVFPQ)
      // Using an example vector dimension of 128, and number of lists of 1024
      cyborg::IndexIVFFlat index_config(dimension=128, n_lists=1024);

      // Generate a 32-byte random encryption key
      std::array<uint8_t, 32> index_key;
      std::random_device rd;
      std::generate(index_key.begin(), index_key.end(), [&]() { return rd() % 256; });

      // Create an encrypted index
      cyborg::EncryptedIndex index = client.CreateIndex("my_index", index_key, index_config);
      ```
    </CodeGroup>

    For more info, refer to [Create an Encrypted Index](../encrypted-indexes/create-index).
  </Step>

  <Step title="Add Items to Encrypted Index">
    Add data to the encrypted index via Upsert:

    <CodeGroup>
      ```python Python theme={null}
      # ... Continuing from the previous step

      # Add items to the encrypted index
      items = [
          {"id": 1, "vector": [0.1, 0.2, 0.3, 0.4], "item": "Hello!"},
          {"id": 2, "vector": [0.5, 0.6, 0.7, 0.8]}, "item": "Hello!",
          {"id": 3, "vector": [0.9, 0.10, 0.11, 0.12], "item": "Hello!"}
      ]

      index.upsert(items)
      ```

      ```cpp C++ theme={null}
      // ... Continuing from the previous step

      // Add items to the encrypted index
      std::vector<uint64_t> ids = {1, 2, 3};
      cyborg::Array2D vectors = {{0.1, 0.2, 0.3, 0.4}, {0.5, 0.6, 0.7, 0.8}, {0.9, 0.10, 0.11, 0.12}};

      index.Upsert(vectors, ids);
      ```
    </CodeGroup>

    For more info, refer to [Add Items](../data-operations/add-items).
  </Step>

  <Step title="Query Encrypted Index">
    Query the encrypted index for similar vectors.

    <CodeGroup>
      ```python Python theme={null}
      # ... Continuing from the previous step

      # Query the encrypted index
      query_vector = [0.1, 0.2, 0.3, 0.4]
      results = index.query(query_vector)

      # Print the results
      for result in results:
          print(f"ID: {result.id}, Distance: {result.distance}")
      ```

      ```cpp C++ theme={null}
      // ... Continuing from the previous step
      std::vector<float> query_vector = {0.1, 0.2, 0.3, 0.4};
      cyborg::QueryResults results = index.Query(query_vector);

      // Print the results
      for (const auto& result : results) {
          std::cout << "ID: " << result.id << ", Distance: " << result.distance << std::endl;
      }
      ```
    </CodeGroup>

    For more info, refer to [Query an Encrypted Index](../data-operations/query).
  </Step>

  <Step title="Retrieve Items from Encrypted Index">
    Retrieve data from the encrypted index:

    <CodeGroup>
      ```python Python theme={null}
      # ... Continuing from the previous step

      # Retrieve items from the encrypted index
      ids = [1, 2, 3]
      items = index.get_items(ids)

      # Print the items
      for i in range(len(ids)):
          print(f"ID: {ids[i]}, Contents: {items[i]}")
      ```

      ```cpp C++ theme={null}
      // ... Continuing from the previous step

      // Retrieve items from the encrypted index
      std::vector<uint64_t> ids = {1, 2, 3};
      cyborg::Array2D<uint8_t> items = index.GetItems(ids);

      // Print the items
      for (size_t i = 0; i < ids.size(); i++) {
          std::cout << "ID: " << ids[i] << ", Contents: " << items[i] << std::endl;
      }
      ```
    </CodeGroup>

    For more info, refer to [Get Items](../data-operations/get-items).
  </Step>

  <Step title="Next Steps">
    Learn more about Cyborg Vector Search:

    <CardGroup>
      <Card title="About Cyborg Vector Search" href="./about" icon="book-open-cover">
        Learn about the architecture, design and deployment of Cyborg Vector Search.
      </Card>

      <Card title="API Docs" href="../../api-reference" icon="code">
        Explore the API reference to learn how to use Cyborg Vector Search in your applications.
      </Card>
    </CardGroup>
  </Step>
</Steps>
