Check out the demo
Cha is an open-source command-line tool that simplifies interactions with AI models from OpenAI. It allows users to efficiently engage with powerful language models directly from their terminal, enhancing development workflows.
Cha is a simple, lightweight CLI tool that provides access to powerful AI models directly from the terminal. Think of it like Vim versus Emacs: Cha focuses on simplicity and versatility, delivering essential functionality without overwhelming complexity. It's designed to fit seamlessly into your workflow, helping to reduce the need for developers to leave their terminals, making AI access and general knowledge querying straightforward and efficient.
- CLI Chat Interface: Communicate with OpenAI's models via commands
cha
. - Interactive & Non-interactive Modes: Interact with models via chat interface, command-line arguments, or file input.
- Multi-line Input Mode: Simplifies complex input directly into the CLI.
- Text-Editor Input Mode: Use your system's terminal-based text editor for inputting your prompt, allowing easier input of complex and long prompts.
- Web and YouTube Scraping: Extract YouTube video transcripts, web PDFs, and general web content.
- Answer Search (Deep Search): Simple implementation of an Answer-Search engine similar to Perplexity AI's solution.
- Estimate Tokens: Option to estimate the token count for a file, string, or piped content.
- Support for Multiple File Types: Supports a variety of file types for input, including PDF, DOCX, XLSX, and common image formats, enabling seamless integration and processing of different kinds of content.
- Platform Flexibility: Switch between different AI platform providers offering OpenAI-compatible APIs using the
--platform
argument. - Switch Between Models: Easily switch between models during a conversation.
- Code Dump Feature: Easily dump your entire code or a directory's content as one text file OR as context for your conversation.
- Quick Web Search: Well chatting you can ask a question/prompt and have Cha browse the web real quick before answering your question.
- Export Markdown Fences: If desired, export any Markdown fence in the latest message from a model to file(s).
-
Clone the Repository:
git clone <repository-url> cd <repository-folder>
-
Install the Package:
pip3 install --upgrade .
-
Install other dependencies:
# checkout docs for install details different systems: https://ffmpeg.org/ brew install ffmpeg
-
API Key Setup: Cha requires an OpenAI API key, which you can obtain here.
-
Setup your .env file: Create a
.env
file in the root directory and add your keys:export OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
-
Apply the environment variables
source .env
After installing and configuring everything, the final step is to run the checkup script to ensure everything is set up/installed correctly. You can ignore optional checkups/tests here, as those are not necessary for the core of Cha to function. Knowing this, to run these checkups/tests, use the following command:
python3 ./assets/checkup.py
If the checkups/tests look good, or you're okay with it, then start using Cha!
cha
You can check the instructions below for more details on what Cha can do and how you can use it!
cha
cha "<some question or request>"
- Example:
cha "in type script how can I check if .canvas.edges is an empty array?"
cha --code_dump
cha -d
cha -a
cha -a "<question>"
- Example:
cha -a "what is the goal of life"
cha -f <FILE>
- Example:
cha -f index.js
cha -m <MODEL_NAME>
- Example:
cha -m "o3-mini"
cha -ocr <FILE> [> <OUTPUT_FILE>]
- Examples:
cha -ocr ./README.md cha -ocr meme.jpg > output.txt
-
cha -p "<PLATFORM_OR_URL|API_KEY_ENV>" -m "<MODEL_NAME>"
- Examples:
cha -p "https://api.deepseek.com|DEEP_SEEK_API_KEY" -m "deepseek-chat" cha -p "llama3-70b-8192|GROQ_API_KEY" -m "llama3-70b-8192"
- Examples:
-
cha -p
- Dynamic platform switching with no need for the user to provide a base URL and model name.
- Manually select a platform and model; refer to
./cha/config.py
to see all supported platforms. - Examples:
cha -p
-
cha -p "<PLATFORM_NAME|OPTIONAL_MODEL_NAME>"
-
Refer to
./cha/config.py
to see all supported platforms. -
Here you can select a supported platform and a model on that platform in one line with no need for manually selecting a platform and/or model.
-
The model name is optional; you can just provide the platform name and manually select a model name. Or just provide both.
-
Please note, if the platform is not listed in the config or the model name is invalid, Cha will just error out.
-
Examples:
# cleanly select a supported platform and the name of a model supported on the platform cha -p "groq|deepseek-r1-distill-llama-70b" # cleanly select just the platform and select a model from that platform manually with user input later on cha -p "groq"
-
cha -sm
cha -sm <MODEL_NAME>
cha -t -f <FILE>
- Example:
cha -t -f README.md
These appear frequently with “cha” followed by a question/request referencing programming, shell commands, or general tasks, for example:
cha how many seconds is in a day
cha in python how can I save a dict to a json
cha craft me a unix command to find all Cargo.toml
cha make me a simple flask API
In essence, your unique “cha” CLI usage falls into these main patterns:
- Running “cha” with a direct query.
- Doing code dumps or debug dumps (-code_dump, -c, -d).
- Performing deep answer searches (-a).
- Perform a quick web search before answering your question/prompt (-b).
- Feeding in file input (-f).
- Specifying or switching models (-m, -sm).
- Running OCR operations (-ocr).
- Switching platforms (-p).
- Checking token counts (-t).
- Asking a broad variety of how-to / make-me requests directly after “cha …”.
Note that when you run Cha directly, meaning it conducts a single call to the model through the CLI as an argument, you can use the optional -e
argument. This will export all code/file blocks in the model's last response that are enclosed in markdown fences. This feature makes it easy for Cha to generate files, such as a Python script, and have them accessible on you system (current directory) without needing to manually create a file, select, copy, and paste the content into a file. You can do this by running Cha like this (example):
cha -e write me python code to find the area of a circle
When you run the example command above, it will answer your question in one shot, then grab the code/file the model generated and save it to a file in your current directory. The file(s) it create will be named something like this: export_a9570f7e.py
. Cha considers file extensions, so if the content is a text file, Go code, etc., it will include that file extension as part of the file name. With this, you can run the code/file and/or edit it on your system without needing to manually create a file if needed.
Cha also supports and accepts additional parameters. Here is the help page for reference:
usage: cha [-h] [-pt] [-m MODEL] [-sm] [-f FILE] [-t] [-ocr OCR] [-p [PLATFORM]] [-d [CODE_DUMP]] [-a] [-e] [string ...]
Chat with an OpenAI GPT model.
positional arguments:
string Non-interactive mode, feed a string into the model
options:
-h, --help show this help message and exit
-pt, --print_title Print initial title during interactive mode
-m MODEL, --model MODEL
Model to use for chatting
-sm, --select_model Select one model from OpenAI's supported models
-f FILE, --file FILE Filepath to file that will be sent to the model (text only)
-t, --token_count Count tokens for the input file or string
-ocr OCR, --ocr OCR Given a file path, print the content of that file as text though Cha's main file loading logic
-p [PLATFORM], --platform [PLATFORM]
Use a different provider, set this like this: "<base_url>|<api_key_env_name>", or use as a flag with "-p" for True
-d [CODE_DUMP], --code_dump [CODE_DUMP]
Do a full code dump into one file in your current directory
-a, -as, --answer_search
Run answer search
-e, --export_parsed_text
Extract code blocks from the final output and save them as files
For those interested in contributing or experimenting with Cha:
-
Install Cha in Editable Mode:
pip install -e .
-
Develop and Test: Modify the source code and test changes using
cha
. -
(optional) Load your Custom Configuration: Use the
CHA_PYTHON_CUSTOM_CONFIG_PATH
environment variable to point to a customconfig.py
file that overrides default global variables. Set it usingexport CHA_PYTHON_CUSTOM_CONFIG_PATH="/path/to/your/config.py"
. Ensure your defined variables are in uppercase. -
(Optional) Update Cha's "setup.py" or run system checks to ensure proper functionality: Run the following command in the same directory as Cha's code:
python3 ./assets/update.py
Cha now supports switching between AI platforms using the --platform
argument, enabling interoperability with OpenAI-compatible APIs.
cha -p
Running cha -p
opens a menu to select a platform. To skip the menu, provide the base URL, environment variable name, and model name directly. For example, to use the DeepSeek-V3
model from together.ai
:
# Get and set the provider's API key env variable
export TOGETHER_API_KEY="..."
# Run cha with a different provider/platform
cha -p "https://api.together.xyz/v1|TOGETHER_API_KEY" -m "deepseek-ai/DeepSeek-V3"
Also, you can refer to the config.py file and the THIRD_PARTY_PLATFORMS
variable to see all the other platforms you can try and/or use.
Any contribution is welcomed! Please feel free to submit issues or pull requests for any bugs or features.
Cha is licensed under the MIT License. See LICENSE for more details.