Skip to main content
Command-line interface for TopK.

Installation

Quick start

topk import discovers a schema, shows the plan, and imports on confirmation — see import.

Authentication

To authenticate, run:

Commands

login

Log in with TopK CLI:
If the CLI cannot open your browser automatically, or you prefer to open it manually, use topk login --no-browser to print the login URL.

logout

Remove the saved session:

project

list

List projects in the current organization.
topk project list marks the currently selected project with *.

select

Select a default project.

clear

Clear the selected project:

current

Show the currently selected project.

get

Get a project by ID.

create

Create a project.

delete

Delete a project by ID.

region

list

List available regions.

sql

Create and manage collections, read and write documents, and run keyword, vector, and semantic searches with TopK SQL.

Run a query

Log in and find your project ID, then run SQL against a collection. This example searches a title field with a semantic index:
Alternatively, pass --api-key or set TOPK_API_KEY instead of using your login and --project-id.
See the TopK SQL reference for complete documentation.

Run SQL from a file or stdin

Inspect tables

psql-style commands list and describe tables:

Output

Results print as one table per statement by default, with row counts on stderr. Use -o json to stream one JSON object per row as it arrives, for example topk sql … -o json | jq. Pipe long output to a pager yourself, for example | less.

import

Bulk import into TopK collections. Every run prints the plan as a TOML spec and asks before writing; collections are created right after.

Authenticate

Log in, then provide --project-id and --region when importing:
Set TOPK_PROJECT_ID and TOPK_REGION to omit the corresponding flags. Explicit flags override environment variables.
Use topk project list to find your project ID and topk region list to list regions. Access tokens are cached and renewed automatically. Run topk project select once to omit --project-id from later commands. An API key (--api-key or TOPK_API_KEY) takes precedence over the selected project. Alternatively, pass --api-key or set TOPK_API_KEY instead of logging in and providing --project-id. Get an API key in the TopK console.
--project-id or TOPK_PROJECT_ID cannot be combined with an API key (--api-key or TOPK_API_KEY). Unset TOPK_API_KEY to use your login.

Import a database

Objects are exact names, globs, or <object>=<collection> renames.

Import files

A single file names its collection.

Copy a TopK collection

Schema and indexes copy as-is; the copy is additive.

Split rows across partitions

Each row goes to the partition named by that column, so one source stream writes into as many partitions as the column has values.
The column only has to exist in the source. It does not have to be an imported field.

Preview and edit the plan

Keep credentials on the command line or in the environment, never in the spec — the spec is meant to go in git.

Resume a stopped run

Stop a run — ^C, a lost connection — and pick it up where it left off:
Resume skips finished collections and continues unfinished ones from their source checkpoints, after all preceding partition writes succeeded. Limits include rows consumed before the checkpoint, including skipped rows. Without --resume, a re-run re-imports everything — upserts are idempotent.

Sources

Spec

One TOML table per collection — from, id, filter/partition/limit as the flags (partition names a column), and a fields whitelist (only declared fields import):
Discovery takes the source’s types; declaring a different type converts. Embeddings that arrive as float lists, text ("[1,2,3]") or packed bytes become vectors by declaring f32_vector and dim (f32_matrix and cols for multi-vectors); a sparse vector reads numeric keys or parallel indices/values lists; epoch numbers or date text become timestamp. Conversions are exact or the document fails; a narrower declaration (truncate included) is how loss is accepted.

Failures and limits

A document fails when a value does not convert exactly, its id is missing or empty, or it is over 200 KB. A failure stops the run, ready to --resume; --continue-on-error skips them instead.
  • there is no schema migration: an existing collection whose schema differs is rejected
  • an upsert replaces the whole document, so a spec that omits an existing field clears it

Global flags

These flags are accepted by every command:

--output

Options:
  • text (default)
  • json

Updating the CLI

To update CLI to the latest version, run: