Golang SDK for using Ollama.
- Go 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| .gitignore | ||
| chat.go | ||
| client.go | ||
| errors.go | ||
| generate.go | ||
| go.mod | ||
| LICENSE | ||
| models.go | ||
| pull.go | ||
| README.md | ||
Ollama Go SDK
Lightweight GoLang SDK for working with Ollama.
Supports:
- Bearer Authentication
- Generate
- Generate stream
- Chat
- Streaming Chat
- Pulling models
Installation
go get vc.maxkaya.com/sdk/ollama
Quick Start
package main
import (
"fmt"
"vc.maxkaya.com/sdk/ollama"
)
func main() {
client := ollama.NewClient("http://localhost:11434")
// Or if you have an authentication bearer key
client := ollama.NewClientWithAuth("http://localhost:11434", "API_KEY")
res, err := client.Generate("qwen3:8b", "What is the answer to life?")
if err != nil {
panic(err)
}
fmt.Println("Response: ", res)
}
Pull a model programmatically
package main
import (
"fmt"
"vc.maxkaya.com/sdk/ollama"
)
func main() {
client := ollama.NewClient("http://localhost:11434")
err := client.PullModel("qwen3:8b", func(status string) {
fmt.Println("Pull Status: ", status)
})
if err != nil {
panic(err)
}
}