askoai
v0.1.0
Published
Prompt OpenAI (and OpenAI-compatible APIs) straight from your terminal, with profiles, JSON pretty-printing and clipboard copy.
Maintainers
Readme
askoai
Prompt OpenAI — or any OpenAI-compatible API — straight from your terminal, the way you'd chat on the web. Text only, one question per call, answer printed and copied to your clipboard.
$ askoai What is the capital of France?
Paris.
(copied to clipboard)Install
npm install -g askoaiRequires Node.js ≥ 22.12. askoai is installed.
Quick start
askoai profile new # asks API_KEY, SYSTEM_PROMPT, BASE_URL, then "more? (y/N)"
askoai Explain monads in one sentenceThe first profile you create becomes the default. Every later call uses the default profile unless you pass -p <name>.
Prompting
askoai What is the capital of France?
askoai 'Return {"city": "...", "country": "..."} for Paris' # JSON answers are pretty-printed
git diff | askoai write a commit message # stdin is appended to the prompt
askoai -p work --no-copy "Summarise this" # pick a profile, skip the clipboard
askoai -m gpt-4.1 -s "Answer like a pirate" ahoy # per-call model / system prompt
askoai --stream tell me a story # stream tokens (no JSON formatting)
askoai --raw 'give me json' # never pretty-print
askoai ask profile of Ada Lovelace # explicit form, see Notes| Flag | Meaning |
|------|---------|
| -p, --profile <name> | Use this profile instead of the default |
| -m, --model <model> | Override the model for this call |
| -s, --system <prompt> | Override the system prompt for this call |
| -t, --temperature <n> | Override the temperature (0–2) |
| --copy / --no-copy | Force clipboard copy on/off |
| --stream / --no-stream | Stream the answer / wait for it |
| --raw | Print exactly what the model returned |
When the answer is a JSON object or array (optionally inside a ```json fence) it is re-indented and colourised; the clipboard gets the plain, indented JSON.
Profiles
A profile bundles an API key, system prompt, base URL and a handful of model settings.
askoai profile # show the default profile
askoai profile ls # list profiles (* marks the default)
askoai profile new [name] # create interactively (aliases: mk, create, add)
askoai profile show <name>
askoai profile default <name> # set the default
askoai profile set --default <name> # same thing
askoai profile configure <name> # edit every field interactively (aliases: config, edit)
askoai profile configure --system-prompt 'You are terse.' # edit the default profile via flags
askoai profile configure work --model gpt-4.1 --temperature 0.2 --no-copy
askoai profile rm <name> # aliases: remove, delete
askoai profile path # where the config livesprofile can be shortened to p (askoai p ls).
Fields
| Field | Flag | Notes |
|-------|------|-------|
| API_KEY | --api-key | Empty → uses $OPENAI_API_KEY at run time |
| SYSTEM_PROMPT | --system-prompt | Optional |
| BASE_URL | --base-url | Empty → https://api.openai.com/v1 (or $OPENAI_BASE_URL). Point it at Ollama, OpenRouter, Azure, … |
| MODEL | --model | Default gpt-4o-mini |
| TEMPERATURE | --temperature | 0–2 |
| MAX_TOKENS | --max-tokens | Integer |
| TOP_P | --top-p | 0–1 |
| COPY_TO_CLIPBOARD | --copy / --no-copy | Default yes |
| STREAM | --stream / --no-stream | Default no |
The last six are the "more? (y/N)" questions in profile new. Any flag you pass to profile new skips that question; profile new <name> -y --api-key … creates a profile with no questions at all (handy for scripts). Passing an empty string (--system-prompt '') clears a field.
Where it's stored
~/.config/askoai/config.json (respects $XDG_CONFIG_HOME; %APPDATA%\askoai on Windows), written with mode 0600. Set ASKOAI_CONFIG_DIR to use another directory.
Notes
- An unquoted prompt that starts with a command name (
profile,p,ask) is treated as that command. Quote it (askoai 'profile of Ada Lovelace') or use the explicit form:askoai ask profile of Ada Lovelace. - Clipboard copy uses clipboardy; on Linux it wants
xsel/xclip/wl-copybut ships a fallback. If copying fails you'll see a dim notice on stderr and the answer is still printed. - Only OpenAI's Chat Completions endpoint is used, so any server that implements it works via
BASE_URL.
Development
npm install
npm run dev -- What is 2+2 # run from source
npm run check # typecheck + lint + tests
npm run build # emit dist/
node scripts/mock-server.mjs # OpenAI-compatible echo server on :8765 for manual testing
ASKOAI_CONFIG_DIR=/tmp/askoai askoai profile new dev -y --api-key x --base-url http://127.0.0.1:8765/v1License
MIT
