Use this file to discover all available pages before exploring further.
To run queries in TopK, your documents need to be uploaded. Once a document is uploaded,
TopK parses, chunks, and indexes its content to power Ask, Search, and Research.
# Upload all supported files in the directorytopk upload ./docs --dataset my-docs# Upload all supported files in the directory and subdirectories recursivelytopk upload ./docs -r --dataset my-docs# Upload all supported files in the directory by glob patterntopk upload "./docs/*" --dataset my-docs# Upload all supported files in the directory by glob pattern recursivelytopk upload "./docs/**/*" -r --dataset my-docs# Upload all PDFs in the directory by glob patterntopk upload "./docs/*.pdf" --dataset my-docs# Upload all PDFs in the directory by glob pattern recursivelytopk upload "./docs/**/*.pdf" --dataset my-docs# Upload a single filetopk upload ./report.pdf --dataset my-docs
Each document can be associated with its own metadata. You can attach additional
information about the document, such as title, author, date, or category.
After a document is uploaded, TopK returns a processing handle — a reference to the processing job.
The document is not ready for retrieval until it has been processed.Processing happens asynchronously in the background and may take a few seconds to a few minutes, depending on document size and complexity.
Your documents might not be ready for retrieval immediately after upload.
Alternatively, you can wait for the document to be processed using the processing handle:
CLI
Python SDK
JavaScript SDK
Pass --wait to block until processing is complete:
topk upload ./report.pdf --dataset my-docs --wait
import osfrom topk_sdk import Clientclient = Client( api_key=os.environ["TOPK_API_KEY"], region=os.environ["TOPK_REGION"],)client.dataset("my-docs").wait_for_handle(handle)# Document is now ready to be queried
You can customize polling behavior by passing a WaitConfig:
from topk_sdk import WaitConfigclient.dataset("my-docs").wait_for_handle( handle, WaitConfig(frequency_secs=10, timeout_secs=600),)
Parameter
Default
Description
frequency_secs
5
How often to poll for the handle status
timeout_secs
300
Maximum time to wait before timing out
import { Client } from "topk-js";const client = new Client({ apiKey: process.env.TOPK_API_KEY!, region: process.env.TOPK_REGION!,});await client.dataset("my-docs").waitForHandle(handle);// Document is now ready to be queried
You can customize polling behavior by passing a WaitConfig: