Skip to main content
Prerequisites

Installation

brew tap topk-io/topk
brew install topk

Configuration

Set your API key before running any commands:
export TOPK_API_KEY="your-api-key"
This can also be passed as a flag (--api-key) on any command.

Commands

topk ask

Get a grounded answer from your documents with source citations.
topk ask "What was the total net income of Bank of America in 2024?" -d my-docs
FlagDescription
--dataset / -dDataset to search (repeatable, at least one required)
--modeResponse mode: auto (default), summarize, or research
--field / -fMetadata field to include in results (repeatable)
--output-dirSave non-text references to a directory
Find relevant passages in documents for a query.
topk search "machine learning" -d my-docs
FlagDescription
--dataset / -dDataset(s) to search (repeatable, at least one required)
--top-k / -kNumber of results to return (default: 10)
--field / -fMetadata field to include in results (repeatable)
--output-dirSave non-text results to a directory

topk upload

Upload files into a dataset. Accepts a file path, directory, or glob pattern.
# Upload a single file
topk upload ./report.pdf --dataset my-docs

# Upload a directory (recursively)
topk upload ./docs -r --dataset my-docs

# Upload by glob pattern
topk upload "*.pdf" --dataset my-docs
Glob patterns must be quoted, otherwise the shell expands them before TopK sees them and the command will error. Use "*.pdf" not *.pdf.
FlagDescription
--dataset / -dDataset to upload files into
--recursive / -rRecurse into subdirectories — only valid when passing a directory
--concurrency / -cNumber of concurrent uploads, 1–64 (default: 32)
--waitWait for all files to uploaded and fully processed
--yes / -ySkip confirmation prompt
--dry-runPreview files that would be uploaded, without uploading

topk delete

Delete a document from a dataset.
topk delete --id doc-001 --dataset my-docs
FlagDescription
--idDocument ID
--dataset / -dDataset name
--yes / -ySkip confirmation prompt

topk dataset

Manage datasets.

list

List all datasets.
topk dataset list

get

Get details of a dataset.
topk dataset get my-docs

create

Create a new dataset. A region must be specified — this determines where your data is stored. See available regions.
topk dataset create my-docs --region aws-us-east-1-elastica

delete

Delete a dataset. Prompts for confirmation unless -y is passed.
topk dataset delete my-docs

# Skip confirmation
topk dataset delete my-docs -y

Global flags

These flags apply to all commands.

--api-key

TopK API key. Overrides the TOPK_API_KEY environment variable.

--output

Controls the output format. Accepts text (default) or json.
topk ask "What was the total net income of Bank of America in 2024?" -d my-docs --output json
topk ask "What was the total net income of Bank of America in 2024?" -d my-docs -o json