# Repository Briefing: smg-project/smg
> Source: https://repoforai.com/repo/smg-project/smg (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/smg-project/smg
- **Official Docs / Website**: https://lightseek.org/smg
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Rust
- **License**: Apache-2.0
- **Engineering Health**: A+ (95/100 · Maintenance 35/35 · Adoption 20/25 · Releases 20/20 · License 20/20)
- **Latest Release**: v1.15.0 (2026-11-10) — https://github.com/smg-project/smg/releases
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: Docker, Self-Hosted, API, CLI, GPU
- **Momentum**: 764 ★ total (+2 24h / +14 7d) · 237 forks
- **Topics**: `anthropic`, `claude`, `gemini`, `inference-gateway`, `llm`, `openai`, `routing`, `sglang`, `vllm`, `tensorrtllm`, `anthropic-api`, `chat`
- **When to Use**: Best for: Platform teams unifying several GPU workers or cloud providers behind one endpoint, with shared routing, tenant admission controls, and observability. Skip if: You need a runtime that loads model weights, or you have one stable upstream and no operational reason to add a gateway.

## Overview
```text
### Architecture & Core Mechanics
Shepherd Model Gateway (SMG) is a Rust serving gateway, not a model runtime. A client sends requests to a unified endpoint; SMG chooses an upstream and routes to self-hosted workers over HTTP or streaming gRPC, or to a cloud API. On supported gRPC paths, the gateway can route around data-parallel replicas and coordinate separate prefill and decode roles, with an additional encode stage for vision workloads.

The Cargo workspace separates `model_gateway` from crates such as `crates/protocols`, `crates/service_discovery`, `crates/grpc_client`, `crates/engine_servicer`, `crates/kv_index`, and `crates/tokenizer`. Tokenization caching supports zero-copy hits. WASM plugins extend request and response handling; MCP integration handles tool discovery and execution over stdio, SSE, or streamable HTTP, with approvals and audit logging.

### Key Capabilities & Differentiators
SMG routes to vLLM, SGLang, TokenSpeed, TensorRT-LLM, MLX on Apple Silicon, and OpenAI-compatible servers, as well as providers including OpenAI, Anthropic, Gemini, xAI, AWS Bedrock, and Azure OpenAI. Its client-facing surface includes Chat Completions, Embeddings, Responses and Conversations, Anthropic Messages, Gemini Interactions, and Realtime over WebSocket or WebRTC. Validate the specific endpoint, model, and upstream combination before migrating clients; gateway API coverage does not guarantee identical behavior across providers.

The ten routing policies include `cache_aware`, `least_load`, `prefix_hash`, and `round_robin`. Cache-aware routing tracks worker KV prefixes in radix trees, while load modeling accounts for queued token work and KV pressure. The parser catalog covers 21 tool-call and 16 reasoning parsers, with automatic model detection for families including DeepSeek, Qwen, and Kimi. Per-tenant admission controls and 90+ Prometheus metrics give operators tools to manage and observe a shared serving fleet.

### Trade-offs & Limitations
Compared with calling vLLM directly, SMG adds a hop and a service to operate. That cost is easier to justify when shared traffic rules, tenant admission, or KV-prefix reuse can improve fleet-wide operation. Benchmark cache-aware routing against a simpler policy with your own prompt mix and concurrency: prefix reuse depends on the workload, and gRPC load reporting and disaggregated serving should not be assumed available on every upstream path.

Compared with calling the OpenAI API directly, SMG gives operators control over routing and storage and lets clients reach both local and cloud backends through one gateway. It does not eliminate provider charges or differences in streaming, tool calls, or error behavior. Multi-node deployments add peer discovery and SWIM/CRDT state replication; persistent chat history adds a storage service and schema migrations. Apache-2.0 covers the gateway, not model weights or provider terms.

### Hardware & Deployment Guide
Distribution options include `lightseekorg/smg:latest`, the Helm chart at `oci://ghcr.io/smg-project/charts/smg`, `pip install smg`, and `cargo install smg`, which requires `protoc`. Start with `smg launch --worker-urls http://localhost:8000`; the example client endpoint is `http://localhost:30000/v1/chat/completions`. Kubernetes can discover workers by pod label, including separate selectors for prefill, decode, and encode. Chat history can use PostgreSQL, Oracle, Redis, or in-memory storage; an external database is not required just to route requests.

Size the gateway and model workers separately: profile gateway CPU and memory under realistic streaming concurrency, and size worker VRAM for the chosen models, context lengths, concurrent sequences, and KV-cache demand. An on-premises-only inference path requires local backends and review of any enabled external integrations. v1.14.0 made Symphony the default parser and added a direct ZMQ path for TokenSpeed. v1.15.0 made the Rust engine servicer the default for vLLM, TokenSpeed, and SGLang, added streaming worker-load updates for gRPC, and made cache-aware routing track hybrid-model KV-cache groups.
```

## Key Capabilities
```text
- Routing: Ten policies, including radix-tree KV-prefix routing and load modeling based on queued token work and KV pressure.
- Engine transport: Streaming gRPC with data-parallel-aware routing; supports separate prefill, decode, and vision encode stages.
- Kubernetes and HA: Pod discovery with per-role selectors; gateway peers replicate state using SWIM gossip and CRDTs.
- Admission and identity: Priority scheduling with preemption, per-tenant controls, API keys, and control-plane OIDC.
- Extensibility and storage: WASM request/response middleware, MCP tool approvals and audit logging, and PostgreSQL, Oracle, Redis, or in-memory chat history.
- Observability: 90+ Prometheus metrics, correlated JSON logs, and W3C trace-context propagation over HTTP and gRPC.
```

## Quick Start / Clone
```bash
# Docker
docker pull lightseekorg/smg:latest

# Kubernetes (Helm)
helm install smg oci://ghcr.io/smg-project/charts/smg

# Python
pip install smg

# Rust (needs protoc)
cargo install smg
```
