Skip to main content
Go to documentation:
⌘U
Weaviate Database

Develop AI applications using Weaviate's APIs and tools

Deploy

Deploy, configure, and maintain Weaviate Database

Query Agent

Run agentic search over your Weaviate Cloud collections

Weaviate Cloud

Manage and scale Weaviate in the cloud

Engram

Persistent memory for LLM agents and applications

Additional resources

Integrations
Weaviate Academy

Need help?

Weaviate LogoAsk AI Assistant⌘K
Support
Community Forum
Contributor guide

Web client

weaviate-client-web runs the async Python client under Pyodide, a Python runtime for WebAssembly. Use it in browser pages, marimo notebooks and Web Workers, where a plain gRPC connection is not possible.

It has the same API as the async client. gRPC calls go over gRPC-Web and REST calls go over fetch. Weaviate serves gRPC-Web on the REST port, so the client needs only one HTTP(S) endpoint.

The package was first released with client v4.25.1. It needs Python 3.11 or later and is tested on Pyodide 314.0.4 (CPython 3.14).

Install​

Install it with micropip through the grpc-web extra of the base client:

import micropip
await micropip.install("weaviate-client[grpc-web]")

The extra only applies under Pyodide, so it installs nothing on regular CPython. Installing weaviate-client-web directly also works, and pins weaviate-client to the same version. The package only imports under Pyodide.

Connect to Weaviate​

Under Pyodide, import weaviate loads the web transport automatically. If the package is missing, the import raises an ImportError that names the extra to install.

import weaviate

client = weaviate.use_async_with_local(port=8080)
await client.connect() # runs the gRPC health check over gRPC-Web

collection = client.collections.use("Article")
response = await collection.query.near_text("hello", limit=3)

To connect to Weaviate Cloud:

import weaviate
from weaviate.classes.init import Auth

client = weaviate.use_async_with_weaviate_cloud(
cluster_url=weaviate_url,
auth_credentials=Auth.api_key(weaviate_api_key),
)
await client.connect()

The connect helpers send gRPC to the REST endpoint, with the same host, port and TLS setting. You cannot change this through the helpers. use_async_with_custom() still requires the gRPC arguments. Pass the HTTP values. Any other value is replaced with the HTTP values and a warning is logged.

client = weaviate.use_async_with_custom(
http_host="localhost", http_port=8080, http_secure=False,
grpc_host="localhost", grpc_port=8080, grpc_secure=False, # same as HTTP
)
Added in v1.38.3

Weaviate serves gRPC-Web by default from v1.38.3.

The web client needs Weaviate v1.38.3 or later. For the server side, see gRPC-Web.

Browser notes​

Only the async client is available. The sync client does not run under Pyodide.

Some batching is not available. gRPC-Web has no bidirectional streaming, so client.batch.stream() and client.batch.experimental() raise immediately. Use collection.data.insert_many() instead. batch.dynamic(), batch.fixed_size() and batch.rate_limit() belong to the sync client only.

Embedded Weaviate is not supported. use_async_with_embedded() does not work in the browser.

Some settings are accepted but ignored. The browser's fetch manages connections, so these have no effect:

  • AdditionalConfig.proxies and proxy environment variables
  • Connection pool sizing and session_pool_max_retries
  • GrpcConfig.credentials. The browser trust store decides TLS.
  • GrpcConfig.channel_options, including the max message length. The server's grpcMaxMessageSize is the ceiling. Larger messages fail with RESOURCE_EXHAUSTED.

Provider API keys work in the browser. Other custom headers do not. Model provider keys passed through headers, such as X-OpenAI-Api-Key, are on Weaviate's default CORS allow-list, so they work cross-origin out of the box. Any other header fails the browser's CORS preflight unless the operator lists it in CORS_ALLOW_HEADERS on the server. Setting that variable replaces the default list, so include the defaults you still need.

A request blocked by CORS looks like a network failure (TypeError: Failed to fetch), and the client retries it.

Weaviate Cloud needs CORS enabled. In the Weaviate Cloud console, enable Allow all CORS origins in the cluster settings. The change takes a few minutes to apply. Until then, the client fails at its first REST call with a Failed to fetch error.

Browser credentials are visible to the user

Anyone who opens your page or notebook can read the keys it holds, including Weaviate and model provider API keys. Use a read-only API key with the least RBAC permissions the app needs. Never ship an admin key to a browser.

Questions and feedback​