{"id":6458,"library":"smg-grpc-proto","title":"SMG gRPC Proto Definitions","description":"smg-grpc-proto provides the Protocol Buffer definitions and generated Python gRPC stubs for the Shepherd Model Gateway (SMG). These definitions enable communication with SMG, a universal gateway supporting various LLM inference engines like SGLang, vLLM, and TRT-LLM. While the main SMG project undergoes rapid development (currently v1.4.x), this library provides the stable API surface for gRPC interaction. The current version is 0.4.6, with updates typically tied to major SMG feature releases.","status":"active","version":"0.4.6","language":"en","source_language":"en","source_url":"https://github.com/lightseekorg/smg","tags":["grpc","protobuf","llm","ai","model-gateway","smg"],"install":[{"cmd":"pip install smg-grpc-proto","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"Generated protobuf messages are typically under the 'smg_proto' package, not the 'smg_grpc_proto' top-level package name.","wrong":"from smg_grpc_proto import smg_pb2","symbol":"smg_pb2","correct":"from smg_proto import smg_pb2"},{"note":"Generated gRPC service stubs are typically under the 'smg_proto' package, matching the message definitions.","wrong":"from smg_grpc_proto import smg_pb2_grpc","symbol":"smg_pb2_grpc","correct":"from smg_proto import smg_pb2_grpc"},{"note":"Specific message types are imported directly from the smg_pb2 module.","symbol":"CompletionRequest","correct":"from smg_proto.smg_pb2 import CompletionRequest"},{"note":"Specific service stubs are imported directly from the smg_pb2_grpc module.","symbol":"CompletionServiceStub","correct":"from smg_proto.smg_pb2_grpc import CompletionServiceStub"}],"quickstart":{"code":"import grpc\nfrom smg_proto import smg_pb2, smg_pb2_grpc\nimport os\n\n# NOTE: This example requires a running SMG gateway to connect to.\n# For a local gateway, use 'localhost:8000' (default).\nSMG_GRPC_TARGET = os.environ.get('SMG_GRPC_TARGET', 'localhost:8000')\n\ndef run_completion_client():\n    try:\n        with grpc.insecure_channel(SMG_GRPC_TARGET) as channel:\n            stub = smg_pb2_grpc.CompletionServiceStub(channel)\n            request = smg_pb2.CompletionRequest(\n                model='<your_model_name>',  # e.g., 'mistral-7b-instruct-v0.2'\n                prompt='Hello, world! What is your name?',\n                max_tokens=50,\n                temperature=0.7\n            )\n            print(f\"Sending completion request to {SMG_GRPC_TARGET}...\")\n            response = stub.Complete(request)\n            print(\"Completion Response:\")\n            print(f\"Text: {response.text}\")\n            if response.finish_reason:\n                print(f\"Finish Reason: {response.finish_reason}\")\n            print(f\"Prompt Tokens: {response.prompt_tokens}\")\n            print(f\"Completion Tokens: {response.completion_tokens}\")\n    except grpc.RpcError as e:\n        print(f\"gRPC Error: {e.code()} - {e.details()}\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")\n\nif __name__ == '__main__':\n    run_completion_client()","lang":"python","description":"This quickstart demonstrates how to use the generated gRPC stubs from `smg-grpc-proto` to make a `CompletionRequest` to a running Shepherd Model Gateway. It establishes an insecure channel, creates a stub, and sends a request. Remember to replace '<your_model_name>' with a model available on your SMG instance. An SMG gateway must be running and accessible at `SMG_GRPC_TARGET` (defaults to `localhost:8000`) for this example to work."},"warnings":[{"fix":"If you need a full client library with convenience methods, use `pip install smg-client-sdk`. If you are building a custom gRPC client/server, this package is appropriate.","message":"This package (`smg-grpc-proto`) provides only the Protocol Buffer definitions and generated Python gRPC client/server stubs. It does not include the full Shepherd Model Gateway client SDK or the gateway server itself. For a higher-level client, consider `smg-client-sdk`.","severity":"gotcha","affected_versions":"All"},{"fix":"Always align the `smg-grpc-proto` version with the expected version of the SMG gateway you are interacting with. Consult the SMG gateway's release notes for compatible proto versions. Upgrade `smg-grpc-proto` to the latest version to ensure compatibility with the most recent SMG gateway features and fixes: `pip install --upgrade smg-grpc-proto`.","message":"Significant changes to the SMG gateway's API (e.g., new services, modified message structures for features like Multimodal or Messages API) often lead to updates in `smg-grpc-proto`. Using an older `smg-grpc-proto` version with a newer SMG gateway (or vice versa) can result in gRPC errors like `UNIMPLEMENTED`, `INVALID_ARGUMENT`, or malformed responses.","severity":"breaking","affected_versions":"0.1.x - 0.4.x (especially with SMG gateway versions 1.x.x)"},{"fix":"When importing, always refer to the `smg_proto` module, e.g., `from smg_proto import smg_pb2, smg_pb2_grpc`.","message":"The generated Python package for the proto definitions is `smg_proto`, not `smg_grpc_proto`. Direct imports should use `from smg_proto import ...`.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}