Lifecycle
new
str
required
Display name of the knowledge base.
Optional[EmbeddingModel]
default:"None"
One of the strings listed in
EmbeddingModel. Defaults to the platform default if omitted.Optional[IndexingConfig]
default:"None"
Chunking + analysis options. See
IndexingConfig.KnowledgeBase
The new
KnowledgeBase instance.fetch
id or name. Exactly one is required.
list
delete
Folders
create_folder
folder_id to any add_* method to ingest into a specific folder, or use move_items to reorganise afterwards.
Ingestion
Every ingestion call returns anIngestionTask. The _and_wait variants poll until the task reaches COMPLETED or FAILED; the bare variants return immediately and let you drive the polling yourself via ingestion_status.
add_files
Path, raw bytes, or a file-like object.
add_files_and_wait
add_files. Polls until the task reaches a terminal status or timeout elapses. Raises KbIngestionTimeout on timeout, KbIngestionFailed if the task ends in FAILED.
add_urls
UrlConfig.
add_urls_and_wait
add_urls.
add_folder / add_folder_and_wait
_and_wait blocks until done (default timeout=600).
add_tables / add_tables_and_wait
_and_wait variant blocks until done.
ingestion_status
add_* call to drive your own polling loop.
Querying
query
str
required
The query string.
int
default:"10"
Maximum number of chunks to return (post-rerank if
rerank= is set).Optional[list[FilterClause]]
default:"None"
Metadata filters. See
FilterClause.Optional[HybridConfig]
default:"None"
Enable hybrid (vector + keyword) retrieval. See
HybridConfig.Optional[RerankConfig]
default:"None"
Cross-encoder rerank over the top candidates. See
RerankConfig.Optional[QaConfig]
default:"None"
Run an LLM over the retrieved context and populate
result["answer"]. The backend may still return no answer, so treat answer as optional. See QaConfig.Optional[QueryConfig]
default:"None"
Pass a pre-built
QueryConfig instead of individual kwargs. Cannot be combined with other tuning kwargs.QueryResult
Typed
QueryResult TypedDict — use dict-key access: result["chunks"], result["citations"] (may be empty), result.get("answer") (optional — may be absent/empty), result.get("usage") (optional).Items
list_items
scroll
list_items would require manual cursor management.
get_item
move_items
create_folder).
delete_items
update_item_metadata
FilterClause.
Accessors
A KB exposes three accessor objects for scoped operations. They keep the top-level surface lean by routing item / folder / metadata-autogen calls through dedicated handles.item
folder
folder_id= to ingestion calls or list_items).
metadata_autogen
autogen_id.
create_config
extraction_instructions tells the LLM what to extract from each item; query_instructions controls how that metadata is matched at retrieval time. traversal_type is one of "document", "folder", or "chunk".
list_configs
get_config
replace_config
get_config and merge if you only want to change one field.
delete_config
run
IngestionTask you can poll, or use the wait variant below.
run_and_wait
metadata-autogen example for the full lifecycle.
Integrations
integrations
resync_integration
set_rescrape_frequency
item_id / integration_id. See RescrapeFrequency.
Types
IndexingConfig
Optional[int]
default:"None"
Optional[int]
default:"None"
bool
default:"False"
Run document-level analysis during indexing (slower, richer metadata).
Optional[SplitterMethod]
default:"None"
See
SplitterMethod.Optional[SegmentationMethod]
default:"None"
bool
default:"False"
Optional[list[str]]
default:"None"
str
default:"'Default'"
Optional[str]
default:"None"
UrlConfig
bool
default:"False"
When
True, crawl outbound links recursively up to url_limit.Optional[int]
default:"None"
Maximum number of URLs to fetch in a recursive crawl.
Optional[bool]
default:"None"
str
default:"'CHUNKS'"
RescrapeFrequency
default:"NEVER"
See
RescrapeFrequency.Optional[str]
default:"None"
QueryConfig
Pre-built bundle of every option query(...) accepts as kwargs. Pass config= instead of individual kwargs when you want to reuse a config across queries.
int
default:"10"
Optional[list[FilterClause]]
default:"None"
Optional[SortClause]
default:"None"
Optional[HybridConfig]
default:"None"
Optional[RerankConfig]
default:"None"
Optional[QaConfig]
default:"None"
Optional[RetrievalUnit]
default:"None"
Optional[float]
default:"None"
Optional[str]
default:"None"
HybridConfig
float
default:"0.5"
Weight between vector (
1.0) and keyword (0.0) scoring.Optional[str]
default:"None"
RerankConfig
str
required
Reranker identifier (e.g.
"bge-reranker-v2-m3", "cohere/rerank-english-v3.0").Optional[int]
default:"None"
Number of chunks to keep after rerank.
Optional[bool]
default:"None"
QaConfig
bool
default:"True"
Whether to include
Citations in the response.Optional[str]
default:"None"
Optional[str]
default:"None"
Optional[str]
default:"None"
FilterClause
str
required
Metadata field name to filter on.
FilterOperator
required
See
FilterOperator.Any
required
SortClause
str
required
SortDirection
default:"ASC"
See
SortDirection.IngestionTask
The handle returned by every add_* call. Reaches a terminal status (COMPLETED, FAILED, or WARNING) once indexing finishes.
str
required
str
required
IngestionStatus
required
See
IngestionStatus.list[str]
default:"[]"
The new item ids once the task completes.
Optional[str]
default:"None"
list[FailedUpload]
default:"[]"
QueryResult
The typed return of kb.query(...). It is a TypedDict — access fields by key (result["chunks"], result.get("answer")), not by attribute.
str
required
list[RetrievedChunk]
default:"[]"
list[Citation]
May be an empty list (e.g. when the backend returns no citations).
NotRequired[str]
LLM-generated answer when
qa=QaConfig(mode=...) is set. Optional key — may be absent even with qa set (access via result.get("answer")).NotRequired[UsageInfo]
RetrievedChunk
str
required
str
required
float
required
str
required
RetrievalUnit
required
Optional[dict[str, Any]]
default:"None"
Enums
EmbeddingModel
String literal. Supported values:
"text-embedding-3-large""text-embedding-3-small""text-embedding-ada-002""embed-v4.0""voyage-3"·"voyage-4"·"voyage-multimodal-3"·"voyage-code-3""google-text-embedding-004"·"google-text-embedding-005""together-bge-large-en-v1.5"·"together-m2-bert-80M-8k-retrieval"
SplitterMethod
MARKDOWN · SENTENCE · DYNAMIC · CODE
RescrapeFrequency
NEVER · QUARTER_HOURLY · HOURLY · DAILY · WEEKLY · MONTHLY
QaMode
OFF · FAST · ACCURATE
FilterOperator
EQ · NE (NEQ) · CONTAINS · IN · NOT_IN (NIN) · GT · GTE · LT · LTE
IngestionStatus
StrEnum — member names are uppercase, but .value is lowercase (e.g. IngestionStatus.COMPLETED.value == "completed"). Members: PENDING ("pending") · IN_PROGRESS ("in_progress") · PROCESSING ("processing") · COMPLETED ("completed") · SUCCESS ("success") · FAILED ("failed") · WARNING ("warning").
SortDirection
ASC · DESC
Errors
The KB module raises a small set of typed errors. Catch them by name; all subclassKnowledgeBaseError, which in turn subclasses VectorshiftError.
KbNotFound— KB id/name doesn’t exist (or your key can’t see it).KbIngestionFailed— an ingestion task ended inFAILED.KbIngestionTimeout—add_*_and_waitexceeded itstimeout.KbIntegrationNotFound,KbIntegrationRevoked— integration resolution problems.
What’s next
Overview
Mental model and quick start.
RAG end-to-end guide
Wrap a KB as a tool on a conversational Agent.
RAG pipeline example
Compose a KB reader into a Pipeline.
