Skip to main content

Generated gRPC client library for the open-inference-protocol

Project description

Open Inference Protocol gRPC Client

Package version

open-inference-grpc is a generated client library based on the gRPC protocol definition tracked in the open-inference/open-inference-protocol/ repository.


This package requires Python 3.8 or greater.

Install with your favorite tool from

$ pip install open-inference-grpc
$ poetry add open-inference-grpc

A REST-based python client (open-inference-openapi) also exists for the Open Inference Protocol, and can be installed alongside this gRPC client, as both are distributed as namespace packages.


# These dependencies are installed by open-inference-grpc
import grpc
from google.protobuf.json_format import MessageToDict

from open_inference.grpc.service import GRPCInferenceServiceStub
from open_inference.grpc.protocol import (

with grpc.insecure_channel("localhost:8081") as channel:
    client = GRPCInferenceServiceStub(channel)

    # Check that the server is live, and it has the iris model loaded

    # Make an inference request
    pred = client.ModelInfer(
                    "name": "input-0",
                    "datatype": "FP64",
                    "shape": [1, 4],
                    "contents": {"fp64_contents": [5.3, 3.7, 1.5, 0.2]},

# {
#     "modelName": "iris-model",
#     "parameters": {"content_type": {"stringParam": "np"}},
#     "outputs": [
#         {
#             "name": "output-1",
#             "datatype": "INT64",
#             "shape": ["1", "1"],
#             "parameters": {"content_type": {"stringParam": "np"}},
#             "contents": {"int64Contents": ["0"]},
#         }
#     ],
# }
Async versions of the same APIs are also available, use grpc.aio instead to create a channel then await and requests made.
async with grpc.aio.insecure_channel('localhost:8081') as channel:
    stub = GRPCInferenceServiceStub(channel)
    await stub.ServerReady(ServerReadyRequest())


The open-inference-grpc python package relies only on grpcio, the underlying transport implementation of gRPC.


This client is largely generated automatically by grpc-tools, with a small amount of build post-processing in

Run python to build this package, it will:

  1. If proto/open_inference_grpc.proto is not found, download it from open-inference/open-inference-protocol/
  2. Run grpcio_tools.protoc to create the python client
  3. Postprocess filenames and imports
  4. Prepend the Apache 2.0 License preamble
  5. Format with black

If you want to contribute to the open-inference-protocol itself, please create an issue or PR in the open-inference/open-inference-protocol repository.


By contributing to Open Inference Protocol Python client repository, you agree that your contributions will be licensed under its Apache 2.0 License.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

open_inference_grpc-2.0.0.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distribution

open_inference_grpc-2.0.0-py3-none-any.whl (9.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page