Instructions
The user wants to try TopK. Follow the steps below in order. You run every command yourself; the user only signs up or logs in in the browser during step 2. Rules:- Use the
topkCLI only. Don’t write Python or JavaScript, and don’t ask the user for an API key:topk loginis enough. - Pass
--region <REGION>to everytopk sqlcommand. Environment variables youexportmay not survive between your commands. - Use
-o jsonwhen you need to read IDs from a command’s output. It prints one JSON object per line, not an array. - If
TOPK_API_KEYis set in the environment, runtopkcommands with it unset (env -u TOPK_API_KEY topk …): an API key silently overrides the login and the selected project. - If
TOPK_PROJECT_IDis set in the environment, it overrides the project you select in step 3. Runtopkcommands with it unset (env -u TOPK_PROJECT_ID topk …), or pass--project-id <PROJECT_ID>explicitly. - Never run a
topkcommand that waits for keyboard input: always pass the IDs and flags shown below.
1. Install the CLI
Check whether the CLI is installed:2. Log in
Tell the user first: “A browser window will open. Sign up or log in to TopK there, then come back here.” Then run:✓ Logged in to stderr. If the browser doesn’t open, run topk login --no-browser and give the user the URL it prints. The browser must be on the same machine as the CLI.
3. Select a project
project_id, name, and selected fields.
-
A project has
"selected": true: it’s already selected. Go to step 4. -
No projects: create one, then select it with the
project_idfrom the output: -
One project: select it with
topk project select <PROJECT_ID>. -
Several projects: ask the user which one to use, then select it with its
project_id.
topk project select without one opens an interactive picker.
4. Pick a region
aws-us-east-1-elastica if it’s listed, otherwise the first region listed. Don’t ask the user. Use the same region for every command below.
5. Create a collection
Create amovies collection with a semantic index on the plot, so it can be searched by meaning:
6. Add documents
INSERT is an upsert: running it again replaces documents with the same _id.
7. Search
Run a semantic search. It matches by meaning, not by keywords:8. Wrap up
Show the user the search results and summarize what you set up: the project, the region, and themovies collection. Then suggest next steps:
- Go bigger: search 50,000 Wikipedia articles, loaded straight from Hugging Face. Mention that it takes about 3 minutes and uses some of the account’s free credit, mostly to embed the article text. If the user says yes, follow Go bigger below.
- Search their own data:
topk importloads files (CSV, JSON, Parquet), databases, and object storage. Runtopk import --help. - Install the TopK skill so coding agents use the API correctly:
npx skills add topk-io/topk --skill topk. - Read the TopK SQL reference and the semantic search guide.
Go bigger
Follow this when the user wants a bigger demo. It loads 50,000 English Wikipedia articles from Hugging Face into a new collection, with no download step and no embedding pipeline, then answers questions over them. Steps 1–4 above must be done first.1. Write the import spec
The spec says where the data comes from and which fields to index. Createwikipedia.toml in the current directory:
title gets a keyword index for exact word matches; text, the first 4,000 characters of each article, gets a semantic index for search by meaning.
2. Import
Tell the user it takes about 3 minutes, then run:wikipedia collection, and shows progress. When it finishes, tell the user how many articles were imported and how long it took. If the import stops partway, run the command the CLI prints after to continue:, adding --yes so it doesn’t wait for confirmation. It resumes the same run with --resume <RUN>, using the run id from the # run <RUN> line printed when the import started.
3. Ask it questions
Search by meaning: results match what the question is about, not just its exact words:meaning and keywords columns, and point out how each article’s two scores combine into its rank. BM25 scores run several times larger than semantic scores, so the 0.1 weight puts them on a similar scale; changing the weights changes the ranking.
Show the results as tables, then invite the user to ask their own questions and run them the same way.
If the first query returns few or no results, the semantic index may still be catching up: wait 30 seconds and run it again.
Troubleshooting
Anything else: show the user the exact command and error message, and point them to support.