> ## 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: Union[str, Embeddings],
        storage_config: StorageConfig,
        gpu_config: Optional[GPUConfig] = 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 \| list[int] \| tuple[int, ...] \| np.ndarray` | 32-byte encryption key for securing index data |
    | `api_key` | `str` | API key for CyborgDB authentication |
    | `embedding` | `Union[str, Embeddings]` | LangChain Embeddings instance, or the name of a built-in embedding model |
    | `storage_config` | `StorageConfig` | Backing-store configuration, built with `StorageConfig.disk(...)` or `StorageConfig.s3(...)` |
    | `gpu_config` | `Optional[GPUConfig]` | *(Optional)* GPU configuration for accelerated operations |
    | `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

    ### Example Usage

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

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

    # Initialize with LangChain Embeddings
    store = CyborgVectorStore(
        index_name="my_documents",
        index_key=index_key,
        api_key="your-api-key",
        embedding=OpenAIEmbeddings(),
        storage_config=StorageConfig.disk("/var/lib/cyborgdb"),
        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,
        dimension: Optional[int] = None,
        metric: str = "cosine",
        verify_ssl: Optional[bool] = None
    )
    ```

    ### 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 |
    | `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 a `StorageConfig`; storage is configured on the service.</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",
        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 |
    | `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; storage is configured on the service.</Note>

    ### Example Usage

    ```typescript theme={null}
    import { CyborgVectorStore } from 'cyborgdb/integrations/langchain';
    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(),
            metric: "cosine"
        }
    );
    ```
  </Tab>
</Tabs>

### Exceptions

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


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.