Pipes and scripts
kunji ask answers one question and exits, which makes it easy to use with other commands.
Pipe output into a model
Section titled “Pipe output into a model”npm test 2>&1 | kunji ask "Why are these tests failing?"git log --oneline -20 | kunji ask "Write release notes from these commits"cat config.yaml | kunji ask "Is anything wrong with this config?"Piped text is added under your question. Very large input is cut to the last 200,000 characters.
Plain output for scripts
Section titled “Plain output for scripts”When the output goes to a file or another command, kunji prints plain text with no colours or
boxes. Force it with --raw:
kunji ask --raw "Write a .gitignore for a Node project" > .gitignoregit commit -m "$(kunji @commit --raw)"Keys without prompts
Section titled “Keys without prompts”In CI or on servers, use environment variables instead of the keychain:
export OPENAI_API_KEY=sk-...kunji ask -m openai:gpt-4o-mini "Summarize this" < report.txtOr store a key from a script without typing it:
echo "$GROQ_API_KEY" | kunji keys add groq --key-stdin --model llama-3.3-70b-versatileAll variables: Environment variables.
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Something failed (bad key, provider error, missing file); the message says why |
| 2 | The command was used wrongly (missing argument, interactive command without a terminal) |
| 130 | Cancelled with Ctrl+C |
Interactive vs. non-interactive
Section titled “Interactive vs. non-interactive”kunji chat and the menu need a real terminal. In scripts, use kunji ask, kunji @name and
commands with flags (for example kunji keys remove groq --yes).