🔌Connecting to the Service
This guide explains how to establish and verify the connection to the enVector service using the Python client SDK.
Initializing the Connection
For details on how to initialize the connection using ev.init_connect(), please refer to the Initialize Connection page documentation.
Example
Here is a basic example of how to initialize the connection:
import pyenvector as ev
# Initialize the connection to a local enVector service
ev.init_connect(address="localhost:50050", access_token=None)Access Tokens
If your server is configured with authentication or you are using enVector SaaS, you must provide an access_token:
import os
import pyenvector as ev
token = os.environ.get("ENVECTOR_ACCESS_TOKEN") # or your configured token
ev.init_connect(address="api.envector.example:50050", access_token=token)Notes:
Omit
access_tokenor passNoneonly when your local/server deployment does not require authentication.Store tokens securely (e.g., environment variables, secret managers), and never commit them to source control.
Checking the Connection Status
After running the initialization, you can verify whether the connection to the enVector service was successfully established. The ev.is_connected() function is used for this purpose.
This function returns a boolean value:
Trueif the connection is active and ready.Falseif the connection has not been established or has been lost.
Example
You can use this function to confirm the connection status before making other calls.
import pyenvector as ev
# Initialize the connection
ev.init_connect(address="localhost:50050", access_token=None)
# Check if the connection is successful
if ev.is_connected():
print("Successfully connected to ev! ✅")
else:
print("Failed to connect to ev. ❌")
# Returns: True
is_active = ev.is_connected()
print(f"Connection status: {is_active}")Last updated

