Last updated 2026-05-17

Installation

llmrouter is a regular Go module. There is no binary to download, no daemon to run, and no toolchain beyond the Go SDK itself. Add the module to your go.mod, import the root package plus at least one provider subpackage, and you have a working LLM client.

Prerequisites

  • Go 1.23 or newer. The module declares go 1.23 in go.mod. Older Go versions will refuse the dependency. Check with go version.
  • An API key from at least one supported provider. For the OpenAI provider that is an sk-... key from platform.openai.com. For the Anthropic provider that is a key from console.anthropic.com. For any OpenAI-compatible endpoint (OpenRouter, Together, Groq, self-hosted vLLM, Ollama) use whatever credential that endpoint issues — llmrouter only forwards it as a bearer token.
  • Internet egress to the upstream's API host from whatever environment runs your code. The library does not proxy, cache, or batch — every CompletionStream call opens a fresh HTTPS connection.

Install

Add the module to your project:

go get github.com/elloloop/llmrouter@v0.1.1

That pulls in the root package and makes the provider subpackages importable. If you prefer to track the latest tag instead of pinning, use @latest; if you want to live on the main branch, use a pseudo-version (go get github.com/elloloop/llmrouter@main).

To see the resulting go.mod entry:

go list -m github.com/elloloop/llmrouter

You should see something like:

github.com/elloloop/llmrouter v0.1.1

Imports

Every program imports two things: the root package (github.com/elloloop/llmrouter, which carries the shared types and options) and at least one provider subpackage. The provider subpackage owns the New(opts ...llmrouter.Option) constructor for that backend.

Root package — types, options, errors:

import "github.com/elloloop/llmrouter"

OpenAI provider (and any OpenAI-compatible endpoint via base URL):

import "github.com/elloloop/llmrouter/providers/openai"

Anthropic provider:

import "github.com/elloloop/llmrouter/providers/anthropic"

Import only the providers you actually use. Each provider subpackage is independent — importing one does not pull in the other, so binaries stay small.

Verify your install

To confirm the module resolves and the provider subpackages compile, drop the following into a fresh directory and run it. It does not issue any HTTP calls — it just constructs both providers and prints their Name().

mkdir llmrouter-verify && cd llmrouter-verify
go mod init example.com/llmrouter-verify
go get github.com/elloloop/llmrouter@v0.1.1

Save this as main.go:

package main
import (
"fmt"
"log"
"github.com/elloloop/llmrouter"
"github.com/elloloop/llmrouter/providers/anthropic"
"github.com/elloloop/llmrouter/providers/openai"
)
func main() {
oai, err := openai.New(llmrouter.WithAPIKey("sk-test"))
if err != nil {
log.Fatalf("openai constructor failed: %v", err)
}
fmt.Printf("provider 1: %s\n", oai.Name())
ant, err := anthropic.New(llmrouter.WithAPIKey("sk-ant-test"))
if err != nil {
log.Fatalf("anthropic constructor failed: %v", err)
}
fmt.Printf("provider 2: %s\n", ant.Name())
}

Run it:

go run .

Expected output:

provider 1: openai
provider 2: anthropic

If you see both lines, your install is healthy. The API keys in this snippet are placeholders — the constructors only validate that the key is non-empty; they don't talk to the upstream until you call CompletionStream.

Module path

The module path is github.com/elloloop/llmrouter. The package layout looks like this:

github.com/elloloop/llmrouter // root package: types, options, errors
github.com/elloloop/llmrouter/providers/openai // OpenAI + OpenAI-compatible
github.com/elloloop/llmrouter/providers/anthropic // Anthropic full translator
// v0.2:
github.com/elloloop/llmrouter/providers/azure // Azure OpenAI Service
github.com/elloloop/llmrouter/providers/bedrock // AWS Bedrock (SigV4)
github.com/elloloop/llmrouter/providers/vertex // Google Vertex AI (ADC)

The split between the root package and the provider subpackages is deliberate. The root package carries everything that is provider-agnostic — Provider, ChatRequest, Message, Stream, Chunk, the With* options, and the ErrUpstream type. Each provider subpackage carries exactly one New(opts ...llmrouter.Option) (llmrouter.Provider, error) constructor and the private translation logic.

This means you can write helper code that takes llmrouter.Provider without importing any provider subpackage, and the only place provider names appear is the construction site.

Versioning

llmrouter follows semantic versioning, but the library is pre-1.0. Until v1.0 is tagged, minor releases (v0.1 → v0.2) may include breaking changes; patch releases (v0.1.0 → v0.1.1) are bug fixes only. Pin a minor version in your go.mod and read the release notes before bumping minors.

Recommended pin style:

require github.com/elloloop/llmrouter v0.1.1

License

llmrouter is released under the Apache License, Version 2.0. Apache-2.0 grants the right to use, modify, and redistribute, including in commercial and closed-source products, provided you preserve the copyright + license notice and disclose modifications in the NOTICE file when one is shipped alongside.

Next steps