Skip to content

cloudxabide/perplexity-cli

Repository files navigation

Perplexity CLI

A command-line interface for interacting with the Perplexity AI API.

Warning/NOTE: must of this content was created by GenAI using Amazon Q. As with ANY code you find on the Internet, use at your own risk and review the code (fortunately this code is very simple to review).

Installation

From PyPI (recommended)

pip install perplexity-cli

From Source

git clone https://github.com/cloudxabide/perplexity-cli.git
cd perplexity-cli
pip install -e .

Configuration

Before using the CLI, you need to set up your Perplexity API key. You can do this in one of two ways:

  1. Set an environment variable:
export PERPLEXITY_API_KEY="your-api-key"
  1. Save the API key to the configuration file:
perplexity-cli --set-api-key "your-api-key"

You can also configure default settings:

# Set default model
perplexity-cli --set-default-model "sonar-pro"

# Set default max tokens
perplexity-cli --set-max-tokens 2000

Usage

List Available Models

perplexity-cli -l

Send a Query

Using the default model:

perplexity-cli -q "What is the distance between the Sun and Earth?"

Using a specific model:

perplexity-cli -m sonar-pro -q "What is the distance between the Sun and Earth?"

Advanced Options

Set maximum tokens for the response:

perplexity-cli -t 2000 -q "Explain quantum computing in detail"

Enable verbose output:

perplexity-cli -v -q "What is the distance between the Sun and Earth?"

Enable debug logging:

perplexity-cli -d -q "What is the distance between the Sun and Earth?"

Available Models

As of May 2025, the following models are available:

  • sonar-reasoning-pro
  • sonar-reasoning
  • sonar-pro
  • sonar
  • llama-3.1-sonar-small-128k-online
  • llama-3.1-sonar-large-128k-online
  • llama-3.1-sonar-huge-128k-online

For the most up-to-date list, visit: https://docs.perplexity.ai/guides/model-cards

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/cloudxabide/perplexity-cli.git
cd perplexity-cli

# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install development dependencies
pip install -e ".[dev]"

Running Tests

pytest

License

MIT License

Author

cloudxabide

About

Perplexity AI CLI Client written in Python by Amazon Q

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages