Skip to main content

Inferential Python SDK

Python client and server SDK for Inferential inference orchestration. The Python package includes the client SDK (for sending observations and receiving results) and the server (scheduling and dispatch to local models or Ray Serve).

Install

# Client + edge server (pyzmq, protobuf, numpy, pydantic — no Ray)
pip install inferential

# With Ray Serve for distributed serving
pip install inferential[ray]

# Development
pip install inferential[dev]

Quick Start

See the full Quick Start guide for step-by-step setup.

Edge Server (LocalDispatcher — no Ray)

import asyncio
import numpy as np
from inferential import Server, LocalDispatcher

def my_policy(obs: dict) -> dict:
    dim = 7
    for v in obs.values():
        if isinstance(v, np.ndarray) and v.ndim == 1:
            dim = v.shape[0]
            break
    return {"actions": np.random.randn(dim).astype(np.float32)}

dispatcher = LocalDispatcher({"policy-v2": my_policy})
server = Server(bind="tcp://*:5555", dispatcher=dispatcher)

@server.on_metric
def log(name, value, labels):
    if name == "inference_latency_ms":
        print(f"Client {labels.get('client')}: {value:.1f}ms")

asyncio.run(server.run())

Ray Serve Server (distributed)

import asyncio
import numpy as np
from ray import serve
from inferential import Server

@serve.deployment
class MockPolicy:
    def infer(self, obs: dict) -> dict:
        dim = 7
        for v in obs.values():
            if isinstance(v, np.ndarray) and v.ndim == 1:
                dim = v.shape[0]
                break
        return {"actions": np.random.randn(dim).astype(np.float32)}

serve.run(MockPolicy.bind(), name="policy-v2")

server = Server(bind="tcp://*:5555", models=["policy-v2"])  # defaults to RayDispatcher
asyncio.run(server.run())

Client (sync)

import numpy as np
from inferential import Connection

conn = Connection(server="tcp://localhost:5555", client_id="agent-01", client_type="franka")
model = conn.model("policy-v2", latency_budget_ms=30.0)

state = np.random.randn(7).astype(np.float32)
model.observe(urgency=0.8, state=state)

result = model.get_result(timeout_ms=50)
if result is not None:
    actions = result["actions"]  # np.ndarray

conn.close()

Client (async)

import asyncio
import numpy as np
from inferential import AsyncConnection

async def main():
    async with AsyncConnection(server="tcp://localhost:5555", client_id="agent-01") as conn:
        model = conn.model("policy-v2", latency_budget_ms=30.0)

        state = np.random.randn(7).astype(np.float32)
        await model.observe(urgency=0.8, state=state)

        result = await model.get_result(timeout_ms=50)
        if result is not None:
            actions = result["actions"]  # np.ndarray

asyncio.run(main())

API Reference

Connection(server, client_id, client_type, reconnect_ivl_ms=100, reconnect_max_ms=5000)

Creates a ZMQ DEALER connection to the server. The server address can be with or without the tcp:// prefix.

AsyncConnection(server, client_id, client_type, ...)

Async variant using zmq.asyncio.Context. Supports async with for automatic cleanup.

conn.model(model_id, latency_budget_ms=50.0, priority=1) → Model / AsyncModel

Creates a handle to a specific model on the server.

model.observe(urgency=0.0, steps_remaining=None, **kwargs)

Sends an observation to the server. Keyword arguments are automatically dispatched:

  • np.ndarray values → serialized as tensors (dtype/shape preserved)
  • str values → passed as metadata key-value pairs
  • urgency (float, 0.0–1.0) → scheduling priority hint
  • steps_remaining (int) → remaining steps in trajectory
model.observe(
    urgency=0.5,
    steps_remaining=120,
    state_vector=np.zeros(7, dtype=np.float32),
    image=np.zeros((3, 224, 224), dtype=np.uint8),
    prompt="describe the scene",  # → metadata
)

model.get_result(timeout_ms=100) → dict | None

Waits for a response. Returns a dict mapping tensor keys to numpy arrays, or None on timeout. Also includes response_id, model_id, inference_latency_ms, and any metadata from the server.

conn.close()

Closes the ZMQ socket. Called automatically by AsyncConnection.__aexit__.

Server Configuration

See Architecture for full details on schedulers, queue management, metrics, and configuration schema.

Documentation

  • Quick Start — Install, run server + client, get your first result
  • Architecture — System design, wire protocol, schedulers, metrics
  • Examples — Multi-language client demos, server extensions
  • Contributing — Commit conventions, branching, code style

Metadata

Release files for inferential 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for inferential 1.4.0
File Size Uploaded Provenance
inferential-1.4.0.tar.gz 224.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for inferential 1.4.0
File Interpreter ABI Platform
inferential-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 265.8 kB

Release files / inferential-1.4.0.tar.gz

Download URL inferential-1.4.0.tar.gz
Size 224.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4b9023e7340a6d1abeab42f3a4e642a8359e8d57946c8ed210d130f5ae20c2fa
BLAKE2b-256 checksum
How to use checksums
04aedd0f200ea42ff0f19ec8c2837ac5895944aec314ea15f5d93a2a164d44df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / inferential-1.4.0-py3-none-any.whl

Download URL inferential-1.4.0-py3-none-any.whl
Size 41.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a68b3ed60ff9e5a0a3607c5b6d5953ebf64a1a445d66340ac31e710bb07b363
BLAKE2b-256 checksum
How to use checksums
e75e80c12fe36fbd2e29fd887d82b76218cc3349813efc74ee0172e3ae7bc709
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for inferential 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page