Skip to main content

Retrieval and chat commands

The kscli search, chat, and retrieve commands — consume Knowledge Bases through a retrieval service

These three commands consume Knowledge Bases: search runs semantic retrieval, chat holds a multi-turn conversation, and retrieve queries a single Knowledge Base directly but is deprecated. Shared conventions for authentication, workspace ID, global flags, and output formats are covered in the CLI overview. The examples below assume the workspace ID is already set in the config file; retrieve does not use a workspace ID.

Choosing a command

CommandInputWhen to use
search--agent-idSemantic retrieval. Scope and strategy come from the service config, supporting multiple Knowledge Bases, routing, and reranking
chat--agent-idMulti-turn Q&A. Streams the model-generated answer
retrieve--index-idDeprecated. Queries one Knowledge Base directly, limited in capability and no longer developed
Run semantic retrieval against a Knowledge Base.
kscli search --query <text> --agent-id <id> [flags]
Parameters
ParameterTypeRequiredDescription
--query <text>stringYesQuery text, cannot be empty
--agent-id <id>stringYesRetrieval service ID, found with service list --scene search
--agent-version <version>stringNoService version, beta (draft) or a published number. Defaults to the latest published version
--image <url>arrayNoImage URL, repeatable, for multimodal retrieval
Output
[1] (score: 0.9512)
retrieved text content…

[2] (score: 0.8734)
another passage…
With no matches the command prints No results found.. json mode returns the full result including each hit's score and metadata. Notes
  • Retrieval scope and strategy (multi-Knowledge-Base weighting, routing, reranking, and so on) come from the service configuration behind --agent-id, so only --query and --agent-id are needed — retrieval parameters do not have to be repeated on the command line.
  • --agent-version beta calls the draft configuration, which is how you validate tuning before publishing.
Examples
# Basic retrieval
kscli search --query "What is RAG" --agent-id aid-xxx

# Multimodal retrieval
kscli search --query "describe this image" --agent-id aid-xxx --image https://example.com/img.jpg

# Validate the draft configuration
kscli search --query "test" --agent-id aid-xxx --agent-version beta

kscli chat

Hold a RAG conversation with a Knowledge Base, with streaming output.
kscli chat --message <text> --agent-id <id> [flags]
Parameters
ParameterTypeRequiredDescription
--message <text>arrayYesMessage text, repeatable. Supports a role:content prefix to set the role (such as user:hello), defaulting to user, and follows the OpenAI message format
--agent-id <id>stringYesQ&A service ID, found with service list --scene chat
--agent-version <version>stringNoService version, beta (draft) or a published number. Defaults to the latest published version
--image <url>arrayNoImage URL, repeatable, attached to the last user message
At least one of --message or --image is required — an image-only query can pass --image alone. --image cannot be combined with a structured message that already contains image content. Output In an interactive terminal the answer streams in real time, and the progress label follows the server-side stage:
🔍 Retrieving...
✍️ Generating...
the generated answer streams in character by character…
When output is redirected or piped, the full text is buffered and printed at once. json mode returns:
{
  "answer": "the complete answer text…",
  "request_id": "xxx"
}
quiet mode prints the complete answer text. Notes
  • Pass conversation history by repeating --message with role: prefixes.
  • --verbose writes detailed streaming events to stderr, which helps diagnose interruptions or anomalies.
  • On Chat API error, check that --agent-id exists, the service is published, and the API Key is valid. The error code and message are returned verbatim by the server.
Examples
# Single turn
kscli chat --message "What is RAG" --agent-id aid-xxx

# Multi-turn with history
kscli chat \
  --message "user:What is RAG" \
  --message "assistant:RAG is retrieval-augmented generation…" \
  --message "How does it work" \
  --agent-id aid-xxx

# Multimodal conversation
kscli chat \
  --message "Describe these images" \
  --image https://example.com/a.png \
  --image https://example.com/b.png \
  --agent-id aid-xxx

# Validate the draft configuration
kscli chat --message "test" --agent-id aid-xxx --agent-version beta

kscli retrieve

Query a single Knowledge Base directly.
This command is deprecated and prints a deprecation warning when used. Use search instead: it drives retrieval strategy through --agent-id and supports multiple Knowledge Bases, routing, and reranking, while retrieve operates on a single Knowledge Base ID, is limited in capability, and is no longer developed.
kscli retrieve --index-id <id> --query <text> [flags]
Parameters
ParameterTypeRequiredDescription
--index-id <id>stringYesKnowledge Base ID
--query <text>stringYesQuery text
--dense-similarity-top-k <n>numberNoSemantic retrieval recall count
--sparse-similarity-top-k <n>numberNoKeyword retrieval recall count
--rerankswitchNoEnable reranking
--rerank-top-n <n>numberNoNumber of results after reranking
--rerank-model <name>stringNoRerank model name, such as qwen3-rerank-hybrid
--rerank-mode <mode>stringNoRerank mode, qa, similar, or custom
--rerank-instruct <text>stringNoCustom rerank instruction, used with --rerank-mode custom
--top-k <n>numberNoNumber of results. Deprecated — use --rerank-top-n
Output Same format as search. With no matches the command prints No results found.. Notes
  • This command does not need a workspace ID; it queries --index-id directly without requiring a retrieval service.
  • --top-k is deprecated and prints a warning on stderr when passed — use --rerank-top-n.
Examples
# Basic retrieval
kscli retrieve --index-id idx-xxx --query "how to configure the chunking strategy"

# With reranking
kscli retrieve --index-id idx-xxx --query "RAG retrieval" \
  --rerank --rerank-model qwen3-rerank-hybrid