smg-project/smg
Rust LLM gateway for cache-aware routing across local engines and cloud APIs
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & 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.
Platform teams unifying several GPU workers or cloud providers behind one endpoint, with shared routing, tenant admission controls, and observability.
You need a runtime that loads model weights, or you have one stable upstream and no operational reason to add a gateway.
Quick Start & Installation
# 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
Comparison vs. Top LLMs & Inference Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| smg ★ | 764 | +14 | Rust | Apache-2.0 | Rust LLM gateway for cache-aware routing across local engines and cloud APIs |
| OmniRoute | 92.1k | +1.5k | TypeScript | MIT | Self-hosted OpenAI-compatible gateway for multi-provider routing and fallback |
| gpt-load | 7.2k | +6 | Go | MIT | Self-hosted Go gateway for routing LLM traffic across providers and credentials |
| freellmapi | 62k | +2.6k | TypeScript | MIT | Self-hosted LLM gateway for routing across free tiers and custom endpoints |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/smg-project/smg.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about smg
How do I put SMG in front of an existing inference worker?
smg launch --worker-urls http://localhost:8000. Send a request to the gateway at /v1/chat/completions on port 30000. To add another worker, extend the URL list. Use --policy cache_aware only after confirming that the chosen engine and transport expose the cache information the policy needs.Does the gateway need a GPU, and how should I size the fleet?
Can we use it commercially and keep inference data on premises?
When is SMG worth adding instead of calling vLLM or OpenAI directly?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy