A CLI tool to interact with various LLM APIs
Project description
LLX - A CLI for Interacting with Large Language Models
LLX is a Python-based command-line interface (CLI) that makes it easy to interact with various Large Language Model (LLM) providers. Whether you need to chat with models, send prompts with attachments, crawl URLs for content extraction, or run evaluations, LLX provides a convenient set of commands to streamline the process.
Features
- Support for multiple LLM providers (OpenAI, Ollama, Anthropic, Deepseek, Mistral, Gemini, XAI).
- LLM response streaming.
- Multimodal support, upload and analyze files.
Installation
-
Make sure you have Python 3.7+ installed.
-
(Optional) Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # Linux/Mac venv\Scripts\activate # Windows -
Install LLX with pip:
pip install llx -
(Optional) Create a .env file in your project directory to store your provider API keys (e.g., OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.). You can use .env.example as a reference.
Usage
Once installed, you can run the CLI with:
llx --help
This will list all available subcommands and their required/optional parameters. Below is a summary of each subcommand and example usage.
1. prompt
Send a single prompt to a specified model. The prompt text can be passed in directly or piped in via stdin.
• Required options:
--model / -m : The model in ":<model_name>" format.
• Optional:
--prompt / -p : The prompt string (if not provided, it reads from stdin).
--attachment / -a : Path to an image file to send as an attachment.
Example 1 (inline prompt):
llx prompt --model openai:gpt-3.5-turbo --prompt "Hello, how are you?"
Example 2 (pipe prompt from stdin):
echo "Hello from stdin" | llx prompt -m openai:gpt-3.5-turbo
Example 3 (with attachment):
llx prompt -m openai:gpt-3.5-turbo -p "Extract text from this image" -a /path/to/image.jpg
2. chat
Start an interactive chat session with a specified model. Your local terminal will prompt for user input, and the assistant response will stream back.
• Required option:
--model / -m : The model in ":<model_name>" format.
Example:
llx chat --model openai:gpt-3.5-turbo
Then type your messages. Type /bye or press Ctrl+C to exit.
3. server
Start a small FastAPI server to expose a chat completions endpoint (POST /v1/chat/completions). This is helpful if you want to run your own local API wrapper.
• Options:
--host : Defaults to 127.0.0.1.
--port : Defaults to 8000.
Example:
llx server --host 127.0.0.1 --port 8000
You can then send POST requests to http://127.0.0.1:8000/v1/chat/completions.
4. url_to_prompt
Crawl one or more URLs, optionally extracting text from HTML, and print the content (plus an optional prompt) to stdout.
• Required option:
--url : The starting URL to begin crawling.
• Optional:
--prompt / -p : A prompt to prepend.
--extract-text : Extract text instead of returning raw HTML.
--domain : Restrict crawling to this domain.
--max-depth : Depth of links to follow (defaults to 1).
--max-urls : Max number of links to crawl (defaults to 1).
Example:
llx url_to_prompt --url https://example.com --prompt "Summarize the following:" --extract-text true --max-depth 2 --max-urls 5
This will print the extracted text from up to 5 URLs (within 2 link levels from the start) in a structured format alongside your prompt.
5. files_to_prompt
Concatenate the contents of all files in a directory into a single prompt (printed to stdout). You can prepend an optional prompt string.
• Required options:
--path : Directory path containing the files.
• Optional:
--prompt / -p : A prompt to prepend.
Example:
llx files_to_prompt --path /path/to/documents --prompt "Here are the contents of my documents:"
This command walks through each file, ignoring binary files, and combines them in an XML-like structure printed to stdout.
6. audio_to_prompt
Perform speech-to-text on the given audio file, and prepend the resulting text as context to the LLM prompt.
• Required options:
--path : Path to the audio file.
--model / -m : Model in ":<model_name>" format.
• Optional:
--prompt / -p : A prompt to prepend to the transcribed text.
Example:
llx audio_to_prompt --path /path/to/speech.wav --model openai:whisper-1 --prompt "Transcribe and analyze this audio:"
(Note: Actual speech-to-text logic is a placeholder in this example; implement your own logic or extend the code where needed.)
7. evals
Run evaluation scripts against a specified LLM.
• Required options:
--path : Path to the evals file.
--model / -m : Model in ":<model_name>" format.
Example:
llx evals --path /path/to/evals.json --model openai:gpt-3.5-turbo
Customize this command for your own testing or evaluation methods.
Environment Variables
Providers require API keys to function. Store them in a .env file in your working directory or set them directly in your shell environment. For example:
• OPENAI_API_KEY
• ANTHROPIC_API_KEY
• DEEPSEEK_API_KEY
• MISTRAL_API_KEY
• GEMINI_API_KEY
• XAI_API_KEY
Use the .env.example file as a reference.
Example .env:
OPENAI_API_KEY=<your-openai-key>
ANTHROPIC_API_KEY=<your-anthropic-key>
...
Contributing
- Clone the repository.
- Create and activate a virtual environment.
- Install dependencies by running pip install -e .
- Develop and submit pull requests.
We appreciate bug reports, feature requests, and pull requests!
License
This project is licensed under the MIT License. See the LICENSE file for details.
Happy prompting! If you have any questions or issues, feel free to open a GitHub issue.%
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_tools_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: llm_tools_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
198f1b3306627ea0b412d5df60f1b9f70dd76ae969c80c761bb5c4081ea9e1b1
|
|
| MD5 |
3064ccac26e2c62084d6e2f38cbd7241
|
|
| BLAKE2b-256 |
39e114f20a8927bc9451c13c6802ad994bf206a44ff21b18f070c943f72c2aa5
|