tmc /langchaingo

LangChain for Go, the easiest way to write LLM-based programs in Go

★ 9,779⑂ 1,166👁 77⑃ 1,067● 457▤ 22
GoMITCreated 2023-02-18tmc.github.io/langchaingo/
下载:v0.1.15v0.1.15 ↓0.1.152026-10-05
+0
日增长
9,779
stars
1,166
forks
77
watchers
1,067
prs
457
issues
22
releases

README

🎉 Join our new official Discord community! Connect with other LangChain Go developers, get help and contribute: Join Discord

 🦜️🔗 LangChain Go







⚡ Building applications with LLMs through composability, with Go! ⚡

 🤔 What is this?

This is the Go language implementation of LangChain.

 📖 Documentation

- Documentation Site
- API Reference


 🎉 Examples

See ./examples for example usage.

go
package main

import (
  "context"
  "fmt"
  "log"

  "github.com/tmc/langchaingo/llms"
  "github.com/tmc/langchaingo/llms/openai"
)

func main() {
  ctx := context.Background()
  llm, err := openai.New()
  if err != nil {
    log.Fatal(err)
  }
  prompt := "What would be a good company name for a company that makes colorful socks?"
  completion, err := llms.GenerateFromSinglePrompt(ctx, llm, prompt)
  if err != nil {
    log.Fatal(err)
  }
  fmt.Println(completion)
}


shell
$ go run .
Socktastic


 Resources

Join the Discord server for support and discussions: Join Discord

Here are some links to blog posts and articles on using Langchain Go:

- Using Gemini models in Go with LangChainGo - Jan 2024
- Using Ollama with LangChainGo - Nov 2023
- Creating a simple ChatGPT clone with Go - Aug 2023
- Creating a ChatGPT Clone that Runs on Your Laptop with Go - Aug 2023


 Contributors

There is a momentum for moving the development of langchaingo to a more community effort, if you are interested in being a maintainer or you are a contributor please join our Discord and let us know.

Top issues

Discussions

Latest release

v0.1.15 v0.1.15 2026-10-05
A patch release that replaces three retired default models, adds typed
reasoning content and OpenAI web search, and fixes a number of provider bugs.

 Action required

googleai, vertex: default embedding model is now gemini-embedding-001.
embedding-001 now returns 404. The new model produces 3072-dimension
vectors that are not comparable with the old ones, so indexes built with the
old default must be re-embedded (and fixed-size vector columns resized).

googleai, vertex: default chat model is now gemini-2.5-flash.
gemini-2.0-flash is retired. Gemini 2.5 thinks by default and thinking
counts t

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON