v0.10.5

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


Go ReferenceReleaseLicense




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 from Agenvoy 2741d4a
Since v0.28.17, Agenvoy's LLM providers are unified and replaced by this package go-llm-router.

Table of Contents



Features


go get github.com/pardnchiu/go-llm-router · Documentation

  • Unified Agent Interface — Fifteen providers share one Send / SendStream contract, so callers never write per-vendor adapters.
  • String Routing Factory — Resolve an Agent from a provider@model name; an unknown prefix falls through to an OpenAI-compatible endpoint as a named instance.
  • Reasoning Level Normalization — Six levels from none to max map onto Claude thinking, Gemini budgets, and OpenAI effort, clamped to each model's range.
  • Usage Field Absorption — prompt_tokens / input_tokens and 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]
  1. graph TB
  2. App[Caller] --> Router[router.New]
  3. Router --> Agent[llmrouter.Agent]
  4. Agent --> KeyBased[Key-based providers]
  5. Agent --> OAuthBased[OAuth providers]
  6. Agent --> Compat[OpenAI-compatible endpoints]
  7. OAuthBased --> OAuth[core/oauth token store]
  8. Agent --> Stream[Stream event normalization]
  9. Agent --> Usage[Usage normalization]
  10. Agent --> Media[Image / audio agents]
  11. App --> DecisionRouter[router.NewDecision]
  12. DecisionRouter --> Decision[llmrouter.DecisionAgent]
  13. Decision --> DecisionProviders[TypeSafe / OpenRouter]

License


This project is licensed under the MIT LICENSE.

Author


Just open an issue to share an idea.
go-llm-router contributors


©️ 2026 邱敬幃 Pardn Chiu
中文