QueryMT Command-Line Interface (qmt)
The QueryMT Command-Line Interface (qmt) is a powerful and versatile tool for interacting with Large Language Models directly from your terminal. It leverages the full power of the QueryMT library, providing a unified interface for chat, text embedding, tool usage, and configuration management across various LLM providers.
Key Features
- Interactive Chat: A REPL-style interface for conversational AI.
- Piped & Single-Shot Commands: Seamlessly integrate
qmtinto your shell scripts and workflows. - Unified Provider Management: Interact with any provider configured in your
providers.toml, from OpenAI and Anthropic to local models via Ollama. - Text Embeddings: Generate vector embeddings for text, with support for multiple documents and custom dimensions.
- Secure Credential Storage: Manage API keys and other secrets securely.
- Tool & Function Calling: Connect LLMs to external tools, including those exposed via the Model Context Protocol (MCP).
Configuration
qmt relies on two primary configuration sources, typically located in ~/.qmt/:
-
Provider Configuration (
~/.qmt/providers.toml): This file defines all the available LLM provider plugins. You can specify the path to local Wasm or native plugins, or reference them from an OCI registry. This can be overridden with the--provider-configflag.- For more details, see Plugin Configuration.
-
Secret Storage (
~/.qmt/secrets.json): This file stores sensitive information like API keys and the default provider setting. It is automatically created and managed by theqmtCLI and should not be edited manually.
Core Commands
Chatting with LLMs
qmt offers several ways to chat with your configured models.
Interactive Mode (REPL)
For a conversational experience, simply run qmt without any prompt.
Single-Shot Prompt
Pass a prompt directly as an argument for a quick question and answer.
Piped Input
Use standard shell pipes to provide context to the LLM. This is ideal for summarizing files, analyzing logs, or processing text and image content.
Generating Embeddings
The embed subcommand generates vector embeddings. It can read from an argument or from stdin, and it outputs the results as a JSON array.
You can also embed multiple documents at once by specifying a separator.
Managing Configuration & Secrets
qmt includes commands to manage your settings without manually editing files.
Setting the Default Provider
Set your most-used provider and model combination as the default.
OAuth Authentication
Some providers support OAuth authentication for enhanced security and automatic token management. The qmt CLI can handle the OAuth flow for you, including opening your browser and storing credentials securely.
Storing API Keys
Securely store API keys and other secrets. The key should match the api_key_name defined by the provider plugin (e.g., OPENAI_API_KEY, ANTHROPIC_API_KEY).
Discovering Providers & Models
List the providers and models that qmt has loaded from your configuration.
Examples & Advanced Usage
Combine flags to customize LLM interactions.
Specifying a Provider and Model
Use the --provider (-p) and --model flags, or combine them in the format provider:model.
Using a Local Model via a Proxy/Local Server
Override the --base-url to point to a local service like Ollama.
Setting a System Prompt
Guide the model's behavior with a system prompt using --system (-s).
Controlling Generation Parameters
Adjust temperature, max tokens, and other parameters for more creative or controlled output.
Passing Custom Provider-Specific Options
Use the --options (-o) flag to pass arbitrary key-value pairs that a specific plugin might support. Values are parsed as JSON if possible, otherwise as strings.
Embedding with Specific Dimensions
Some embedding models support custom dimensions.
Using Tools via MCP
Create a file named mcp-config.toml. This file tells QueryMT how to launch and communicate with the tool server.
Supported transport protocols:
- stdio: Spawns an MCP server as a child process (requires command, optional args and envs)
- http: Connects to an MCP server over HTTP using Streamable HTTP transport (requires url, optional token)
When you ask a question that requires a tool, the LLM will request to use it, and qmt will handle the communication.
Command-Line Reference
Global Options
These options can be used with the main chat command.
| Flag | Alias | Description |
|---|---|---|
--provider <NAME> |
-p |
The name of the provider to use (e.g., openai, anthropic:claude-3). |
--model <NAME> |
The specific model to use (e.g., gpt-4-turbo). |
|
--system <PROMPT> |
-s |
The system prompt to set the context for the conversation. |
--api-key <KEY> |
Directly provide an API key, overriding stored secrets or environment vars. | |
--base-url <URL> |
The base URL for the LLM API, for use with proxies or local models. | |
--temperature <FLOAT> |
Controls randomness (e.g., 0.7). |
|
--top-p <FLOAT> |
Nucleus sampling parameter. | |
--top-k <INT> |
Top-k sampling parameter. | |
--max-tokens <INT> |
The maximum number of tokens to generate in the response. | |
--mcp-config <PATH> |
Path to a TOML configuration file for MCP tool servers. | |
--provider-config <PATH> |
Path to the provider plugins configuration file (e.g., plugins.toml). |
|
--options <KEY=VALUE> |
-o |
Set a provider-specific parameter. Can be used multiple times. |
Subcommands
| Command | Description |
|---|---|
qmt auth login <PROVIDER> |
Login to a provider using OAuth authentication. |
--mode <MODE> |
OAuth mode (provider-specific, e.g., "max" or "console" for Anthropic). Defaults to "max". |
qmt auth logout <PROVIDER> |
Logout from an OAuth provider (removes stored tokens). |
qmt auth status [PROVIDER] |
Check OAuth authentication status for all or a specific provider. |
--no-refresh |
Skip automatic token refresh (show raw stored status). |
qmt secrets set <KEY> <VALUE> |
Set a secret key-value pair in the secure store. |
qmt secrets get <KEY> |
Get a secret value by its key. |
qmt secrets delete <KEY> |
Delete a secret by its key. |
qmt providers |
List all available provider plugins loaded from the configuration. |
qmt models |
List all available models for each provider. |
qmt default [PROVIDER] |
Get or set the default provider (e.g., qmt default openai:gpt-4). |
qmt embed [TEXT] |
Generate embeddings for the given text or for text from stdin. |
--separator <STR> |
Document separator for embedding multiple texts from a single stream. |
--dimensions <INT> |
Request a specific number of dimensions for the embedding vector. |
--encoding-format <FMT> |
Specify the embedding encoding format (e.g., float, base64). |
--provider <NAME> |
Override the provider for this embedding task. |
--model <NAME> |
Override the model for this embedding task. |
qmt update |
Update provider plugins. |
qmt completion <SHELL> |
Generate shell completions for the specified shell. |