knowledge
Knowledge base models, directory structures, and file management forms.
Classes
KnowledgeModel
Bases: BaseModel
Represents a knowledge base.
Attributes
meta
Metadata associated with the knowledge base.
Dict Fields
legacy(bool, optional): Whether this is a legacy knowledge base migrated from older versionsdocument(bool, optional): Whether this knowledge base represents a document-type structuretags(list[str], optional): List of tags associated with the knowledge baseid(str, optional): Knowledge base IDname(str, optional): Knowledge base namecollection_name(str, optional): Collection nametype(str, optional): Type of knowledge (e.g., 'file', 'collection')collection_names(list[str], optional): List of collection names for collection-type knowledge
Additional keys may exist. Complete structure not found in reference code.
access_grants
access_grants: list[AccessGrantModel] = Field(
default_factory=list
)
List of access grants controlling who can read/write this knowledge base. Replaces the legacy access_control field.
access_control
Access control settings.
None: Public access, available to all users with the "user" role. Requires "sharing.public_knowledge" permission for non-admin users to set.{}: Private access, restricted exclusively to the owner.- Custom permissions: Specific access control for reading and writing. Can specify group or user-level restrictions. Example:
Dict Fields
read(dict, optional): Read access permissionswrite(dict, optional): Write access permissionsread.group_ids(list[str], optional): List of group IDs with read accessread.user_ids(list[str], optional): List of user IDs with read accesswrite.group_ids(list[str], optional): List of group IDs with write accesswrite.user_ids(list[str], optional): List of user IDs with write access
KnowledgeUserModel
Bases: KnowledgeModel
Represents a knowledge base with user information.
Inherits access_control from KnowledgeModel. Access is determined by:
- Direct user ownership (user_id matches)
- Access control permissions (read/write for groups and users)
- Admin users have full access regardless of access_control settings
- Code Reference models knowledge Classes KnowledgeUserResponse
Attributes
KnowledgeResponse
Bases: KnowledgeModel
Represents a knowledge base response, optionally including files.
Inherits meta from KnowledgeModel. See KnowledgeModel.meta for complete documentation
of the metadata structure and valid fields.
- Code Reference routers knowledge Classes KnowledgeClient Functions
- Code Reference models knowledge Classes KnowledgeFilesResponse
Attributes
files
files: Optional[list[Union[FileMetadataResponse, dict]]] = (
None
)
List of files associated with the knowledge base.
KnowledgeUserResponse
Bases: KnowledgeUserModel
Represents a knowledge base response including user information and files.
Inherits access_control from KnowledgeModel. See KnowledgeModel.access_control
for complete documentation of the access control structure and permissions.
- Code Reference routers knowledge Classes KnowledgeClient Functions get_knowledge_list
- Code Reference models knowledge Classes KnowledgeAccessResponse
Attributes
files
files: Optional[list[Union[FileMetadataResponse, dict]]] = (
None
)
List of files associated with the knowledge base.
KnowledgeForm
Bases: BaseModel
Form for creating or updating a knowledge base.
- Code Reference routers knowledge Classes KnowledgeClient Functions
Attributes
access_grants
List of access grants for the knowledge base.
Dict Fields:
- id (str, optional): Unique identifier for the grant
- principal_type (str, required): 'user' or 'group'
- principal_id (str, required): User/group ID, or '*' for public access
- permission (str, required): 'read' or 'write'
access_control
Access control settings.
None: Public access, available to all users with the "user" role.{}: Private access, restricted exclusively to the owner.- Custom permissions: Specific access control for reading and writing. Can specify group or user-level restrictions. Example:
Dict Fields
read(dict, optional): Read access permissionswrite(dict, optional): Write access permissionsread.group_ids(list[str], optional): List of group IDs with read accessread.user_ids(list[str], optional): List of user IDs with read accesswrite.group_ids(list[str], optional): List of group IDs with write accesswrite.user_ids(list[str], optional): List of user IDs with write access
KnowledgeFilesResponse
Bases: KnowledgeResponse
Represents a knowledge base response with full file metadata.
Inherits access_control from KnowledgeModel. Access control determines who can read and write to this knowledge base.
Attributes
files
files: Optional[list[FileMetadataResponse]] = None
List of files associated with the knowledge base.
write_access
Whether the current user has write access to the knowledge base.
warnings
Warnings returned during processing, e.g., if some files failed to process in a batch operation.
Dict Fields
message(str, required): Human-readable warning message describing the issueerrors(list[str], required): List of specific error details for failed operations
KnowledgeAccessResponse
Bases: KnowledgeUserResponse
Response model for knowledge base access information.
- Code Reference models knowledge Classes KnowledgeAccessListResponse Attributes items
KnowledgeAccessListResponse
Bases: BaseModel
Response model for a list of knowledge bases with access info.
- Code Reference routers knowledge Classes KnowledgeClient Functions
Attributes
FileUserResponse
Bases: FileModelResponse
File response with user details.
- Code Reference models knowledge Classes KnowledgeFileListResponse Attributes items
Attributes
KnowledgeDirectoryModel
Bases: BaseModel
Represents a directory within a knowledge base.
Attributes
parent_id
The ID of the parent directory, or None if this is a root directory.
KnowledgeDirectoryCreateForm
Bases: BaseModel
Form for creating a new directory in a knowledge base.
- Code Reference routers knowledge Classes KnowledgeClient Functions create_knowledge_directory
KnowledgeDirectoryUpdateForm
Bases: BaseModel
Form for updating a directory in a knowledge base.
- Code Reference routers knowledge Classes KnowledgeClient Functions update_knowledge_directory
KnowledgeFileMoveForm
Bases: BaseModel
Form for moving a file to a different directory within a knowledge base.
- Code Reference routers knowledge Classes KnowledgeClient Functions move_file_in_knowledge
FileManifestEntry
Bases: BaseModel
Represents a file entry in a local manifest for sync diff comparison.
- Code Reference models knowledge Classes SyncDiffForm Attributes manifest
SyncDiffForm
Bases: BaseModel
Form for computing a sync diff against a knowledge base.
- Code Reference routers knowledge Classes KnowledgeClient Functions sync_knowledge_diff
Attributes
manifest
manifest: list[FileManifestEntry]
List of file manifest entries representing the local state.
SyncDiffResponse
Bases: BaseModel
Response containing the diff between a local manifest and a knowledge base.
- Code Reference routers knowledge Classes KnowledgeClient Functions sync_knowledge_diff
Attributes
added
Files that exist locally but not in the knowledge base.
Dict Fields
filename(str, required): The base filename of the new filepath(str, required): The relative directory path, or '' for root
modified
Files that exist in both but differ (checksum mismatch).
Dict Fields
filename(str, required): The base filenamepath(str, required): The relative directory path, or '' for rootstale_file_id(str, required): The file ID of the existing version to replace
deleted
Files that exist in the knowledge base but not in the local manifest.
Dict Fields
file_id(str, required): The ID of the file to removefilename(str, required): The base filename
SyncCleanupForm
Bases: BaseModel
Form for cleaning up stale files and directories after a sync.
- Code Reference routers knowledge Classes KnowledgeClient Functions sync_knowledge_cleanup
KnowledgeFileListResponse
Bases: BaseModel
Response model for a list of knowledge base files.
- Code Reference routers knowledge Classes KnowledgeClient Functions search_knowledge_files
Attributes
directories
directories: list[KnowledgeDirectoryModel] = []
List of directories at the current level in the knowledge base.
breadcrumbs
breadcrumbs: list[KnowledgeDirectoryModel] = []
Ordered list of ancestor directories from root to the current directory (for navigation).
KnowledgeFileIdForm
KnowledgeAccessGrantsForm
Bases: BaseModel
Form for updating access grants on a knowledge base.
Attributes
access_grants
List of access grants to set on the knowledge base.
Dict Fields:
- id (str, optional): Unique identifier for the grant
- principal_type (str, required): 'user' or 'group'
- principal_id (str, required): User/group ID, or '*' for public access
- permission (str, required): 'read' or 'write'
ExternalKnowledgeConnectionForm
Bases: BaseModel
Form for creating or updating an external knowledge connection.
An external connection describes how to reach an external vector
database (endpoint + credentials + provider). Connections are stored
as a list under the external_knowledge.connections config key, not
in a dedicated table. provider must be one of qdrant, milvus,
or pgvector; any other value is rejected with HTTP 400.
- Code Reference routers knowledge Classes KnowledgeClient Functions
Attributes
endpoint
Connection URL for the external system. For qdrant/milvus an HTTP URL; for pgvector a postgresql connection string (required, non-empty).
auth_config
Credentials for the external system. Ignored for pgvector (always {}).
Dict Fields
api_key(str, optional): API key / bearer token (used by qdrant and milvus)token(str, optional): Alternative token field read by milvus whenapi_keyis absent
config
Provider-specific connection options. Only whitelisted keys are kept.
Dict Fields
timeout(int, optional): Request timeout in seconds (all providers)db_name(str, optional): Milvus database name (milvus provider only)
capabilities
Feature flags for the connection. Defaults to {retrieve: True} when omitted.
Dict Fields
retrieve(bool, optional): Whether retrieval/search is supported; defaults to True
ExternalKnowledgeSourceForm
Bases: BaseModel
Form describing a single collection (source) inside an external connection.
type is currently restricted to collection; any other value is
rejected with HTTP 400. config.content_field is always required.
Attributes
config
Field mapping from the external system's schema to Open WebUI's document model.
Dict Fields
content_field(str, required): Dotted path to the text content (e.g.payload.text,data.text,text)metadata_field(str, optional): Dotted path to a metadata object to attach to each resultdocument_id_field(str, optional): Dotted path to a stable document id (defaults toid)vector_field(str, optional): Name of the vector column. Required formilvusandpgvector; optional forqdranttable_name(str, optional): Qualified table name (pgvectorprovider only, e.g.document_chunk)collection_field(str, optional): Column that holds the collection name (pgvectorprovider only)
ExternalKnowledgeCreateForm
Bases: BaseModel
Form for POST /external/knowledge/create.
Creates a read-only knowledge base backed by an EXISTING external
connection (connection_id must already exist). Unlike the source
create/update flow, this path does NOT run a retrieval test; it only
validates and normalizes the source mapping.
- Code Reference routers knowledge Classes KnowledgeClient Functions create_external_knowledge
Attributes
source
source: ExternalKnowledgeSourceForm
The collection/source mapping to retrieve from within the connection.
access_grants
Optional access grants to set on the new knowledge base.
Dict Fields
id(str, optional): Unique identifier for the grantprincipal_type(str, required):userorgroupprincipal_id(str, required): User/group ID, or*for public accesspermission(str, required):readorwrite
ExternalKnowledgeSourceCreateForm
Bases: BaseModel
Form for POST /external/source/create.
Creates BOTH a new external connection AND a read-only knowledge base
in one shot. Before persisting, the backend runs a retrieval test
against the supplied connection+source; if the test returns no
documents the request fails with HTTP 400. This is the "add knowledge
connection" flow in the admin UI.
- Code Reference models knowledge Classes ExternalKnowledgeSourceUpdateForm
- Code Reference routers knowledge Classes KnowledgeClient Functions create_external_knowledge_source
Attributes
connection
connection: ExternalKnowledgeConnectionForm
Full connection definition to create and persist.
access_grants
Optional access grants to set on the new knowledge base.
Dict Fields
id(str, optional): Unique identifier for the grantprincipal_type(str, required):userorgroupprincipal_id(str, required): User/group ID, or*for public accesspermission(str, required):readorwrite
test_query
Query string used for the mandatory pre-create retrieval test (required, non-empty).
ExternalKnowledgeSourceUpdateForm
Bases: ExternalKnowledgeSourceCreateForm
Form for PATCH /external/source/{id}.
Identical to ExternalKnowledgeSourceCreateForm: the connection and
source mapping are fully replaced and a retrieval test is re-run
before the update is committed. No documents from the test => HTTP 400.
- Code Reference routers knowledge Classes KnowledgeClient Functions update_external_knowledge_source
ExternalKnowledgeSourceTestForm
Bases: BaseModel
Form for POST /external/source/test.
Runs an ad-hoc retrieval test against a connection+source definition
WITHOUT persisting anything. If connection_id is supplied the stored
connection is loaded and merged with connection; otherwise a
throwaway connection is built from connection.
- Code Reference routers knowledge Classes KnowledgeClient Functions test_external_knowledge_source
Attributes
connection_id
Optional ID of an existing connection to load and merge with connection.
connection
connection: ExternalKnowledgeConnectionForm
Connection definition to test against (merged on top of connection_id if given).
ExternalKnowledgeRetrieveTestForm
Bases: BaseModel
Form for POST /external/connections/{id}/retrieve-test.
Runs an ad-hoc retrieval test against an EXISTING connection by id.
source is optional; if omitted the backend uses a default source
(name='test', content_field='payload.text').
- Code Reference routers knowledge Classes KnowledgeClient Functions test_external_knowledge_retrieval
Attributes
source
source: Optional[ExternalKnowledgeSourceForm] = None
Optional collection/source mapping; defaults to a test/payload.text source.
ExternalKnowledgeConnectionListResponse
Bases: BaseModel
Response for GET /external/connections.
items are SANITIZED connection dicts: the secret auth_config is
stripped and replaced by a boolean auth_configured flag.
- Code Reference routers knowledge Classes KnowledgeClient Functions get_external_knowledge_connections
Attributes
items
Sanitized external connection dicts.
Dict Fields
id(str, required): Connection idname(str, required): Connection nameprovider(str, required):qdrant,milvus, orpgvectorendpoint(str, required): Connection URL / connection stringconfig(dict, optional): Provider options (timeout, anddb_namefor milvus)capabilities(dict, optional): Feature flags (e.g.{retrieve: True})health(dict, optional): Last/testresult, or Noneenabled(bool, required): Whether the connection is activecreated_by(str, required): User id of the creatorcreated_at(int, required): Creation timestamp (epoch)updated_at(int, required): Last-update timestamp (epoch)auth_configured(bool, required): True if credentials are stored (auth_config is never returned)