pardnchiu/go-llm-router
Last updated
NoteThis README was generated by SKILL, get the ZH version from here.
ONE AGENT INTERFACE FOR EVERY LLM PROVIDER
A Go LLM library with a unified LLM API for 15 providers, provider@model routing, and normalized streaming and usage
Extracted as a standalone package fromAgenvoy2741d4a
Since v0.28.17, Agenvoy's LLM providers are unified and replaced by this packagego-llm-router.
Table of Contents
Features
go get github.com/pardnchiu/go-llm-router · Documentation- Unified Agent Interface — Fifteen providers share one
Send/SendStreamcontract, so callers never write per-vendor adapters. - String Routing Factory — Resolve an Agent from a
provider@modelname; an unknown prefix falls through to an OpenAI-compatible endpoint as a named instance. - Reasoning Level Normalization — Six levels from
nonetomaxmap onto Claude thinking, Gemini budgets, and OpenAI effort, clamped to each model's range. - Usage Field Absorption —
prompt_tokens/input_tokensand every cache variant fold into a single Input / Output / Cache shape. - Multimodal and OAuth Extensions — Built-in Copilot / Codex / Grok OAuth flows, plus image generation, speech-to-text, and text-to-speech agents.
- Live X Search for Grok — Grok requests that carry function tools also get xAI's server-side
x_search, so the model can read current X posts, users, and threads before it answers. - Typed Decisions — Ask yes/no, choice, and score questions about a piece of text and get probability-weighted answers from TypeSafe or OpenRouter through one
DecisionAgent.
Architecture
Full Architecture
graph TB
App[Caller] --> Router[router.New]
Router --> Agent[llmrouter.Agent]
Agent --> KeyBased[Key-based providers]
Agent --> OAuthBased[OAuth providers]
Agent --> Compat[OpenAI-compatible endpoints]
OAuthBased --> OAuth[core/oauth token store]
Agent --> Stream[Stream event normalization]
Agent --> Usage[Usage normalization]
Agent --> Media[Image / audio agents]
App --> DecisionRouter[router.NewDecision]
DecisionRouter --> Decision[llmrouter.DecisionAgent]
Decision --> DecisionProviders[TypeSafe / OpenRouter]- graph TB
- App[Caller] --> Router[router.New]
- Router --> Agent[llmrouter.Agent]
- Agent --> KeyBased[Key-based providers]
- Agent --> OAuthBased[OAuth providers]
- Agent --> Compat[OpenAI-compatible endpoints]
- OAuthBased --> OAuth[core/oauth token store]
- Agent --> Stream[Stream event normalization]
- Agent --> Usage[Usage normalization]
- Agent --> Media[Image / audio agents]
- App --> DecisionRouter[router.NewDecision]
- DecisionRouter --> Decision[llmrouter.DecisionAgent]
- Decision --> DecisionProviders[TypeSafe / OpenRouter]
License
This project is licensed under the MIT LICENSE.
Author
Just open an issue to share an idea.
©️ 2026 邱敬幃 Pardn Chiu