Skip to main content

The Buf logo

protoc-gen-grpc-py

PyPI version License Slack

protoc-gen-grpc-py generates well-typed, idiomatic gRPC stubs for protobuf-py, the ergonomic and modern Protobuf library for Python.

Fully typed clients and servicers you can read. asyncio and sync variants.
Plugs into your existing grpcio channels and servers.

Quickstart • Example • protobuf-py

It's a compatibility layer for projects already built on grpcio. The generated clients and servicers plug into your existing gRPC channels and servers, but serialize protobuf-py messages directly. This lets you upgrade to a better Protobuf package without touching your RPC stack.

Quickstart

Generated code requires the runtime libraries protobuf-py and grpcio. The plugin works with Protobuf compilers like buf.

$ uv add protobuf-py grpcio
$ uv add --dev protoc-gen-py protoc-gen-grpc-py buf-bin

Add protoc-gen-grpc-py alongside protoc-gen-py in your buf.gen.yaml:

version: v2
inputs:
  - directory: proto
plugins:
  # Generates message types (*_pb.py).
  - local: protoc-gen-py
    out: src/gen
  # Generates gRPC service stubs (*_pb_grpc.py).
  - local: protoc-gen-grpc-py
    out: src/gen

To generate code for all Protobuf files within your project, run:

$ uv run -- buf generate

A *_pb_grpc.py file is generated for each proto file that declares a service. Message types come from protoc-gen-py, which also manages __init__.py files.

Feature highlights

Well-typed clients you can read

For each service, the plugin emits a client whose methods are fully typed, so editors and type checkers understand every RPC method, its request and response types, and its streaming shape:

async with grpc.aio.insecure_channel("localhost:50051") as channel:
    client = ElizaServiceClient(channel)
    response = await client.say(SayRequest(sentence="Hello!"))
    print(response.sentence)

Servicers that register themselves

Each service also gets a servicer base class with typed method signatures and an add_to_server method:

class ElizaService(ElizaServiceServicer):
    async def say(
        self, request: SayRequest, context: grpc.aio.ServicerContext
    ) -> SayResponse:
        return SayResponse(sentence=f"You said: {request.sentence}")


async def serve() -> None:
    server = grpc.aio.server()
    ElizaService().add_to_server(server)
    server.add_insecure_port("[::]:50051")
    await server.start()
    await server.wait_for_termination()

asyncio and sync, side by side

Every client and servicer is generated in both asyncio (grpc.aio) and synchronous flavors:

with grpc.insecure_channel("localhost:50051") as channel:
    client = ElizaServiceClientSync(channel)  # synchronous servicer
    response = client.say(SayRequest(sentence="Hello!"))

protobuf-py messages end to end

Requests and responses are protobuf-py messages. They have readable generated code, typed oneofs with pattern matching, real IntEnum enums, and a high-performance Rust encoder/decoder, with zero dependency on the legacy google-protobuf runtime.

Generating with protoc

The plugin also works with protoc as a standard protoc plugin:

$ uv run protoc --proto_path proto \
    --py_out src/gen \
    --grpc-py_out src/gen \
    proto/a.proto proto/b.proto proto/c.proto

Example

See the example for a complete client and server using the generated stubs, including server, client, and bidirectional streaming.

Metadata

Release files for protoc-gen-grpc-py 0.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 protoc-gen-grpc-py 0.4.0
File Size Uploaded Provenance
protoc_gen_grpc_py-0.4.0.tar.gz 11.9 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for protoc-gen-grpc-py 0.4.0
File Interpreter ABI Platform
protoc_gen_grpc_py-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.9 kB

Release files / protoc_gen_grpc_py-0.4.0.tar.gz

Download URL protoc_gen_grpc_py-0.4.0.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a76daf81b795c70b82f74d4be43ea03febbf3f4007e184a64add086ba34518e5
BLAKE2b-256 checksum
How to use checksums
c1e14daaaa7e47b6b40439dbd46a329e7339201fbd69dacb516e190d1bc21935
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / protoc_gen_grpc_py-0.4.0-py3-none-any.whl

Download URL protoc_gen_grpc_py-0.4.0-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ddb8afc7cbf9fa87dfd8ba6de8d3936d6eeff50d01cdb4920c221b04e1052088
BLAKE2b-256 checksum
How to use checksums
c63a721c446a30469f3c336cc608c6d7a024bb700c2e3a1466f5cc855619f8fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Security for protoc-gen-grpc-py 0.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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for protoc_gen_grpc_py-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

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.

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