Simple command-line router for large language model prompts. ask lets you:
- Pipe shell output or inline prompts into one or more configured models.
- Share model definitions, aliases, and grouped fan-out calls through a single YAML config.
- Layer pre-prompts, temperature/token overrides, and metadata that cascade across aliases and groups.
- Log every run to structured JSONL files for later inspection.
The first release targets OpenRouter via the OpenAI SDK.
Prerequisites: Python 3.10+, an OpenRouter account, and an API key.
-
Clone & install
uv pip install -e '.[dev]' -
Configure environment (uses rasengans)
cp config/.env.example .env # edit .env and add your OPENROUTER_API_KEYThe CLI automatically loads
.envon startup (viapython-dotenv), so you normally do not need tosourceit. -
Review configuration –
config/ask.yamldefines tools, aliases, and groups. Example bundle:version: 1 tools: default: prov: openrouter endpoint: openrouter model: openai/gpt-4.1-mini pp: file:preprompts/default.txt temp: 0.2 tok: 400 critique: tool: default pp: "Provide a concise critique focusing on weak points." review: pp: file:preprompts/review-group.txt members: - tool: default - tool: critique id: critique pp: "Highlight risks and follow-up questions." defaults: default_tool: default separator: "\n\n" verbose: false
-
Run the CLI
ask "Summarize today’s meeting notes." # uses the configured default tool cat docs/ask.md | ask "Assess this document." # default tool with piped input ask default "Summarize today’s meeting notes." # explicit alias still supported cat docs/ask.md | ask review "Assess this document." # group alias example ask review -v "Give me a project status snapshot." # verbose flag shows log path
Tip: On first run outside the repo, the CLI seeds
~/.config/ask/config.yamlfrom its bundled template; adjust that file to match your models.
$ ask -v "Summarize the release notes for me."
[default] tool=default provider=openrouter model=openai/gpt-4.1-mini
Here’s a concise summary of the release notes, covering the major features and bug fixes in plain language.$ printf "Fix auth bug\nAudit logging incomplete" | ask -v "Draft a status update"
[default] tool=default provider=openrouter model=openai/gpt-4.1-mini
Status update:
- Fixed the lingering authentication bug affecting SSO.
- Logging gaps remain; plan remediation this week.$ cat docs/ask.md | ask -v review "Provide a critique and risks."
[default] tool=default provider=openrouter model=openai/gpt-4.1-mini
Initial analysis of the document, highlighting structure and themes.
[critique] tool=critique provider=openrouter model=openai/gpt-4.1-mini
Key risks include missing rate-limit mitigation and sparse validation coverage.
[log] wrote metadata to logs/run-20251004T120000Z.jsonl- Inspect logs – each invocation writes metadata to
logs/run-YYYYMMDDTHHMMSSZ.jsonl. Usetailorjqto audit model usage and latency.
- All entries live under
tools:and can represent:- Model – define
prov,model, optionalendpoint, and prompt/parameter defaults. - Alias – point
tool:at another tool, optionally overridingpp,temp,tok, orparams. - Group – declare
members:to fan out to multiple tools. Reused members auto-number (default,default-1, …) unless you supply anid.
- Model – define
- Parameters cascade: group → alias/member → base model.
- Shorthand keys:
prov,pp,temp,tok; long-form names also work. defaults.default_toolselects the model/alias/group that runs when no target is supplied (falls back to a tool nameddefault).versionpins the config format. The CLI currently supportsversion: 1.- Run with
-v/--verbose(or setdefaults.verbose: true) to surface the invoked tool, provider, and actual model slug above each response. - See
docs/ask.mdfor the complete schema and additional examples.
| Variable | Purpose |
|---|---|
OPENROUTER_API_KEY |
Required OpenRouter API key. |
ASK_HTTP_REFERER |
Referer header sent with each request (defaults to https://ask.cli.local). |
ASK_APP_TITLE |
X-Title header identifying the app (defaults to ask-cli). |
Full guidance lives in docs/configuration/env.md.
- Install in editable mode with
uv pip install -e '.[dev]'(thedevextra pulls in pytest). - Source code lives under
src/ask/; key modules:config.py– YAML parsing and tool resolution.runtime.py– async execution, request assembly, logging.providers/openrouter.py– async OpenRouter wrapper using the OpenAI SDK.cli.py– argument parsing, stdin handling, verbosity control.
- Cached vendor docs live in
sdk-docs/; project history and design notes live inhistory.mdanddocs/. - Respect the repository guideline prohibiting edits to
.env(or other secret files) without explicit user approval (seeAGENTS.md).
docs/ask.md– CLI overview, configuration schema, execution scenarios.docs/configuration/env.md– Environment variable reference and.envusage.sdk-docs/openrouter.md– Cached OpenRouter API summary.docs/index.md– Rolling index + change log for project documentation.
- 400 Invalid model ID – verify the
model:slug againstcurl https://openrouter.ai/api/v1/modelsand confirm your API key has access. OPENROUTER_API_KEYmissing – check.env, ensure it is loaded (auto viapython-dotenv).- Rate limits / 429 – review the log JSONL for error details; OpenRouter may require backoff.
- Run with
--verboseor setdefaults.verbose: trueto surface log-file paths and additional diagnostics.
No license has been defined yet. Confirm project ownership before redistribution.