Ga naar inhoud

CLI overview

Deze inhoud is nog niet vertaald.

The Khadim CLI is the stable entry point for the Khadim platform. It connects to 19+ LLM providers, gives the agent tool access, and supports both an interactive terminal UI and headless batch runs.

Install globally via npm:

Terminal window
npm install -g @unravelai/khadim

Or with bun:

Terminal window
bun install -g @unravelai/khadim

The package auto-detects your platform (Linux x64/arm64, macOS x64/arm64) and downloads the correct native binary. Re-run the install command to upgrade.

See Installation for release downloads, installer script usage, and source builds.

Launch the TUI by running khadim with no arguments:

Terminal window
khadim

The interactive mode provides:

  • Multi-line chat input with history navigation
  • Live streaming of agent responses and tool execution
  • Slash commands for session management, settings, and more (type / to preview)
  • Settings panel (F2) for provider, model, theme, and API key configuration
  • OAuth login flow for Copilot and Codex
  • Session persistence — save, load, rename, and switch between sessions
KeyAction
EnterSend message
Shift+EnterInsert newline
TabAccept command suggestion
EscapeAbort agent or close overlay
Ctrl+CQuit
Ctrl+LClear session
Ctrl+KClear input
Ctrl+OToggle tool output
F2Open settings
PageUp / PageDownScroll transcript

See Commands for the full slash command and shortcut reference.

Run a single prompt non-interactively by passing --prompt:

Terminal window
khadim --prompt "explain this codebase"

Or use the exec subcommand (supports piped stdin):

Terminal window
echo "summarize the README" | khadim exec
khadim exec "write a function that checks if a number is prime" --json

The --json flag switches to machine-readable JSON-line output. Each line is a structured event:

{"event_type":"text_delta","content":"Here's the function..."}
{"event_type":"step_start","content":"Running read_file","metadata":{"tool":"read_file"}}
{"event_type":"step_complete","content":"file contents","metadata":{"tool":"read_file"}}
{"event_type":"done"}

This is the same event stream the Khadim SDK consumes. Anything you can read from --json you can wire into your own app.

FlagDescription
--cwd PATHSet working directory
--prompt TEXTRun in batch mode (- reads stdin)
--provider NAMESet AI provider
--model IDSet AI model
--session NAMELoad a saved session
--system-prompt TEXTOverride the system prompt
--harness NAMESelect coding, rpa, assistant, or a custom harness
--jsonOutput machine-readable JSON events
--providers [format]List available providers (JSON or plain)
--models PROVIDERList models for a provider
--verboseEnable verbose logging

API keys are read from standard environment variables:

ProviderEnv Var
OpenAIOPENAI_API_KEY
AnthropicANTHROPIC_API_KEY
GeminiGEMINI_API_KEY
GroqGROQ_API_KEY
xAIXAI_API_KEY
OpenRouterOPENROUTER_API_KEY
MistralMISTRAL_API_KEY
CopilotGITHUB_TOKEN or GH_TOKEN
CodexOPENAI_CODEX_API_KEY or OPENAI_API_KEY
CerebrasCEREBRAS_API_KEY
HuggingFaceHF_TOKEN
NVIDIANVIDIA_API_KEY
KimiKIMI_API_KEY
MiniMaxMINIMAX_API_KEY
Z.AIZAI_API_KEY
OpenCodeOPENCODE_API_KEY

The universal fallback KHADIM_API_KEY works across providers that can use a single generic key.

Set the default provider and model:

Terminal window
export KHADIM_PROVIDER=anthropic
export KHADIM_MODEL=claude-sonnet-4

The TUI settings panel (F2) saves provider, model, API keys, and theme preferences to ~/.config/khadim/settings.json.

The CLI supports 19+ providers across major AI vendors. Use khadim --providers to list all available providers, and khadim --models <provider> to see models.

GitHub Copilot and OpenAI Codex use OAuth device-code flow instead of API keys. Run khadim interactively and use /login to authenticate, or press F2 to open settings and select one of these providers.

Khadim can run multiple harnesses from the same CLI:

Terminal window
khadim --harness coding
khadim rpa exec "inspect the current screen"
khadim assistant

The coding harness is the mature path. The RPA and assistant harnesses are active development surfaces for desktop automation and general agent runs.

Docker support is under active development. A khadim-cli image will let you run the agent in containers without installing a native binary on the host. See Docker Agent Runtime for the planned integration pattern.