Skip to main content
MuBit supports both HTTP/REST and gRPC transports. All SDK methods work identically regardless of transport — the choice affects performance characteristics, not API surface.

When to use gRPC vs HTTP

FactorgRPCHTTP
LatencyLower per-call overhead (binary protocol, persistent connections)Slightly higher due to JSON serialization
StreamingNative bidirectional streaming (Subscribe, StreamSearch, WatchMemory)SSE for events, no bidirectional streaming
DebuggingRequires gRPC tooling (grpcurl, Bloom RPC)curl, browser dev tools
Proxies/CDNsRequires HTTP/2-aware infrastructureWorks everywhere
Browser clientsRequires grpc-web proxyNative fetch/XMLHttpRequest
Recommendation: Use gRPC for backend services where you want lower latency and streaming. Use HTTP for browser clients, serverless functions, or environments with HTTP/1.1-only proxies.

Configuration

Environment variables

.env
MUBIT_TRANSPORT="grpc"
MUBIT_GRPC_ENDPOINT="grpc.api.mubit.ai:443"

SDK constructor

from mubit import Client

client = Client(
    api_key="mbt_...",
    transport="grpc",
    # endpoint defaults to grpc.api.mubit.ai:443
)

Endpoints

EnvironmentgRPC endpointTLS
Hosted (production)grpc.api.mubit.ai:443Yes (system CA)
Hosted (dev)grpc.api.dev.mubit.ai:443Yes (system CA)
Local127.0.0.1:50051No (plaintext)
TLS is handled automatically by the SDK — no certificate configuration is needed for hosted endpoints.

Proto file locations

The proto definitions are available in the repository:
Proto fileServiceDescription
proto/mubit/v1/core.protoMubitServiceCore data-plane operations (insert, search, memory, sessions)
proto/mubit/v1/control.protoControlServiceControl-plane operations (ingest, query, context, reflection, coordination)
These can be used with any gRPC code generator if you need a client outside the official SDKs.

Streaming RPCs

gRPC enables streaming RPCs not available over HTTP:
RPCDirectionPurpose
Subscribe (Control)Server → ClientStream control-plane events in real-time
StreamSearch (Core)Server → ClientStream search results as they’re found
WatchMemory (Core)Server → ClientWatch for scratchpad memory changes
# Stream control events
async for event in client.control.subscribe(run_id="my-run"):
    print(f"Event: {event.type}{event.data}")

Auto transport

When transport is set to "auto" (the default), the SDK:
  1. Checks if a gRPC connection can be established to the endpoint
  2. Falls back to HTTP if gRPC is unavailable
  3. Caches the result for subsequent calls
This works well for most deployments. Set an explicit transport when you need deterministic behavior or want to avoid the initial probe.

Troubleshooting

SymptomCauseFix
Connection refused on port 50051gRPC server not running or wrong endpointVerify endpoint; for local, ensure make run-mubit is running
TLS handshake failureSelf-signed cert or wrong CAFor hosted endpoints, ensure system CA store is current
UNIMPLEMENTED errorProto version mismatchUpdate SDK to latest version
DEADLINE_EXCEEDEDNetwork timeoutCheck connectivity; increase timeout in client config
Fields missing in responsekeepCase not set (JS SDK < v0.4.1)Update @mubit-ai/sdk to >= v0.4.1

Next steps