Skip to content

notfixingit3/openwebui-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openwebui-go logo

openwebui-go

A complete Go client SDK for the Open WebUI REST API.
Covers all 462 endpoints across 29 domain tags — streaming, auth, Ollama & OpenAI proxies, RAG, and more.

CI Status Go Reference MIT License Buy Me a Coffee

InstallQuickstartConfigurationAPI CoverageError HandlingStreamingSupport


Install

go get github.com/notfixingit3/openwebui-go

Requires Go 1.24 or later.

Quickstart

package main

import (
    "context"
    "fmt"
    "log"
    "os"

    "github.com/notfixingit3/openwebui-go/client"
)

func main() {
    apiKey := os.Getenv("OPENWEBUI_API_KEY")
    if apiKey == "" {
        log.Fatal("OPENWEBUI_API_KEY not set")
    }

    c, err := client.New(client.Config{APIKey: apiKey})
    if err != nil {
        log.Fatal(err)
    }

    // Check service health (public endpoint, no auth required)
    version, err := c.GetAppVersion(context.Background())
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Open WebUI version: %s\n", version["version"])
}

Configuration

client.Config accepts three fields:

Field Default Description
APIKey OPENWEBUI_API_KEY env var Bearer token for authenticated endpoints
BaseURL http://localhost:8080 Root URL of the Open WebUI server
HTTPClient &http.Client{Timeout: 30s} Custom HTTP client (timeouts, TLS, proxies)
// Custom timeout and TLS config
c, err := client.New(client.Config{
    APIKey:  "sk-...",
    BaseURL: "https://openwebui.example.com",
    HTTPClient: &http.Client{
        Timeout: 60 * time.Second,
        Transport: &http.Transport{TLSClientConfig: &tls.Config{...}},
    },
})

API Coverage

The SDK covers all 462 endpoints across 29 domain tags.

Domain Endpoints Key Operations
analytics 8 Daily stats, messages, models, tokens, users
audio 6 TTS, STT, voices, config
auths 21 Signin, signup, OAuth, LDAP, API keys
automations 8 CRUD, toggle, runs
calendars 13 CRUD, events, RSVP
channels 28 Messaging, threads, reactions, webhooks, members
chats 42 CRUD, archive, share, clone, tag, search, stats
configs 20 Server config, banners, connections, code execution
evaluations 16 Feedback, leaderboard, config
files 12 Upload, content retrieval, processing, search
folders 7 CRUD, parent, expanded state
functions 17 Plugin functions, valves, toggle, sync
groups 10 CRUD, user membership, export
images 6 Generation, edit, config
knowledge 17 Knowledge bases, files, search, reindex, access
memories 7 CRUD, query, reset
models 14 CRUD, tags, profile images, base models, import/export
notes 9 CRUD, pin, search, access
ollama 43 Proxy: chat, generate, embeddings, model management
openai 12 OpenAI-compatible proxy, chat completions, audio
pipelines 8 Add, upload, valves
prompts 17 Prompt templates, history, versioning, tags
retrieval 16 RAG: embeddings, process file/text/web/youtube
skills 9 CRUD, access, toggle, export
tasks 11 Auto-title, emoji, tags, follow-up, MOA completions
terminals 8 Terminal server proxy
tools 15 Tool plugins, valves, access, load from URL
users 21 CRUD, groups, permissions, settings, profile images
utils 6 DB download, code execute/format, markdown, PDF

All generated request and response types live in internal/gen and are re-exported through the client package where appropriate.

Error Handling

Non-2xx responses are returned as *client.HTTPError, which exposes the status code and raw response body.

var httpErr *client.HTTPError
if errors.As(err, &httpErr) {
    fmt.Printf("HTTP %d: %s\n", httpErr.StatusCode, string(httpErr.Body))
}

Validation errors (422) include structured detail:

var valErr *client.HTTPValidationError
if errors.As(err, &valErr) {
    for _, d := range valErr.Detail {
        fmt.Printf("Field %v: %s\n", d.Loc, d.Msg)
    }
}

Streaming

Chat completions and Ollama generate/chat endpoints support NDJSON streaming. The SDK returns two channels: one for events and one for errors.

events, errs := c.StreamChatCompletion(ctx, body)
for {
    select {
    case event, ok := <-events:
        if !ok { return }
        fmt.Printf("Type: %s, Data: %s\n", event.Type, string(event.Data))
    case err, ok := <-errs:
        if !ok { return }
        log.Fatal(err)
    }
}

See examples/streaming/main.go for a complete runnable example with graceful shutdown on SIGINT.

Examples

  • examples/basic/main.go — Create a client, call a public endpoint, and handle errors.
  • examples/streaming/main.go — Stream chat completions with graceful shutdown.

Buy Me a Coffee

If you find this SDK useful, consider buying me a coffee to support ongoing development.

Buy Me a Coffee

Thank you!

License

MIT © 2026 notfixingit3

About

Go Module for open-webui API

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages