openwebui

package
v0.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
}

APIError represents an error from the Open WebUI API

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface for APIError

type AddFileRequest

type AddFileRequest struct {
	FileID string `json:"file_id"`
}

AddFileRequest represents the request to add a file to knowledge base

type BackupMetadata added in v0.3.0

type BackupMetadata struct {
	OpenWebUIURL      string   `json:"open_webui_url"`
	OpenWebUIVersion  string   `json:"open_webui_version,omitempty"`
	BackupToolVersion string   `json:"backup_tool_version"`
	BackupTimestamp   string   `json:"backup_timestamp"`
	BackupType        string   `json:"backup_type"` // "knowledge", "model", "tool", "prompt", "file", "chat", "all"
	ItemCount         int      `json:"item_count"`
	UnifiedBackup     bool     `json:"unified_backup"`            // true for backup-all
	ContainedTypes    []string `json:"contained_types,omitempty"` // ["knowledge", "model", "tool", "prompt", "file", "chat", "user"]
}

BackupMetadata contains information about the backup

type Chat added in v0.4.0

type Chat struct {
	ID        string                 `json:"id"`
	UserID    string                 `json:"user_id"`
	Title     string                 `json:"title"`
	Chat      ChatMessages           `json:"chat"` // Array of messages
	Meta      map[string]interface{} `json:"meta,omitempty"`
	CreatedAt int64                  `json:"created_at"`
	UpdatedAt int64                  `json:"updated_at"`
}

Chat represents a chat conversation from the Open WebUI API

type ChatMessages added in v0.4.0

type ChatMessages struct {
	Messages []Message `json:"messages"`
}

ChatMessages represents the messages array in a chat

type ChatTitleID added in v0.15.0

type ChatTitleID struct {
	ID        string `json:"id"`
	Title     string `json:"title"`
	UserID    string `json:"user_id"`
	CreatedAt int64  `json:"created_at"`
	UpdatedAt int64  `json:"updated_at"`
}

ChatTitleID represents a simplified chat response from list/search endpoints

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents an HTTP client for the Open WebUI API

func NewClient

func NewClient(baseURL, apiKey string) *Client

NewClient creates a new API client instance

func (*Client) AddFileToKnowledge

func (c *Client) AddFileToKnowledge(knowledgeID, fileID string) error

AddFileToKnowledge associates an uploaded file with a knowledge base

func (*Client) CreateFeedback added in v0.5.0

func (c *Client) CreateFeedback(feedbackForm *FeedbackForm) (*Feedback, error)

CreateFeedback creates a new feedback

func (*Client) CreateFileFromExport added in v0.3.0

func (c *Client) CreateFileFromExport(file *FileExport) error

CreateFileFromExport uploads a file from export data

func (*Client) CreateGroup added in v0.5.0

func (c *Client) CreateGroup(groupForm *GroupForm) (*Group, error)

CreateGroup creates a new group via /api/v1/groups/create

func (*Client) CreateKnowledge

func (c *Client) CreateKnowledge(form *KnowledgeForm) (*KnowledgeCreateResponse, error)

CreateKnowledge creates a new knowledge base

func (*Client) CreatePrompt added in v0.3.0

func (c *Client) CreatePrompt(prompt *PromptForm) error

CreatePrompt creates a new prompt

func (*Client) DeleteAllChats added in v0.4.0

func (c *Client) DeleteAllChats() error

DeleteAllChats deletes all user chats

func (*Client) DeleteAllFeedbacks added in v0.4.0

func (c *Client) DeleteAllFeedbacks() error

DeleteAllFeedbacks deletes all feedbacks

func (*Client) DeleteAllFiles added in v0.4.0

func (c *Client) DeleteAllFiles() error

DeleteAllFiles deletes all files

func (*Client) DeleteAllGroups added in v0.5.0

func (c *Client) DeleteAllGroups() error

DeleteAllGroups deletes all groups

func (*Client) DeleteAllMemories added in v0.4.0

func (c *Client) DeleteAllMemories() error

DeleteAllMemories deletes all user memories

func (*Client) DeleteAllModels added in v0.4.0

func (c *Client) DeleteAllModels() error

DeleteAllModels deletes all models

func (*Client) DeleteChatByID added in v0.4.0

func (c *Client) DeleteChatByID(id string) error

DeleteChatByID deletes a specific chat by ID

func (*Client) DeleteFeedbackByID added in v0.5.0

func (c *Client) DeleteFeedbackByID(id string) error

DeleteFeedbackByID deletes a specific feedback by ID

func (*Client) DeleteFunctionByID added in v0.4.0

func (c *Client) DeleteFunctionByID(id string) error

DeleteFunctionByID deletes a specific function by ID

func (*Client) DeleteGroupByID added in v0.5.0

func (c *Client) DeleteGroupByID(id string) error

DeleteGroupByID deletes a specific group by ID

func (*Client) DeleteKnowledgeByID added in v0.4.0

func (c *Client) DeleteKnowledgeByID(id string) error

DeleteKnowledgeByID deletes a specific knowledge base by ID

func (*Client) DeleteMemoryByID added in v0.4.0

func (c *Client) DeleteMemoryByID(id string) error

DeleteMemoryByID deletes a specific memory by ID

func (*Client) DeletePromptByCommand added in v0.4.0

func (c *Client) DeletePromptByCommand(command string) error

DeletePromptByCommand deletes a specific prompt by command

func (*Client) DeleteToolByID added in v0.4.0

func (c *Client) DeleteToolByID(id string) error

DeleteToolByID deletes a specific tool by ID

func (*Client) DeleteUserByID added in v0.5.0

func (c *Client) DeleteUserByID(userID string) error

DeleteUserByID deletes a specific user by ID

func (*Client) ExportModels added in v0.2.0

func (c *Client) ExportModels() ([]Model, error)

ExportModels fetches all models via /api/v1/models/export

func (*Client) ExportTools added in v0.3.0

func (c *Client) ExportTools() ([]Tool, error)

ExportTools fetches all tools from /api/v1/tools/export

func (*Client) GetAPIKey added in v0.5.0

func (c *Client) GetAPIKey() string

GetAPIKey returns the API key being used by the client

func (*Client) GetAllChats added in v0.4.0

func (c *Client) GetAllChats() ([]Chat, error)

GetAllChats fetches all chats from /api/v1/chats/all

func (*Client) GetAllChatsDB added in v0.15.0

func (c *Client) GetAllChatsDB() ([]Chat, error)

GetAllChatsDB fetches all chats from database /api/v1/chats/all/db

func (*Client) GetAllFeedbacks added in v0.5.0

func (c *Client) GetAllFeedbacks() ([]Feedback, error)

GetAllFeedbacks fetches all feedbacks from /api/v1/evaluations/feedbacks/all/export

func (*Client) GetAllGroups added in v0.5.0

func (c *Client) GetAllGroups() ([]Group, error)

GetAllGroups fetches all groups from /api/v1/groups/

func (*Client) GetAllUsers added in v0.5.0

func (c *Client) GetAllUsers() ([]User, error)

GetAllUsers fetches all users from /api/v1/users/ with pagination support

func (*Client) GetArchivedChats added in v0.15.0

func (c *Client) GetArchivedChats(page int, query, orderBy, direction string) ([]ChatTitleID, error)

GetArchivedChats fetches archived chats

func (*Client) GetBaseURL added in v0.3.0

func (c *Client) GetBaseURL() string

GetBaseURL returns the base URL of the client

func (*Client) GetChatByID added in v0.4.0

func (c *Client) GetChatByID(id string) (*Chat, error)

GetChatByID fetches a specific chat by ID

func (*Client) GetChatsByFolder added in v0.15.0

func (c *Client) GetChatsByFolder(folderID string, page int) ([]Chat, error)

GetChatsByFolder fetches chats in a specific folder

func (*Client) GetChatsList added in v0.15.0

func (c *Client) GetChatsList(page int, includePinned, includeFolders bool) ([]ChatTitleID, error)

GetChatsList fetches paginated list of chats from /api/v1/chats/list

func (*Client) GetFeedbackByID added in v0.5.0

func (c *Client) GetFeedbackByID(id string) (*Feedback, error)

GetFeedbackByID fetches a specific feedback by ID

func (*Client) GetFile

func (c *Client) GetFile(fileID string) (*FileData, error)

GetFile fetches a single file by ID

func (*Client) GetFileWithContent added in v0.3.0

func (c *Client) GetFileWithContent(id string) (*FileExport, error)

GetFileWithContent fetches a file with its full content

func (*Client) GetGroupByID added in v0.5.0

func (c *Client) GetGroupByID(id string) (*Group, error)

GetGroupByID fetches a specific group by ID

func (*Client) GetKnowledgeByID

func (c *Client) GetKnowledgeByID(id string) (*KnowledgeBase, error)

GetKnowledgeByID fetches a specific knowledge base with its files

func (*Client) GetModelByID added in v0.2.0

func (c *Client) GetModelByID(id string) (*Model, error)

GetModelByID fetches a specific model by ID

func (*Client) GetSharedChat added in v0.15.0

func (c *Client) GetSharedChat(shareID string) (*Chat, error)

GetSharedChat fetches a shared chat by share ID

func (*Client) ImportChat added in v0.4.0

func (c *Client) ImportChat(chat *Chat) error

ImportChat imports a chat via /api/v1/chats/import

func (*Client) ImportModels added in v0.2.0

func (c *Client) ImportModels(models []Model) error

ImportModels posts models to /api/v1/models/import

func (*Client) ImportTool added in v0.3.0

func (c *Client) ImportTool(tool *ToolForm) error

ImportTool creates or imports a tool

func (*Client) ImportUser added in v0.5.0

func (c *Client) ImportUser(userForm *UserForm) error

ImportUser creates a new user via /api/v1/auths/add

func (*Client) ListFiles added in v0.3.0

func (c *Client) ListFiles() ([]FileMetadata, error)

ListFiles fetches all files (metadata only) from /api/v1/files/

func (*Client) ListFunctions added in v0.4.0

func (c *Client) ListFunctions() ([]Function, error)

ListFunctions fetches all functions from /api/v1/functions/export

func (*Client) ListKnowledge

func (c *Client) ListKnowledge() ([]KnowledgeBase, error)

ListKnowledge fetches all knowledge bases from the API

func (*Client) ListMemories added in v0.4.0

func (c *Client) ListMemories() ([]Memory, error)

ListMemories fetches all memories from /api/v1/memories/

func (*Client) ListPrompts added in v0.3.0

func (c *Client) ListPrompts() ([]Prompt, error)

ListPrompts fetches all prompts from /api/v1/prompts/

func (*Client) ListTools added in v0.4.0

func (c *Client) ListTools() ([]Tool, error)

ListTools fetches all tools from /api/v1/tools/

func (*Client) RemoveFileFromKnowledge

func (c *Client) RemoveFileFromKnowledge(knowledgeID, fileID string) error

RemoveFileFromKnowledge removes a file from a knowledge base

func (*Client) SearchChats added in v0.15.0

func (c *Client) SearchChats(query string, page int) ([]ChatTitleID, error)

SearchChats searches chats by text query

func (*Client) UpdateKnowledge

func (c *Client) UpdateKnowledge(id string, form *KnowledgeForm) error

UpdateKnowledge updates an existing knowledge base

func (*Client) UploadFile

func (c *Client) UploadFile(filename string, content []byte) (*FileUploadResponse, error)

UploadFile uploads a file via multipart/form-data

type Feedback added in v0.5.0

type Feedback struct {
	ID        string                 `json:"id"`
	UserID    string                 `json:"user_id"`
	Type      string                 `json:"type,omitempty"`
	Data      map[string]interface{} `json:"data"`
	Meta      map[string]interface{} `json:"meta,omitempty"`
	Snapshot  map[string]interface{} `json:"snapshot,omitempty"`
	CreatedAt int64                  `json:"created_at"`
	UpdatedAt int64                  `json:"updated_at"`
}

Feedback represents a feedback/evaluation from the Open WebUI API

type FeedbackForm added in v0.5.0

type FeedbackForm struct {
	Type     string                 `json:"type,omitempty"`
	Data     map[string]interface{} `json:"data"`
	Meta     map[string]interface{} `json:"meta,omitempty"`
	Snapshot map[string]interface{} `json:"snapshot,omitempty"`
}

FeedbackForm for creating/updating feedbacks

type FileContent

type FileContent struct {
	Status  string `json:"status"`
	Content string `json:"content"`
}

FileContent contains the actual file content

type FileData

type FileData struct {
	ID            string                 `json:"id"`
	UserID        string                 `json:"user_id"`
	Hash          string                 `json:"hash"`
	Filename      string                 `json:"filename"`
	Path          string                 `json:"path"`
	Data          *FileContent           `json:"data"`
	Meta          FileMeta               `json:"meta"`
	AccessControl map[string]interface{} `json:"access_control"`
	CreatedAt     int64                  `json:"created_at"`
	UpdatedAt     int64                  `json:"updated_at"`
}

FileData represents a complete file with content from the API

type FileExistsError

type FileExistsError struct {
	Path string
}

FileExistsError indicates a backup file already exists

func (*FileExistsError) Error

func (e *FileExistsError) Error() string

Error implements the error interface for FileExistsError

type FileExport added in v0.3.0

type FileExport struct {
	ID            string                 `json:"id"`
	UserID        string                 `json:"user_id"`
	Filename      string                 `json:"filename"`
	Meta          FileMeta               `json:"meta"`
	Data          *FileContent           `json:"data"`
	Hash          string                 `json:"hash,omitempty"`
	AccessControl map[string]interface{} `json:"access_control,omitempty"`
	CreatedAt     int64                  `json:"created_at"`
	UpdatedAt     int64                  `json:"updated_at"`
}

FileExport represents a complete file export with all metadata

type FileMeta

type FileMeta struct {
	Name           string                 `json:"name"`
	ContentType    string                 `json:"content_type"`
	Size           int64                  `json:"size"`
	Data           map[string]interface{} `json:"data"`
	CollectionName string                 `json:"collection_name"`
}

FileMeta contains file-specific metadata

type FileMetadata

type FileMetadata struct {
	ID        string   `json:"id"`
	Meta      FileMeta `json:"meta"`
	CreatedAt int64    `json:"created_at"`
	UpdatedAt int64    `json:"updated_at"`
}

FileMetadata represents file metadata from the API

type FileUploadResponse

type FileUploadResponse struct {
	ID        string   `json:"id"`
	UserID    string   `json:"user_id"`
	Filename  string   `json:"filename"`
	Meta      FileMeta `json:"meta"`
	CreatedAt int64    `json:"created_at"`
	UpdatedAt int64    `json:"updated_at"`
}

FileUploadResponse represents the response from uploading a file

type Function added in v0.4.0

type Function struct {
	ID        string       `json:"id"`
	UserID    string       `json:"user_id"`
	Name      string       `json:"name"`
	Type      string       `json:"type"`
	Content   string       `json:"content"`
	Meta      FunctionMeta `json:"meta"`
	IsActive  bool         `json:"is_active"`
	IsGlobal  bool         `json:"is_global"`
	UpdatedAt int64        `json:"updated_at"`
	CreatedAt int64        `json:"created_at"`
}

Function represents a function from the Open WebUI API

type FunctionMeta added in v0.4.0

type FunctionMeta struct {
	Description string                 `json:"description,omitempty"`
	Manifest    map[string]interface{} `json:"manifest,omitempty"`
}

FunctionMeta contains function-specific metadata

type Group added in v0.5.0

type Group struct {
	ID          string                 `json:"id"`
	UserID      string                 `json:"user_id"`
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	UserIDs     []string               `json:"user_ids"`
	AdminIDs    []string               `json:"admin_ids,omitempty"`
	Permissions map[string]interface{} `json:"permissions,omitempty"`
	Meta        map[string]interface{} `json:"meta,omitempty"`
	CreatedAt   int64                  `json:"created_at"`
	UpdatedAt   int64                  `json:"updated_at"`
}

Group represents a group from the Open WebUI API

type GroupForm added in v0.5.0

type GroupForm struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	UserIDs     []string `json:"user_ids,omitempty"`
}

GroupForm for creating/updating groups

type KnowledgeBase

type KnowledgeBase struct {
	ID            string                 `json:"id"`
	UserID        string                 `json:"user_id"`
	Name          string                 `json:"name"`
	Description   string                 `json:"description"`
	Data          *KnowledgeData         `json:"data"`
	Meta          map[string]interface{} `json:"meta"`
	AccessControl map[string]interface{} `json:"access_control"`
	CreatedAt     int64                  `json:"created_at"`
	UpdatedAt     int64                  `json:"updated_at"`
	Files         []FileMetadata         `json:"files"`
}

KnowledgeBase represents a knowledge base from the API

type KnowledgeCreateResponse

type KnowledgeCreateResponse struct {
	ID            string                 `json:"id"`
	UserID        string                 `json:"user_id"`
	Name          string                 `json:"name"`
	Description   string                 `json:"description"`
	Data          *KnowledgeData         `json:"data"`
	Meta          map[string]interface{} `json:"meta"`
	AccessControl map[string]interface{} `json:"access_control"`
	CreatedAt     int64                  `json:"created_at"`
	UpdatedAt     int64                  `json:"updated_at"`
}

KnowledgeCreateResponse represents the response from creating a knowledge base

type KnowledgeData

type KnowledgeData struct {
	FileIDs []string `json:"file_ids"`
}

KnowledgeData contains file IDs associated with the knowledge base

type KnowledgeExistsError

type KnowledgeExistsError struct {
	Name string
}

KnowledgeExistsError indicates a knowledge base with the name already exists

func (*KnowledgeExistsError) Error

func (e *KnowledgeExistsError) Error() string

Error implements the error interface for KnowledgeExistsError

type KnowledgeForm

type KnowledgeForm struct {
	Name          string                 `json:"name"`
	Description   string                 `json:"description"`
	Data          *KnowledgeData         `json:"data,omitempty"`
	AccessControl map[string]interface{} `json:"access_control,omitempty"`
}

KnowledgeForm represents the request body for creating/updating knowledge

type KnowledgeItem added in v0.2.0

type KnowledgeItem struct {
	Type string                 `json:"type"` // "file" or "collection"
	Data map[string]interface{} `json:"-"`    // Raw data for flexibility
}

KnowledgeItem represents a single knowledge item (file or collection)

type Memory added in v0.4.0

type Memory struct {
	ID        string `json:"id"`
	UserID    string `json:"user_id"`
	Content   string `json:"content"`
	UpdatedAt int64  `json:"updated_at"`
	CreatedAt int64  `json:"created_at"`
}

Memory represents a memory from the Open WebUI API

type Message added in v0.4.0

type Message struct {
	ID          string                 `json:"id,omitempty"`
	ParentID    *string                `json:"parentId,omitempty"`
	ChildrenIDs []string               `json:"childrenIds,omitempty"`
	Role        string                 `json:"role"`
	Content     string                 `json:"content"`
	Model       string                 `json:"model,omitempty"`
	Timestamp   int64                  `json:"timestamp,omitempty"`
	Meta        map[string]interface{} `json:"meta,omitempty"`
}

Message represents a single message in a chat

type Model added in v0.2.0

type Model struct {
	ID            string                 `json:"id"`
	UserID        string                 `json:"user_id"`
	BaseModelID   *string                `json:"base_model_id"`
	Name          string                 `json:"name"`
	Params        map[string]interface{} `json:"params"`
	Meta          ModelMeta              `json:"meta"`
	AccessControl map[string]interface{} `json:"access_control"`
	IsActive      bool                   `json:"is_active"`
	UpdatedAt     int64                  `json:"updated_at"`
	CreatedAt     int64                  `json:"created_at"`
}

Model represents a model from the Open WebUI API

type ModelForm added in v0.2.0

type ModelForm struct {
	ID            string                 `json:"id"`
	BaseModelID   *string                `json:"base_model_id,omitempty"`
	Name          string                 `json:"name"`
	Params        map[string]interface{} `json:"params"`
	Meta          ModelMeta              `json:"meta"`
	AccessControl map[string]interface{} `json:"access_control,omitempty"`
	IsActive      bool                   `json:"is_active"`
}

ModelForm for creating/updating models

type ModelMeta added in v0.2.0

type ModelMeta struct {
	ProfileImageURL string                   `json:"profile_image_url,omitempty"`
	Description     *string                  `json:"description,omitempty"`
	Capabilities    map[string]interface{}   `json:"capabilities,omitempty"`
	Knowledge       []map[string]interface{} `json:"knowledge,omitempty"` // Can be files or collections
	Tags            interface{}              `json:"tags,omitempty"`      // Flexible type to handle API changes
}

ModelMeta contains model metadata including knowledge base references

type Prompt added in v0.3.0

type Prompt struct {
	Command       string                 `json:"command"`
	Title         string                 `json:"title"`
	Content       string                 `json:"content"`
	UserID        string                 `json:"user_id,omitempty"`
	AccessControl map[string]interface{} `json:"access_control,omitempty"`
	UpdatedAt     int64                  `json:"updated_at,omitempty"`
	CreatedAt     int64                  `json:"created_at,omitempty"`
}

Prompt represents a prompt from the Open WebUI API

type PromptForm added in v0.3.0

type PromptForm struct {
	Command       string                 `json:"command"`
	Title         string                 `json:"title"`
	Content       string                 `json:"content"`
	AccessControl map[string]interface{} `json:"access_control,omitempty"`
}

PromptForm for creating/updating prompts

type Tool added in v0.3.0

type Tool struct {
	ID            string                 `json:"id"`
	UserID        string                 `json:"user_id"`
	Name          string                 `json:"name"`
	Content       string                 `json:"content"`
	Meta          ToolMeta               `json:"meta"`
	AccessControl map[string]interface{} `json:"access_control"`
	UpdatedAt     int64                  `json:"updated_at"`
	CreatedAt     int64                  `json:"created_at"`
}

Tool represents a tool from the Open WebUI API

type ToolForm added in v0.3.0

type ToolForm struct {
	ID            string                 `json:"id"`
	Name          string                 `json:"name"`
	Content       string                 `json:"content"`
	Meta          ToolMeta               `json:"meta"`
	AccessControl map[string]interface{} `json:"access_control,omitempty"`
}

ToolForm for creating/updating tools

type ToolMeta added in v0.3.0

type ToolMeta struct {
	Description string                 `json:"description,omitempty"`
	Manifest    map[string]interface{} `json:"manifest,omitempty"`
}

ToolMeta contains tool-specific metadata

type User added in v0.5.0

type User struct {
	ID              string                 `json:"id"`
	Name            string                 `json:"name"`
	Email           string                 `json:"email"`
	Username        string                 `json:"username,omitempty"`
	Role            string                 `json:"role"`
	ProfileImageURL string                 `json:"profile_image_url,omitempty"`
	Bio             string                 `json:"bio,omitempty"`
	Gender          string                 `json:"gender,omitempty"`
	DateOfBirth     string                 `json:"date_of_birth,omitempty"`
	Info            map[string]interface{} `json:"info,omitempty"`
	Settings        map[string]interface{} `json:"settings,omitempty"`
	APIKey          string                 `json:"api_key,omitempty"`
	OAuthSub        string                 `json:"oauth_sub,omitempty"`
	LastActiveAt    int64                  `json:"last_active_at,omitempty"`
	UpdatedAt       int64                  `json:"updated_at,omitempty"`
	CreatedAt       int64                  `json:"created_at,omitempty"`
}

User represents a user from the Open WebUI API

type UserForm added in v0.5.0

type UserForm struct {
	Name            string `json:"name"`
	Email           string `json:"email"`
	Password        string `json:"password"`
	Role            string `json:"role"`
	ProfileImageURL string `json:"profile_image_url"`
}

UserForm for creating/updating users

type UserListResponse added in v0.5.0

type UserListResponse struct {
	Users []User `json:"users"`
	Total int    `json:"total"`
}

UserListResponse represents the paginated response from the users endpoint

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL