Model or dataset
teilomillet/gollm avatar
teilomillet/gollm

gollm: one Go constructor for many LLM providers, plus a prompt optimizer and no tagged releases

Unified Go interface for Language Model (LLM) providers. Simplifies LLM integration with flexible prompt management and common task functions.

674 stars66 forksGoApache-2.0

At a glance

What is it?
gollm is a Go package that puts OpenAI, Anthropic, Groq, Ollama, Mistral and OpenRouter behind a single NewLLM call, then layers prompts, chain of thought, an optimizer and model comparison on top. Its last push was in March 2026 and the repository has no GitHub releases.
Who is it for?
Choose gollm if you write Go, want one NewLLM call across several providers, and are happy to pin a commit yourself. Avoid it if you need tagged releases or evidence of recent maintenance, because the last push was on 2026-03-21 and no release exists.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Activity is slowing. The repository last received commits 8 months ago.
What is it written in?
Mainly Go, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • teilomillet/gollm674 ★ · +1
Star history
Repository2026-09-112026-11-25
teilomillet/gollm673674

1 Stars in the last 75 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

gollm.NewLLM builds every client from functional options

The entry point is a single constructor. You pass it options such as SetProvider, SetModel, SetAPIKey, SetMaxTokens, SetTemperature and SetMemory, and it returns an LLM value plus an error. The configuration example in the quick reference looks like this:

go
// Using OpenAI
llm, err := gollm.NewLLM(
    gollm.SetProvider("openai"),
    gollm.SetModel("gpt-4"),
    gollm.SetAPIKey("your-api-key"),
    gollm.SetMaxTokens(100),
    gollm.SetTemperature(0.7),
    gollm.SetMemory(4096),
)

The provider is a plain string, so switching from OpenAI to another backend is an edit to two option values rather than a different import. The longer basic-usage program reads OPENAI_API_KEY from the environment with os.Getenv and calls log.Fatalf when it is empty, and it also passes SetMaxRetries(3). That is the pattern to copy. The quick-reference snippet hard-codes the key as a string literal, which is fine for a reference line and wrong for anything you commit. Because the constructor returns an error, a misspelled provider name or a missing key surfaces at construction time and not on the first request, provided you check err.

The environment file lists more providers than the README table does

The README's Supported Providers section names OpenAI with GPT-4o, GPT-4 and GPT-3.5 Turbo, Anthropic with Claude 3 and Claude 2.1, Groq, Ollama, Mistral and OpenRouter. The .env.example file in the repository root goes further. It has key variables for OPENAI_API_KEY, ANTHROPIC_API_KEY, GROQ_API_KEY, MISTRAL_API_KEY, COHERE_API_KEY, DEEPSEEK_API_KEY, GEMINI_API_KEY, DASHSCOPE_API_KEY (marked Aliyun/Alibaba Cloud), OPENROUTER_API_KEY, AZURE_OPENAI_API_KEY and LAMBDA_API_KEY. Local servers get OLLAMA_ENDPOINT=http://localhost:11434 and LMSTUDIO_ENDPOINT=http://localhost:1234/v1, the latter marked OpenAI-compatible.

Defaults can come from the environment too: LLM_PROVIDER=openai, LLM_MODEL=gpt-4o-mini, LLM_TEMPERATURE=0.7, LLM_MAX_TOKENS=1000 and LLM_LOG_LEVEL=WARN. Azure OpenAI needs three more values together, AZURE_OPENAI_RESOURCE_NAME, AZURE_OPENAI_DEPLOYMENT_NAME and AZURE_OPENAI_API_VERSION, and the file says all three are required. AWS Bedrock reads the standard AWS variables. The examples directory has folders for azure_openai, bedrock, lmstudio, lambda and google_openai, which is where to see those backends wired up. The model names in the README table are the ones the author wrote down, so confirm current model identifiers with each provider before relying on them.

Fallback models belong to the OpenRouter example, not to every provider

Reliability features are not spread evenly. The README lists OpenRouter as the backend that offers model fallback, auto-routing between models, prompt caching, reasoning tokens and provider routing preferences. The quick reference shows the pattern: create the client with SetProvider("openrouter"), a model such as anthropic/claude-3-5-sonnet and an OpenRouter key, then call llm.SetOption with the key fallback_models and a list of alternative model strings.

The consequence is narrow but real. If you configure the OpenAI provider directly, that fallback example does not apply to you, and an outage or a retired model is something your own code has to handle. Do not read the one-line promise of a unified interface as meaning that every option works on every backend. The retry count set with SetMaxRetries is a separate mechanism, described as a way to cope with API rate limits and transient errors. A retry repeats the same request. It does not move the request to another model. The examples folder has an openrouter directory and a providers directory, and reading them is the cheapest way to see which options a given backend accepts.

Prompts are structs with context, directives and an expected output

A prompt is not just a string. NewPrompt takes the main text and then options that add structure:

go
prompt := gollm.NewPrompt("Your prompt text here",
    gollm.WithContext("Additional context"),
    gollm.WithDirectives("Be concise", "Use examples"),
    gollm.WithOutput("Expected output format"),
    gollm.WithMaxLength(300),
)

Generation is then one call that takes a context and the prompt:

go
response, err := llm.Generate(ctx, prompt)

The split matters because context, directives and output format are separate fields, so you can reuse a directive set across prompts without string concatenation. The README's table of contents also names prompt templates, working with examples, and structured output with JSON validation, backed by the invopop/jsonschema and go-playground/validator packages in go.mod. Those packages hint at how schema generation and validation are done, though the exact flow sits in the full documentation at docs.gollm.co, so read it before building on it. Because Generate returns an error alongside the response, a validation failure or a provider error reaches your code the same way, and you decide whether to retry, log or abort.

ChainOfThought is a function in the tools package, not a client setting

Step-by-step reasoning is exposed as a helper that wraps an existing client:

go
response, err := tools.ChainOfThought(ctx, llm, "Your question here")

It lives in a tools package, separate from the root gollm package, and it takes the context, the LLM and a question string. You do not construct a prompt with NewPrompt for this call, and you do not turn anything on in NewLLM. That means chain of thought is opt-in per call: the same client can answer one question through Generate and another through ChainOfThought.

The README presents it under the heading of complex reasoning tasks, and the examples directory has a chain_of_thought folder. The quick reference does not show how the function phrases its instructions to the model or how many requests it makes, so treat cost and latency as unknown until you read the source or measure a run with your own provider. The same tools package supplies CompareModels, covered below, so an import of the tools path is something you will need for more than one feature. The repository root also holds moa.go, which backs the mixture of agents example, one of the listed applications that combines responses from several providers.

Model comparison follows the same shape as the other helpers. The call is results, err := tools.CompareModels(ctx, promptText, validateFunc, configs...), where promptText is the task, validateFunc checks each answer and configs are the provider setups to run it against. The README describes this as a way to test performance across providers and models on the same task. Because you supply the validation function, what counts as a pass is your decision, and a loose validator will make every model look equally good. The examples folder has compare_providers and compare_structured_output for runnable versions.

The prompt optimizer takes your client as its first argument

Prompt optimization is its own package. The constructor receives the LLM, an initial prompt and a task description, followed by options:

go
optimizer := optimizer.NewPromptOptimizer(llm, initialPrompt, taskDescription,
    optimizer.WithCustomMetrics(/* custom metrics */),
    optimizer.WithRatingSystem("numerical"),
    optimizer.WithThreshold(0.8),
)
optimizedPrompt, err := optimizer.OptimizePrompt(ctx)

Because the client is passed in, the refinement work goes through whichever provider and model you already configured. WithRatingSystem("numerical") picks how candidates are scored, WithThreshold(0.8) sets a score at which the process can stop, and WithCustomMetrics lets you supply your own criteria in place of the defaults. The README advertises support for custom metrics and different rating systems.

Two cautions follow. First, the quick reference leaves the metrics argument as a comment, so the type of a custom metric has to be found in the optimizer package or in docs.gollm.co. Second, an optimizer that improves a prompt according to a score is only as good as that score; a threshold of 0.8 on a poorly chosen metric just stops early on the wrong thing. There are two example folders, prompt_optimizer and batch_prompt_optimizer, and the batch one is the place to look if you have many prompts to process.

No GitHub releases and a last push on 2026-03-21 leave you pinning commits

The repository is not archived, but the maintenance picture is thin. The last push was on 2026-03-21 and the project has no GitHub releases, so there is no tagged version to read release notes for. The repository shows no recent commits, and a gap of several months since the last push is reason to look at the commit history and open issues before adopting it. With no release tags, a Go module consumer who runs go get github.com/teilomillet/gollm ends up referencing a commit, so record the exact version your build resolves and keep it in go.sum.

On the build side, go.mod declares go 1.25, which sets a floor for your toolchain. Direct dependencies are caarlos0/env v11.3.1, go-playground/validator v10.30.1, invopop/jsonschema v0.13.0, pkoukk/tiktoken-go v0.1.8, stretchr/testify v1.11.1 and golang.org/x/time v0.14.0. The tiktoken-go entry points to token counting, and x/time to rate limiting. The license is Apache-2.0. The source layout is flat: gollm.go, config.go, prompt.go, stream.go, validation.go and moa.go at the root, with llm, providers, optimizer, presets, assess, config, types and utils as directories. The install is a single command:

bash
go get github.com/teilomillet/gollm

If you depend on it in production, vendor it or fork it so a change you did not review cannot reach your build.

Editorial conclusion

Choose gollm if you write Go, want one NewLLM call across several providers, and are happy to pin a commit yourself. Avoid it if you need tagged releases or evidence of recent maintenance, because the last push was on 2026-03-21 and no release exists.

Frequently asked questions

How do I install gollm?

Run go get github.com/teilomillet/gollm. The module declares go 1.25 in its go.mod and is licensed Apache-2.0.

Which LLM providers does gollm work with?

The README lists OpenAI, Anthropic, Groq, Ollama, Mistral and OpenRouter. The .env.example file also has keys for Cohere, DeepSeek, Gemini, DashScope, Azure OpenAI and Lambda, plus an LM Studio endpoint.

Does gollm have tagged releases?

No. The repository has no GitHub releases, and its last push was on 2026-03-21, so pin a commit rather than a version.

Does gollm support model fallback?

The README lists model fallback under OpenRouter, and the quick reference sets fallback_models with llm.SetOption on an OpenRouter client. It does not show the same option for other providers.

Official sources

  1. Issues
  2. License: Apache-2.0
  3. Project website
  4. README
  5. teilomillet/gollm on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/teilomillet-gollm.svg)](https://hysenlabs.com/projects/teilomillet-gollm)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/teilomillet-gollm.svg)](https://hysenlabs.com/projects/teilomillet-gollm)

Was this useful?