> ## 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.

# __init__

Initializes a new CyborgVectorStore instance for use with LangChain.

<Tabs>
  <Tab title="Embedded">
    ```python theme={null}
    CyborgVectorStore(
        index_name: str,
        index_key: bytes | list[int] | tuple[int, ...] | np.ndarray,
        api_key: str,
        embedding: Embeddings,
        index_location: DBConfig,
        config_location: DBConfig,
        items_location: Optional[DBConfig] = None,
        index_type: str = "ivfsq",
        index_config_params: Optional[Dict[str, Any]] = None,
        dimension: Optional[int] = None,
        metric: str = "cosine",
        gpu_config: Optional[GPUConfig] = None
    )
    ```

    ### Parameters

    | Parameter             | Type                                                  | Description                                                                                |
    | --------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------ |
    | `index_name`          | `str`                                                 | Name of the index (must be unique)                                                         |
    | `index_key`           | `bytes \| list[int] \| tuple[int, ...] \| np.ndarray` | 32-byte encryption key for securing index data                                             |
    | `api_key`             | `str`                                                 | API key for CyborgDB authentication                                                        |
    | `embedding`           | `Embeddings`                                          | LangChain Embeddings instance                                                              |
    | `index_location`      | `DBConfig`                                            | Configuration for index data storage location                                              |
    | `config_location`     | `DBConfig`                                            | Configuration for index config storage location                                            |
    | `items_location`      | `Optional[DBConfig]`                                  | *(Optional)* Location for item data storage (default: memory)                              |
    | `index_type`          | `str`                                                 | Type of index: `"ivfflat"`, `"ivfpq"`, or `"ivfsq"` (default: `"ivfsq"`)                   |
    | `index_config_params` | `Optional[Dict[str, Any]]`                            | *(Optional)* Additional index configuration parameters                                     |
    | `dimension`           | `Optional[int]`                                       | *(Optional)* Embedding dimension (auto-inferred if not provided)                           |
    | `metric`              | `str`                                                 | Distance metric: `"cosine"`, `"euclidean"`, or `"squared_euclidean"` (default: `"cosine"`) |
    | `gpu_config`          | `Optional[GPUConfig]`                                 | *(Optional)* GPU configuration for accelerated operations                                  |

    ### Returns

    `CyborgVectorStore`: Initialized vector store instance

    ### Example Usage

    ```python theme={null}
    from cyborgdb_core.integrations.langchain import CyborgVectorStore
    from cyborgdb_core import DBConfig
    from langchain_openai import OpenAIEmbeddings

    # Generate a secure key
    index_key = CyborgVectorStore.generate_key(save=True)

    # Initialize with LangChain Embeddings
    store = CyborgVectorStore(
        index_name="my_documents",
        index_key=index_key,
        api_key="your-api-key",
        embedding=OpenAIEmbeddings(),
        index_location=DBConfig("rocksdb"),
        config_location=DBConfig("rocksdb"),
        index_type="ivfsq",
        metric="cosine"
    )
    ```
  </Tab>

  <Tab title="Python SDK">
    ```python theme={null}
    CyborgVectorStore(
        index_name: str,
        index_key: bytes,
        api_key: str,
        embedding: Union[str, Embeddings, SentenceTransformer],
        base_url: str,
        verify_ssl: Optional[bool] = None,
        index_type: str = "ivfflat",
        index_config_params: Optional[Dict[str, Any]] = None,
        dimension: Optional[int] = None,
        metric: str = "cosine"
    )
    ```

    ### Parameters

    | Parameter             | Type                                          | Description                                                                                           |
    | --------------------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
    | `index_name`          | `str`                                         | Name of the index (must be unique)                                                                    |
    | `index_key`           | `bytes`                                       | 32-byte encryption key for securing index data                                                        |
    | `api_key`             | `str`                                         | API key for CyborgDB authentication                                                                   |
    | `embedding`           | `Union[str, Embeddings, SentenceTransformer]` | Embedding model name or instance                                                                      |
    | `base_url`            | `str`                                         | Base URL of the CyborgDB microservice endpoint                                                        |
    | `verify_ssl`          | `Optional[bool]`                              | *(Optional)* SSL verification. When `None`, automatically disabled for `localhost` and `http://` URLs |
    | `index_type`          | `str`                                         | Type of index: `"ivfflat"`, `"ivfpq"`, or `"ivfsq"` (default: `"ivfflat"`)                            |
    | `index_config_params` | `Optional[Dict[str, Any]]`                    | *(Optional)* Additional index configuration parameters                                                |
    | `dimension`           | `Optional[int]`                               | *(Optional)* Embedding dimension (auto-inferred if not provided)                                      |
    | `metric`              | `str`                                         | Distance metric: "cosine", "euclidean", or "squared\_euclidean" (default: "cosine")                   |

    ### Returns

    `CyborgVectorStore`: Initialized vector store instance

    <Note>The Python SDK requires a running CyborgDB service. Use `base_url` to point to your service endpoint instead of providing `DBConfig` storage locations.</Note>

    ### Example Usage

    ```python theme={null}
    from cyborgdb.integrations.langchain import CyborgVectorStore

    # Generate a secure key
    index_key = CyborgVectorStore.generate_key(save=True)

    # Initialize with string embedding model name
    store = CyborgVectorStore(
        index_name="my_documents",
        index_key=index_key,
        api_key="your-api-key",
        embedding="sentence-transformers/all-MiniLM-L6-v2",
        base_url="http://localhost:8000",
        index_type="ivfflat",
        metric="cosine"
    )
    ```
  </Tab>

  <Tab title="JS/TS">
    ```typescript theme={null}
    new CyborgVectorStore(embeddings: EmbeddingsInterface, config: CyborgVectorStoreConfig)
    ```

    ### Parameters

    | Parameter    | Type                      | Description                      |
    | ------------ | ------------------------- | -------------------------------- |
    | `embeddings` | `EmbeddingsInterface`     | LangChain embeddings instance    |
    | `config`     | `CyborgVectorStoreConfig` | Configuration object (see below) |

    ### CyborgVectorStoreConfig

    | Parameter           | Type                     | Description                                                                                             |
    | ------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------- |
    | `baseUrl`           | `string`                 | Base URL of the CyborgDB microservice endpoint                                                          |
    | `apiKey`            | `string`                 | API key for CyborgDB authentication                                                                     |
    | `indexName`         | `string`                 | Name of the index (must be unique)                                                                      |
    | `indexKey`          | `Uint8Array`             | 32-byte encryption key for securing index data                                                          |
    | `indexType`         | `string`                 | *(Optional)* Type of index: `"ivfflat"`, `"ivfpq"`, or `"ivfsq"` (default: `"ivfflat"`)                 |
    | `indexConfigParams` | `Record<string, number>` | *(Optional)* Additional index configuration parameters                                                  |
    | `dimension`         | `number`                 | *(Optional)* Embedding dimension (auto-inferred if not provided)                                        |
    | `metric`            | `string`                 | *(Optional)* Distance metric: `"cosine"`, `"euclidean"`, or `"squared_euclidean"` (default: `"cosine"`) |
    | `verifySsl`         | `boolean`                | *(Optional)* SSL verification (default: `true`)                                                         |

    ### Returns

    `CyborgVectorStore`: Initialized vector store instance

    <Note>The JS/TS SDK requires a running CyborgDB service. Use `baseUrl` to point to your service endpoint instead of providing `DBConfig` storage locations.</Note>

    ### Example Usage

    ```typescript theme={null}
    import { CyborgVectorStore } from 'cyborgdb';
    import { OpenAIEmbeddings } from '@langchain/openai';

    const store = new CyborgVectorStore(
        new OpenAIEmbeddings(),
        {
            baseUrl: "http://localhost:8000",
            apiKey: "your-api-key",
            indexName: "my_documents",
            indexKey: CyborgVectorStore.generateKey(),
            indexType: "ivfflat",
            metric: "cosine"
        }
    );
    ```
  </Tab>
</Tabs>

### Exceptions

<AccordionGroup>
  <Accordion title="ValueError">
    * Throws if index\_type is invalid
  </Accordion>

  <Accordion title="RuntimeError">
    * Throws if no embedding model provided and dimension not specified
  </Accordion>
</AccordionGroup>
