askp-cli


Nameaskp-cli JSON
Version 1.0.6 PyPI version JSON
download
home_pagehttps://github.com/liensimen/askp
SummaryA command-line interface for Perplexity AI
upload_time2025-08-14 22:08:21
maintainerNone
docs_urlNone
authorLienS
requires_python>=3.8
licenseNone
keywords perplexity ai cli command-line chat assistant
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # askp - Perplexity CLI (Python)

A tiny command-line tool to query Perplexity’s API with optional search filters and structured/text output.

## Modes

askp supports two main modes:

- **Interactive mode:**  
  Start a conversational REPL for multi-turn chat and advanced features. Just run `askp` with no arguments.

- **Single-shot mode:**  
  Ask a single question and get a response immediately. Run `askp "your question"` with optional flags for output format, filters, and model selection.
  Defaults to raw json to work with other model as a researcher.

If you only want to run it, install to PATH and simply run `askp "your question"` after setting your API key.

---

## Features

- **Interactive chat mode** (REPL) with slash commands for advanced control
- **Single-shot mode** for quick answers or scripting
- **Simple one-file CLI** in Python, no build step required
- **Search filters**:
  - Academic-only search: `-a/--academic`
  - Restrict to a domain: `-d/--domain`
  - Recency filter: `--recency {day|week|month}`
- **Output modes**:
  - Raw JSON (default, great for piping to `jq`)
  - Text-only output: `-t/--text`
  - Structured JSON with `--json-schema`
  - Optional `--usage` and `--citations` summaries
- **Model selection** with validation: `-m/--model {sonar, sonar-pro, sonar-reasoning, sonar-reasoning-pro}`
- **Async API support** for long-running jobs (`--async`, `/async`)
- **File and directory attachment** in chat (`/attach`, `/ocr`), including OCR for images
- **Slash commands** for model switching, system prompts, filters, pruning, and more
- **Piping and scripting**: designed for shell integration and automation
- **Verbose logging** with `-v/--verbose` for debugging
- **Cross-platform**: works on macOS, Linux, and Windows
- **Easy install**: venv, pipx, or single-line user install
- **API key fallback**: supports both `PPLX_API_KEY` and `PERPLEXITY_API_KEY`
- **Extensible**: supports additional Python packages for enhanced features (e.g., BeautifulSoup for HTML, pytesseract for OCR)

## Requirements

- Python 3.8+
- `requests` Python package

Install dependencies one of two ways:

- With a venv and requirements.txt:

  ```bash
  python -m venv .venv
  source .venv/bin/activate
  pip install -r requirements.txt
  ```

## Install

### Recommended: Install from PyPI

```bash
pip install askp-cli
```

After installation, you can use the `askp` command directly:

```bash
askp --help
```

### Alternative: Install with pipx (isolated environment)

```bash
pipx install askp-cli
```

### Development: Install from source

If you want to contribute or use the latest development version:

```bash
git clone https://github.com/LienSimen/perplexity-cli.git
cd perplexity-cli
pip install -e .
```

Or install directly from Git with pipx:

```bash
pipx install git+https://github.com/LienSimen/perplexity-cli.git
```


## Get an API key

- You need a Perplexity API key. See Perplexity’s docs/pricing for obtaining an API key.

## Configure your API key (PPLX_API_KEY with fallback)

askp.py checks these environment variables in order:

1) `PPLX_API_KEY` (preferred)
2) `PERPLEXITY_API_KEY` (fallback)

Below are platform-specific instructions to set environment variables.

### macOS and Linux (bash/zsh)

- Current shell only:

  ```bash
  export PPLX_API_KEY="your_api_key_here"
  ```

- Persist for future shells (append to your shell profile):
  - For bash: `echo 'export PPLX_API_KEY="your_api_key_here"' >> ~/.bashrc`
  - For zsh: `echo 'export PPLX_API_KEY="your_api_key_here"' >> ~/.zshrc`
  - Then reload: `source ~/.bashrc` or `source ~/.zshrc`

- fish shell (universal variable):

  ```fish
  set -Ux PPLX_API_KEY "your_api_key_here"
  ```

- System-wide (Debian/Ubuntu):

  ```bash
  echo 'PPLX_API_KEY="your_api_key_here"' | sudo tee -a /etc/environment
  # log out and back in for changes to take effect
  ```

### Windows (PowerShell)

- Current session only:

  ```powershell
  $env:PPLX_API_KEY = "your_api_key_here"
  ```

- Persist for your user profile:

  ```powershell
  setx PPLX_API_KEY "your_api_key_here"
  # Restart your shell to see the change
  ```

- GUI method:
  - Start > search "Environment Variables" > Edit the system environment variables
  - Click "Environment Variables…"
  - Under "User variables", New…
  - Name: `PPLX_API_KEY`, Value: your key, OK

If you already have `PERPLEXITY_API_KEY` set, that works too -- no changes needed.

## Usage

To start interactive mode:

```bash
askp
```

Basic (raw JSON by default):

```bash
askp "What are the key differences between SQL and NoSQL?"
```

Text-only output:

```bash
askp -t "Explain RAG in simple terms"
```

Academic-only search:

```bash 
askp -a -t "Latest research on diffusion models vs transformers"
```

Restrict to a domain:

```bash
askp -t -d arxiv.org "Chain of thought prompting"
```

Recency filter:

```bash
askp -t --recency week "Best LLM fine-tuning guides"
```

Structured JSON response (example schema for startups):

```bash
askp --json-schema "List 5 notable AI infrastructure startups and their focus areas"
```

Choose a model:

```bash
askp -t -m sonar-pro "Summarize latest LLM evals"
# Note: the async API only supports 'sonar-deep-research'; prefer -m sonar-deep-research with --async
```

Show usage and citations (when available) with text output:

```bash
askp -t --usage --citations "Provide sources for your answer on LoRA vs QLoRA"
```

Piping to jq (optional, when using raw JSON):

```bash
askp "Explain vector databases" | jq .
```

## Interactive chat mode

Slash commands overview (type `/` to see suggestions):

- /help — list commands
- `/model <name>`, `/models` — change model or list available models
- `/system <text>` — set a system prompt; typing `/system` and pressing Enter pre-fills it
- `/academic on|off` — toggle or set academic search filter
- `/domain [host]` — set or clear domain filter
- `/recency day|week|month|off` — set or clear recency filter
- `/jsonschema on|off` — toggle structured output
- `/citations on|off` — toggle citation display (non-stream)
- `/usage on|off` — toggle usage display (non-stream)
- `/stream on|off` — toggle streaming output
- `/attach [path] [summarize|full|all] [--as-user] [--max-files N] [--pattern ".py,.md"] [--include-hidden]` — attach a local file or directory (supports txt, md, pdf, docx, html, images via OCR). Default: summarize. If [path] is omitted, it uses the current directory. Use `all` to skip selection UI and include all shown.
- `/async submit [prompt]|list|get <id>|wait <id>` — async helpers for chat sessions
- `/attachlimit <N>` — set truncation limit for `/attach --as-user` (default 8000)
- /settings — show current settings
- /prune [N] — summarize the conversation and restart with the summary as system prompt (default N=200 words)
- /clear — clear screen and start new conversation
- /new, /reset — new conversation (preserve /system)
- /exit, /quit — exit chat

Run askp with no arguments to start a conversational REPL:

```bash
askp
```

### Attach files in chat (/attach and /ocr)

Attach local files into the chat to provide context:

- Supported: .txt, .md, .pdf, .docx, .html/.htm, .py, .json, .yaml/.yml, .toml, .ini/.cfg, .csv/.tsv, .sh, .ps1, .bat/.cmd, .ipynb
- Images with OCR: .png, .jpg, .jpeg, .tif, .tiff (requires Tesseract OCR installed)
- Default behavior is summarize, which adds a brief summary as a system note.
- Use full to insert the entire text as a user message (only if reasonably small).
- Use --as-user to force inserting as a user message with truncation if very long. Adjust with `/attachlimit <N>` or `--attach-limit <N>` CLI flag.

Examples:

```text
/attach                         # no path: uses current directory, summarizes supported files
/attach notes.md                # summarize by default
/attach report.pdf summarize    # explicit summarize
/attach "docs/plan v2.txt" full   # include full content if small enough
/attach "huge.pdf" --as-user      # attach as user with truncation if long
/attach ./project-notes/          # attach a directory; auto-summarize supported files
/attach ./project-notes/ all      # attach all shown files without selection UI

/ocr ./images                    # OCR images in a directory; interactive selection
/ocr ./images all                # OCR all shown images without selection UI
/ocr ./images --pattern ".png"    # limit to PNGs
/ocr ./scan.jpg --as-user        # OCR a single file and insert as user message
```

Notes on OCR: pytesseract requires the Tesseract binary.

- macOS (Homebrew): brew install tesseract
- Debian/Ubuntu: sudo apt-get install tesseract-ocr
- Windows: Install from <https://github.com/tesseract-ocr/tesseract> and ensure it’s on PATH.

Notes on HTML extraction (optional BeautifulSoup):

- If the beautifulsoup4 package is installed, askp uses it for more accurate HTML-to-text extraction (ignores scripts/styles, preserves text order better).
- If not installed, askp falls back to a basic tag-stripper using regular expressions.
- To install: pip install beautifulsoup4

### Async usage

askp supports the Perplexity Async API for single-shot requests and within chat. Only the model `sonar-deep-research` is supported by the async API.

Single-shot (CLI) price around 0.40$:

```bash
# Takes 3-5 min, aprox $0.40
askp --async --wait -t -m sonar-deep-research "Survey recent academic literature on applications of large language models in scientific research"
# or fire-and-forget without --wait
askp --async -t -m sonar-deep-research "Outline key strategies for global poverty reduction" 
```

Example cost for above:

```bash
      "prompt_tokens": 9,
      "completion_tokens": 9895,
      "total_tokens": 9904,
      "search_context_size": null,
      "citation_tokens": 8417,
      "num_search_queries": 20,
      "reasoning_tokens": 62953,
      "cost": 
        "input_tokens_cost": 0.0,
        "output_tokens_cost": 0.08,
        "reasoning_tokens_cost": 0.19,
        "total_cost": 0.38
```

Tunables available with --async:

- --search-mode {web|none}
- --reasoning-effort {low|medium|high}
- --return-images
- --return-related-questions

In chat, you can use helpers:

```text
/async submit            # submit current conversation as async job
/async list              # list async jobs
/async get <id>          # fetch a job by id
/async wait <id>         # poll until completed
```

Notes:

- In chat mode, replies are printed as plain text. You can pass `--usage` and/or `--citations` at startup to show those when available.
- Startup flags like `-a/--academic`, `-d/--domain`, `--recency`, and `-m/--model` apply to the whole chat session. You can change the model mid-chat using `:model`.

## Command-line flags

- `--attach-limit <N>`: Set truncation limit used by /attach --as-user
- `query` (positional): Your question/prompt
- `-a, --academic`: Use academic search filter
- `-d, --domain <host>`: Restrict search to a domain (e.g., `arxiv.org`)
- `--recency {day|week|month}`: Search recency filter
- `--json-schema`: Enable structured JSON response for the included schema example
- `-m, --model {sonar, sonar-pro, sonar-reasoning, sonar-reasoning-pro}`: Select model (default: `sonar`)
- `-t, --text`: Print only the assistant text (instead of raw JSON)
- `-u, --usage`: Show token usage summary if available (only with `--text`)
- `-c, --citations`: Show citations if available (only with `--text`)
- `--async`: Use the async API for single-shot requests
- `--wait`: When used with `--async`, poll for the result and print it when completed
- `--search-mode {web|none}`: Search mode (async only)
- `--reasoning-effort {low|medium|high}`: Reasoning effort (async only)
- `--return-images`: Return images in the async response (async only)
- `--return-related-questions`: Return related questions (async only)
- `-v, --verbose`: Enable debug logging

## Making it a global command (optional)

### macOS/Linux

Option A: Shebang + executable + PATH

1. Make the script executable: `chmod +x askp.py`
2. Put it somewhere on your PATH, e.g.: `cp askp.py /usr/local/bin/askp`
3. Alternatively, use the included wrapper scripts for Windows/macOS/Linux; once on PATH, invoke `askp` everywhere.

Option B: Use the included wrapper script

- The included `askp` bash wrapper uses a relative path to the adjacent `askp.py`. Once the wrapper is on your PATH (`chmod +x askp`), just run `askp`.

Option C: Alias

```bash
alias askp='python /absolute/path/to/askp.py'
```

Add that line to your shell profile to persist.

### Windows

- Use the provided `askp.bat` (it calls the `askp.py` next to it). Add this folder to your PATH.
- Then run: `askp "your question"`

## Troubleshooting

- Error: `Error: API key not found. Set PPLX_API_KEY (preferred) or PERPLEXITY_API_KEY.`
  - Ensure you exported/set the variable and restarted your shell.
- Error: `ModuleNotFoundError: No module named 'requests'`
  - Run `pip install requests` or `pip install -r requirements.txt` in your virtual environment.
- HTTP 401 Unauthorized
  - Check that your API key is valid and has access.
- Other HTTP errors
  - The CLI prints server responses on errors to help diagnose issues (rate limits, malformed payloads, etc.).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/liensimen/askp",
    "name": "askp-cli",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "perplexity, ai, cli, command-line, chat, assistant",
    "author": "LienS",
    "author_email": "Simen Lien <simen@cvcv.no>",
    "download_url": "https://files.pythonhosted.org/packages/a7/f4/3f46dddc6c1dd4a19f9421fe50885a09389be920482ae586c93fbbb7d147/askp_cli-1.0.6.tar.gz",
    "platform": null,
    "description": "# askp - Perplexity CLI (Python)\r\n\r\nA tiny command-line tool to query Perplexity\u2019s API with optional search filters and structured/text output.\r\n\r\n## Modes\r\n\r\naskp supports two main modes:\r\n\r\n- **Interactive mode:**  \r\n  Start a conversational REPL for multi-turn chat and advanced features. Just run `askp` with no arguments.\r\n\r\n- **Single-shot mode:**  \r\n  Ask a single question and get a response immediately. Run `askp \"your question\"` with optional flags for output format, filters, and model selection.\r\n  Defaults to raw json to work with other model as a researcher.\r\n\r\nIf you only want to run it, install to PATH and simply run `askp \"your question\"` after setting your API key.\r\n\r\n---\r\n\r\n## Features\r\n\r\n- **Interactive chat mode** (REPL) with slash commands for advanced control\r\n- **Single-shot mode** for quick answers or scripting\r\n- **Simple one-file CLI** in Python, no build step required\r\n- **Search filters**:\r\n  - Academic-only search: `-a/--academic`\r\n  - Restrict to a domain: `-d/--domain`\r\n  - Recency filter: `--recency {day|week|month}`\r\n- **Output modes**:\r\n  - Raw JSON (default, great for piping to `jq`)\r\n  - Text-only output: `-t/--text`\r\n  - Structured JSON with `--json-schema`\r\n  - Optional `--usage` and `--citations` summaries\r\n- **Model selection** with validation: `-m/--model {sonar, sonar-pro, sonar-reasoning, sonar-reasoning-pro}`\r\n- **Async API support** for long-running jobs (`--async`, `/async`)\r\n- **File and directory attachment** in chat (`/attach`, `/ocr`), including OCR for images\r\n- **Slash commands** for model switching, system prompts, filters, pruning, and more\r\n- **Piping and scripting**: designed for shell integration and automation\r\n- **Verbose logging** with `-v/--verbose` for debugging\r\n- **Cross-platform**: works on macOS, Linux, and Windows\r\n- **Easy install**: venv, pipx, or single-line user install\r\n- **API key fallback**: supports both `PPLX_API_KEY` and `PERPLEXITY_API_KEY`\r\n- **Extensible**: supports additional Python packages for enhanced features (e.g., BeautifulSoup for HTML, pytesseract for OCR)\r\n\r\n## Requirements\r\n\r\n- Python 3.8+\r\n- `requests` Python package\r\n\r\nInstall dependencies one of two ways:\r\n\r\n- With a venv and requirements.txt:\r\n\r\n  ```bash\r\n  python -m venv .venv\r\n  source .venv/bin/activate\r\n  pip install -r requirements.txt\r\n  ```\r\n\r\n## Install\r\n\r\n### Recommended: Install from PyPI\r\n\r\n```bash\r\npip install askp-cli\r\n```\r\n\r\nAfter installation, you can use the `askp` command directly:\r\n\r\n```bash\r\naskp --help\r\n```\r\n\r\n### Alternative: Install with pipx (isolated environment)\r\n\r\n```bash\r\npipx install askp-cli\r\n```\r\n\r\n### Development: Install from source\r\n\r\nIf you want to contribute or use the latest development version:\r\n\r\n```bash\r\ngit clone https://github.com/LienSimen/perplexity-cli.git\r\ncd perplexity-cli\r\npip install -e .\r\n```\r\n\r\nOr install directly from Git with pipx:\r\n\r\n```bash\r\npipx install git+https://github.com/LienSimen/perplexity-cli.git\r\n```\r\n\r\n\r\n## Get an API key\r\n\r\n- You need a Perplexity API key. See Perplexity\u2019s docs/pricing for obtaining an API key.\r\n\r\n## Configure your API key (PPLX_API_KEY with fallback)\r\n\r\naskp.py checks these environment variables in order:\r\n\r\n1) `PPLX_API_KEY` (preferred)\r\n2) `PERPLEXITY_API_KEY` (fallback)\r\n\r\nBelow are platform-specific instructions to set environment variables.\r\n\r\n### macOS and Linux (bash/zsh)\r\n\r\n- Current shell only:\r\n\r\n  ```bash\r\n  export PPLX_API_KEY=\"your_api_key_here\"\r\n  ```\r\n\r\n- Persist for future shells (append to your shell profile):\r\n  - For bash: `echo 'export PPLX_API_KEY=\"your_api_key_here\"' >> ~/.bashrc`\r\n  - For zsh: `echo 'export PPLX_API_KEY=\"your_api_key_here\"' >> ~/.zshrc`\r\n  - Then reload: `source ~/.bashrc` or `source ~/.zshrc`\r\n\r\n- fish shell (universal variable):\r\n\r\n  ```fish\r\n  set -Ux PPLX_API_KEY \"your_api_key_here\"\r\n  ```\r\n\r\n- System-wide (Debian/Ubuntu):\r\n\r\n  ```bash\r\n  echo 'PPLX_API_KEY=\"your_api_key_here\"' | sudo tee -a /etc/environment\r\n  # log out and back in for changes to take effect\r\n  ```\r\n\r\n### Windows (PowerShell)\r\n\r\n- Current session only:\r\n\r\n  ```powershell\r\n  $env:PPLX_API_KEY = \"your_api_key_here\"\r\n  ```\r\n\r\n- Persist for your user profile:\r\n\r\n  ```powershell\r\n  setx PPLX_API_KEY \"your_api_key_here\"\r\n  # Restart your shell to see the change\r\n  ```\r\n\r\n- GUI method:\r\n  - Start > search \"Environment Variables\" > Edit the system environment variables\r\n  - Click \"Environment Variables\u2026\"\r\n  - Under \"User variables\", New\u2026\r\n  - Name: `PPLX_API_KEY`, Value: your key, OK\r\n\r\nIf you already have `PERPLEXITY_API_KEY` set, that works too -- no changes needed.\r\n\r\n## Usage\r\n\r\nTo start interactive mode:\r\n\r\n```bash\r\naskp\r\n```\r\n\r\nBasic (raw JSON by default):\r\n\r\n```bash\r\naskp \"What are the key differences between SQL and NoSQL?\"\r\n```\r\n\r\nText-only output:\r\n\r\n```bash\r\naskp -t \"Explain RAG in simple terms\"\r\n```\r\n\r\nAcademic-only search:\r\n\r\n```bash \r\naskp -a -t \"Latest research on diffusion models vs transformers\"\r\n```\r\n\r\nRestrict to a domain:\r\n\r\n```bash\r\naskp -t -d arxiv.org \"Chain of thought prompting\"\r\n```\r\n\r\nRecency filter:\r\n\r\n```bash\r\naskp -t --recency week \"Best LLM fine-tuning guides\"\r\n```\r\n\r\nStructured JSON response (example schema for startups):\r\n\r\n```bash\r\naskp --json-schema \"List 5 notable AI infrastructure startups and their focus areas\"\r\n```\r\n\r\nChoose a model:\r\n\r\n```bash\r\naskp -t -m sonar-pro \"Summarize latest LLM evals\"\r\n# Note: the async API only supports 'sonar-deep-research'; prefer -m sonar-deep-research with --async\r\n```\r\n\r\nShow usage and citations (when available) with text output:\r\n\r\n```bash\r\naskp -t --usage --citations \"Provide sources for your answer on LoRA vs QLoRA\"\r\n```\r\n\r\nPiping to jq (optional, when using raw JSON):\r\n\r\n```bash\r\naskp \"Explain vector databases\" | jq .\r\n```\r\n\r\n## Interactive chat mode\r\n\r\nSlash commands overview (type `/` to see suggestions):\r\n\r\n- /help \u2014 list commands\r\n- `/model <name>`, `/models` \u2014 change model or list available models\r\n- `/system <text>` \u2014 set a system prompt; typing `/system` and pressing Enter pre-fills it\r\n- `/academic on|off` \u2014 toggle or set academic search filter\r\n- `/domain [host]` \u2014 set or clear domain filter\r\n- `/recency day|week|month|off` \u2014 set or clear recency filter\r\n- `/jsonschema on|off` \u2014 toggle structured output\r\n- `/citations on|off` \u2014 toggle citation display (non-stream)\r\n- `/usage on|off` \u2014 toggle usage display (non-stream)\r\n- `/stream on|off` \u2014 toggle streaming output\r\n- `/attach [path] [summarize|full|all] [--as-user] [--max-files N] [--pattern \".py,.md\"] [--include-hidden]` \u2014 attach a local file or directory (supports txt, md, pdf, docx, html, images via OCR). Default: summarize. If [path] is omitted, it uses the current directory. Use `all` to skip selection UI and include all shown.\r\n- `/async submit [prompt]|list|get <id>|wait <id>` \u2014 async helpers for chat sessions\r\n- `/attachlimit <N>` \u2014 set truncation limit for `/attach --as-user` (default 8000)\r\n- /settings \u2014 show current settings\r\n- /prune [N] \u2014 summarize the conversation and restart with the summary as system prompt (default N=200 words)\r\n- /clear \u2014 clear screen and start new conversation\r\n- /new, /reset \u2014 new conversation (preserve /system)\r\n- /exit, /quit \u2014 exit chat\r\n\r\nRun askp with no arguments to start a conversational REPL:\r\n\r\n```bash\r\naskp\r\n```\r\n\r\n### Attach files in chat (/attach and /ocr)\r\n\r\nAttach local files into the chat to provide context:\r\n\r\n- Supported: .txt, .md, .pdf, .docx, .html/.htm, .py, .json, .yaml/.yml, .toml, .ini/.cfg, .csv/.tsv, .sh, .ps1, .bat/.cmd, .ipynb\r\n- Images with OCR: .png, .jpg, .jpeg, .tif, .tiff (requires Tesseract OCR installed)\r\n- Default behavior is summarize, which adds a brief summary as a system note.\r\n- Use full to insert the entire text as a user message (only if reasonably small).\r\n- Use --as-user to force inserting as a user message with truncation if very long. Adjust with `/attachlimit <N>` or `--attach-limit <N>` CLI flag.\r\n\r\nExamples:\r\n\r\n```text\r\n/attach                         # no path: uses current directory, summarizes supported files\r\n/attach notes.md                # summarize by default\r\n/attach report.pdf summarize    # explicit summarize\r\n/attach \"docs/plan v2.txt\" full   # include full content if small enough\r\n/attach \"huge.pdf\" --as-user      # attach as user with truncation if long\r\n/attach ./project-notes/          # attach a directory; auto-summarize supported files\r\n/attach ./project-notes/ all      # attach all shown files without selection UI\r\n\r\n/ocr ./images                    # OCR images in a directory; interactive selection\r\n/ocr ./images all                # OCR all shown images without selection UI\r\n/ocr ./images --pattern \".png\"    # limit to PNGs\r\n/ocr ./scan.jpg --as-user        # OCR a single file and insert as user message\r\n```\r\n\r\nNotes on OCR: pytesseract requires the Tesseract binary.\r\n\r\n- macOS (Homebrew): brew install tesseract\r\n- Debian/Ubuntu: sudo apt-get install tesseract-ocr\r\n- Windows: Install from <https://github.com/tesseract-ocr/tesseract> and ensure it\u2019s on PATH.\r\n\r\nNotes on HTML extraction (optional BeautifulSoup):\r\n\r\n- If the beautifulsoup4 package is installed, askp uses it for more accurate HTML-to-text extraction (ignores scripts/styles, preserves text order better).\r\n- If not installed, askp falls back to a basic tag-stripper using regular expressions.\r\n- To install: pip install beautifulsoup4\r\n\r\n### Async usage\r\n\r\naskp supports the Perplexity Async API for single-shot requests and within chat. Only the model `sonar-deep-research` is supported by the async API.\r\n\r\nSingle-shot (CLI) price around 0.40$:\r\n\r\n```bash\r\n# Takes 3-5 min, aprox $0.40\r\naskp --async --wait -t -m sonar-deep-research \"Survey recent academic literature on applications of large language models in scientific research\"\r\n# or fire-and-forget without --wait\r\naskp --async -t -m sonar-deep-research \"Outline key strategies for global poverty reduction\" \r\n```\r\n\r\nExample cost for above:\r\n\r\n```bash\r\n      \"prompt_tokens\": 9,\r\n      \"completion_tokens\": 9895,\r\n      \"total_tokens\": 9904,\r\n      \"search_context_size\": null,\r\n      \"citation_tokens\": 8417,\r\n      \"num_search_queries\": 20,\r\n      \"reasoning_tokens\": 62953,\r\n      \"cost\": \r\n        \"input_tokens_cost\": 0.0,\r\n        \"output_tokens_cost\": 0.08,\r\n        \"reasoning_tokens_cost\": 0.19,\r\n        \"total_cost\": 0.38\r\n```\r\n\r\nTunables available with --async:\r\n\r\n- --search-mode {web|none}\r\n- --reasoning-effort {low|medium|high}\r\n- --return-images\r\n- --return-related-questions\r\n\r\nIn chat, you can use helpers:\r\n\r\n```text\r\n/async submit            # submit current conversation as async job\r\n/async list              # list async jobs\r\n/async get <id>          # fetch a job by id\r\n/async wait <id>         # poll until completed\r\n```\r\n\r\nNotes:\r\n\r\n- In chat mode, replies are printed as plain text. You can pass `--usage` and/or `--citations` at startup to show those when available.\r\n- Startup flags like `-a/--academic`, `-d/--domain`, `--recency`, and `-m/--model` apply to the whole chat session. You can change the model mid-chat using `:model`.\r\n\r\n## Command-line flags\r\n\r\n- `--attach-limit <N>`: Set truncation limit used by /attach --as-user\r\n- `query` (positional): Your question/prompt\r\n- `-a, --academic`: Use academic search filter\r\n- `-d, --domain <host>`: Restrict search to a domain (e.g., `arxiv.org`)\r\n- `--recency {day|week|month}`: Search recency filter\r\n- `--json-schema`: Enable structured JSON response for the included schema example\r\n- `-m, --model {sonar, sonar-pro, sonar-reasoning, sonar-reasoning-pro}`: Select model (default: `sonar`)\r\n- `-t, --text`: Print only the assistant text (instead of raw JSON)\r\n- `-u, --usage`: Show token usage summary if available (only with `--text`)\r\n- `-c, --citations`: Show citations if available (only with `--text`)\r\n- `--async`: Use the async API for single-shot requests\r\n- `--wait`: When used with `--async`, poll for the result and print it when completed\r\n- `--search-mode {web|none}`: Search mode (async only)\r\n- `--reasoning-effort {low|medium|high}`: Reasoning effort (async only)\r\n- `--return-images`: Return images in the async response (async only)\r\n- `--return-related-questions`: Return related questions (async only)\r\n- `-v, --verbose`: Enable debug logging\r\n\r\n## Making it a global command (optional)\r\n\r\n### macOS/Linux\r\n\r\nOption A: Shebang + executable + PATH\r\n\r\n1. Make the script executable: `chmod +x askp.py`\r\n2. Put it somewhere on your PATH, e.g.: `cp askp.py /usr/local/bin/askp`\r\n3. Alternatively, use the included wrapper scripts for Windows/macOS/Linux; once on PATH, invoke `askp` everywhere.\r\n\r\nOption B: Use the included wrapper script\r\n\r\n- The included `askp` bash wrapper uses a relative path to the adjacent `askp.py`. Once the wrapper is on your PATH (`chmod +x askp`), just run `askp`.\r\n\r\nOption C: Alias\r\n\r\n```bash\r\nalias askp='python /absolute/path/to/askp.py'\r\n```\r\n\r\nAdd that line to your shell profile to persist.\r\n\r\n### Windows\r\n\r\n- Use the provided `askp.bat` (it calls the `askp.py` next to it). Add this folder to your PATH.\r\n- Then run: `askp \"your question\"`\r\n\r\n## Troubleshooting\r\n\r\n- Error: `Error: API key not found. Set PPLX_API_KEY (preferred) or PERPLEXITY_API_KEY.`\r\n  - Ensure you exported/set the variable and restarted your shell.\r\n- Error: `ModuleNotFoundError: No module named 'requests'`\r\n  - Run `pip install requests` or `pip install -r requirements.txt` in your virtual environment.\r\n- HTTP 401 Unauthorized\r\n  - Check that your API key is valid and has access.\r\n- Other HTTP errors\r\n  - The CLI prints server responses on errors to help diagnose issues (rate limits, malformed payloads, etc.).\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A command-line interface for Perplexity AI",
    "version": "1.0.6",
    "project_urls": {
        "Bug Reports": "https://github.com/liensimen/askp/issues",
        "Homepage": "https://github.com/liensimen/askp",
        "Source": "https://github.com/liensimen/askp"
    },
    "split_keywords": [
        "perplexity",
        " ai",
        " cli",
        " command-line",
        " chat",
        " assistant"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2f45cd45c45ddb886764cdc08bd00f9a03c116e27ccf1607da32847eb46a5482",
                "md5": "642265a720385e654da29c399a7bb353",
                "sha256": "493c498dd83f30ea05f96abdc1fff01bd9288021f807169ae31bf8608285aa08"
            },
            "downloads": -1,
            "filename": "askp_cli-1.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "642265a720385e654da29c399a7bb353",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 47881,
            "upload_time": "2025-08-14T22:08:20",
            "upload_time_iso_8601": "2025-08-14T22:08:20.118863Z",
            "url": "https://files.pythonhosted.org/packages/2f/45/cd45c45ddb886764cdc08bd00f9a03c116e27ccf1607da32847eb46a5482/askp_cli-1.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a7f43f46dddc6c1dd4a19f9421fe50885a09389be920482ae586c93fbbb7d147",
                "md5": "60768c43dbe2f06e8329b52fbdd2a6af",
                "sha256": "aad5482209110cd4bdb1fc8cc2d92e00ea7affa17c6bc6e209c778f2f0799e08"
            },
            "downloads": -1,
            "filename": "askp_cli-1.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "60768c43dbe2f06e8329b52fbdd2a6af",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 53639,
            "upload_time": "2025-08-14T22:08:21",
            "upload_time_iso_8601": "2025-08-14T22:08:21.471007Z",
            "url": "https://files.pythonhosted.org/packages/a7/f4/3f46dddc6c1dd4a19f9421fe50885a09389be920482ae586c93fbbb7d147/askp_cli-1.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-14 22:08:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "liensimen",
    "github_project": "askp",
    "github_not_found": true,
    "lcname": "askp-cli"
}
        
Elapsed time: 0.92338s