Skip to main content

Lifecycle

new

Create a new knowledge base. Parameters
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.
Returns
KnowledgeBase
The new KnowledgeBase instance.

fetch

Fetch by id or name. Exactly one is required.

list

Paginated list of the KBs visible to the API key’s org.

delete

Permanently delete the KB and every item in it.

Folders

create_folder

Folders organise items inside a KB. Pass a folder_id to any add_* method to ingest into a specific folder, or use move_items to reorganise afterwards.

Ingestion

Every ingestion call returns an IngestionTask. 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

Ingest one or more local files. Each entry can be a Path, raw bytes, or a file-like object.

add_files_and_wait

Blocking variant of 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

Ingest URLs, optionally with a recursive crawl and a rescrape schedule. See UrlConfig.

add_urls_and_wait

Blocking variant of add_urls.

add_folder / add_folder_and_wait

Walk a local directory and ingest every file. _and_wait blocks until done (default timeout=600).

add_tables / add_tables_and_wait

Ingest structured table rows. _and_wait variant blocks until done.

ingestion_status

Fetch the latest state of an ingestion task. Use after a bare add_* call to drive your own polling loop.

Querying

query

Retrieve relevant chunks for the query. Parameters
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.
Returns
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

Paginated listing of items, optionally filtered and sorted.

scroll

Stream through every item in pages — useful for large KBs where list_items would require manual cursor management.

get_item

move_items

Move items into a folder (created via create_folder).

delete_items

update_item_metadata

Attach or replace custom metadata on an item. Filter against this metadata at query time via 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

Return a lightweight reference to an item. The ref carries the KB id + item id; use it as a typed alternative to passing raw item ids around.

folder

Return a lightweight reference to a folder. Use the ref to scope subsequent operations (e.g. pass it as folder_id= to ingestion calls or list_items).

metadata_autogen

Accessor for the metadata-autogeneration subsystem — extract structured metadata (summaries, topics, custom fields) from items via LLM-driven pipelines. A KB can hold many autogen configs, each addressed by an autogen_id.

create_config

Register a new autogen 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

Full-overwrite update — every field omitted resets to its default server-side. Pre-fetch with get_config and merge if you only want to change one field.

delete_config

run

Trigger autogen against a subset of items. Returns an IngestionTask you can poll, or use the wait variant below.

run_and_wait

See the metadata-autogen example for the full lifecycle.

Integrations

integrations

List integrations attached to the KB. Integration setup happens in the platform.

resync_integration

Trigger a refresh against the upstream source.

set_rescrape_frequency

Set a periodic re-scrape on a URL item or an integration. Pass exactly one of 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"
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"
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

QaMode
default:"OFF"
See QaMode.
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
Any
required

SortClause

str
required
SortDirection
default:"ASC"

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
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 subclass KnowledgeBaseError, which in turn subclasses VectorshiftError.
  • KbNotFound — KB id/name doesn’t exist (or your key can’t see it).
  • KbIngestionFailed — an ingestion task ended in FAILED.
  • KbIngestionTimeoutadd_*_and_wait exceeded its timeout.
  • KbIntegrationNotFound, KbIntegrationRevoked — integration resolution problems.
See the top-level Errors page for the broader hierarchy.

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.