client.knowledge_bases manages KBs and their documents: ingestion (upload & train), listing, semantic search, and export/import. A KB stores documents as vectors so agents and workflows can retrieve from them.
Create a KB
Use a v3 config (the current format). KBConfigV3 has sensible defaults, so you usually only set the embedding model if you need a specific one.
KBConfigV3 fields: embedding_model: list[str]
(default ["vertexai/text-multilingual-embedding-002"]), default_chunk_size
(2048), default_chunk_overlap (512), csv_row_as_document (True).
Manage KBs
Adding documents
Upload local files (they ingest & train asynchronously — returns run ids):
Train from a source (URL / connector / etc. via a Source):
Create a bare document row (e.g. a folder or a placeholder):
Listing & iterating documents
status is one of trained | training | error | uploaded | folder. Omit it to list all statuses (the SDK loops them for you). Prefer the iterator to walk every document without hand-rolling pages:
KnowledgeBaseDocument fields: id, name, prefix, status, size,
source_type, file_id, content_type, created_at, updated_at, error.
Document operations
Search
Semantic search returns scored chunks:
Document search returns matching documents (metadata), not chunks:
Structure, types & export
version is "auto" | "v3" | "v4"; mode is "clone" | "version" | "replace".
Recipe: export a KB’s documents to a spreadsheet