weaviate.client

Client class definition.

class weaviate.client.Client(**kwargs)[source]

Bases: object

class weaviate.client.WeaviateAsyncClient(connection_params: ConnectionParams | None = None, embedded_options: EmbeddedOptions | None = None, auth_client_secret: _BearerToken | _ClientPassword | _ClientCredentials | _APIKey | None = None, additional_headers: dict | None = None, additional_config: AdditionalConfig | None = None, skip_init_checks: bool = False)[source]

Bases: _WeaviateClientBase

The v4 Python-native Weaviate Client class that encapsulates Weaviate functionalities in one object.

WARNING: This client is only compatible with Weaviate v1.23.6 and higher!

A Client instance creates all the needed objects to interact with Weaviate, and connects all of them to the same Weaviate instance. See below the Attributes of the Client instance. For the per attribute functionality see that attribute’s documentation.

Attributes:
backup

A Backup object instance connected to the same Weaviate instance as the Client.

cluster

A Cluster object instance connected to the same Weaviate instance as the Client.

collections

A _CollectionsAsync object instance connected to the same Weaviate instance as the Client.

Initialise a WeaviateClient/WeaviateClientAsync class instance to use when interacting with Weaviate.

Use this specific initializer when you want to create a custom Client specific to your Weaviate setup.

To simplify connections to Weaviate Cloud or local instances, use the weaviate.connect_to_weaviate_cloud or weaviate.connect_to_local helper functions.

Arguments:
  • connection_params: weaviate.connect.ConnectionParams or None, optional
    • The connection parameters to use for the underlying HTTP requests.

  • embedded_options: weaviate.EmbeddedOptions or None, optional
    • The options to use when provisioning an embedded Weaviate instance.

  • auth_client_secret: weaviate.AuthCredentials or None, optional
    • Authenticate to weaviate by using one of the given authentication modes:
      • weaviate.auth.AuthBearerToken to use existing access and (optionally, but recommended) refresh tokens

      • weaviate.auth.AuthClientPassword to use username and password for oidc Resource Owner Password flow

      • weaviate.auth.AuthClientCredentials to use a client secret for oidc client credential flow

  • additional_headers: dict or None, optional
  • additional_config: weaviate.AdditionalConfig or None, optional
    • Additional and advanced configuration options for Weaviate.

  • skip_init_checks: bool, optional
    • If set to True then the client will not perform any checks including ensuring that weaviate has started. This is useful for air-gapped environments and high-performance setups.

backup

This namespace contains all functionality to backup data.

cluster

This namespace contains all functionality to inspect the connected Weaviate cluster.

collections

This namespace contains all the functionality to manage Weaviate data collections. It is your main entry point for all collection-related functionality.

Use it to retrieve collection objects using client.collections.get(“MyCollection”) or to create new collections using await client.collections.create(“MyCollection”, …).

debug

This namespace contains functionality used to debug Weaviate clusters. As such, it is deemed experimental and is subject to change.

We can make no guarantees about the stability of this namespace nor the potential for future breaking changes. Use at your own risk.

roles

This namespace contains all functionality to manage Weaviate’s RBAC functionality.

class weaviate.client.WeaviateClient(connection_params: ConnectionParams | None = None, embedded_options: EmbeddedOptions | None = None, auth_client_secret: _BearerToken | _ClientPassword | _ClientCredentials | _APIKey | None = None, additional_headers: dict | None = None, additional_config: AdditionalConfig | None = None, skip_init_checks: bool = False)[source]

Bases: _WeaviateClientBase

The v4 Python-native Weaviate Client class that encapsulates Weaviate functionalities in one object.

WARNING: This client is only compatible with Weaviate v1.23.6 and higher!

A Client instance creates all the needed objects to interact with Weaviate, and connects all of them to the same Weaviate instance. See below the Attributes of the Client instance. For the per attribute functionality see that attribute’s documentation.

Attributes:
backup

A Backup object instance connected to the same Weaviate instance as the Client.

batch

A _Batch object instance connected to the same Weaviate instance as the Client.

classification

A Classification object instance connected to the same Weaviate instance as the Client.

cluster

A Cluster object instance connected to the same Weaviate instance as the Client.

collections

A _Collections object instance connected to the same Weaviate instance as the Client.

Initialise a WeaviateClient/WeaviateClientAsync class instance to use when interacting with Weaviate.

Use this specific initializer when you want to create a custom Client specific to your Weaviate setup.

To simplify connections to Weaviate Cloud or local instances, use the weaviate.connect_to_weaviate_cloud or weaviate.connect_to_local helper functions.

Arguments:
  • connection_params: weaviate.connect.ConnectionParams or None, optional
    • The connection parameters to use for the underlying HTTP requests.

  • embedded_options: weaviate.EmbeddedOptions or None, optional
    • The options to use when provisioning an embedded Weaviate instance.

  • auth_client_secret: weaviate.AuthCredentials or None, optional
    • Authenticate to weaviate by using one of the given authentication modes:
      • weaviate.auth.AuthBearerToken to use existing access and (optionally, but recommended) refresh tokens

      • weaviate.auth.AuthClientPassword to use username and password for oidc Resource Owner Password flow

      • weaviate.auth.AuthClientCredentials to use a client secret for oidc client credential flow

  • additional_headers: dict or None, optional
  • additional_config: weaviate.AdditionalConfig or None, optional
    • Additional and advanced configuration options for Weaviate.

  • skip_init_checks: bool, optional
    • If set to True then the client will not perform any checks including ensuring that weaviate has started. This is useful for air-gapped environments and high-performance setups.

backup

This namespace contains all functionality to backup data.

batch

This namespace contains all the functionality to upload data in batches to Weaviate for all collections and tenants.

close() None

In order to clean up any resources used by the client, call this method when you are done with it.

If you do not do this, memory leaks may occur due to stale connections. This method also closes the embedded database if one was started.

cluster

This namespace contains all functionality to inspect the connected Weaviate cluster.

collections

This namespace contains all the functionality to manage Weaviate data collections. It is your main entry point for all collection-related functionality.

Use it to retrieve collection objects using client.collections.get(“MyCollection”) or to create new collections using client.collections.create(“MyCollection”, …).

connect() None

Connect to the Weaviate instance performing all the necessary checks.

If you have specified skip_init_checks in the constructor then this method will not perform any runtime checks to ensure that Weaviate is running and ready to accept requests. This is useful for air-gapped environments and high-performance setups.

This method is idempotent and will only perform the checks once. Any subsequent calls do nothing while client.is_connected() == True.

Raises:
weaviate.WeaviateConnectionError

If the network connection to weaviate fails.

weaviate.UnexpectedStatusCodeException

If weaviate reports a none OK status.

debug

This namespace contains functionality used to debug Weaviate clusters. As such, it is deemed experimental and is subject to change.

We can make no guarantees about the stability of this namespace nor the potential for future breaking changes. Use at your own risk.

get_meta() dict

Get the meta endpoint description of weaviate.

Returns:
dict

The dict describing the weaviate configuration.

Raises:
weaviate.UnexpectedStatusCodeError

If Weaviate reports a none OK status.

get_open_id_configuration() Dict[str, Any] | None

Get the openid-configuration.

Returns
dict

The configuration or None if not configured.

Raises
weaviate.UnexpectedStatusCodeError

If Weaviate reports a none OK status.

graphql_raw_query(gql_query: str) _RawGQLReturn

Allows to send graphQL string queries, this should only be used for weaviate-features that are not yet supported.

Be cautious of injection risks when generating query strings.

Arguments:
gql_query

GraphQL query as a string.

Returns:

A dict with the response from the GraphQL query.

Raises
TypeError

If ‘gql_query’ is not of type str.

weaviate.WeaviateConnectionError

If the network connection to weaviate fails.

weaviate.UnexpectedStatusCodeError

If weaviate reports a none OK status.

is_live() bool
is_ready() bool
roles

This namespace contains all functionality to manage Weaviate’s RBAC functionality.