https://github.com/haalven/llm_terminal
ask LLMs in the terminal
https://github.com/haalven/llm_terminal
chatgpt command-line gemma2 gpt4o llama3 ollama-api openai-api python terminal
Last synced: about 1 month ago
JSON representation
ask LLMs in the terminal
- Host: GitHub
- URL: https://github.com/haalven/llm_terminal
- Owner: haalven
- Created: 2024-07-12T15:51:35.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2026-02-13T12:12:16.000Z (4 months ago)
- Last Synced: 2026-02-13T21:23:22.056Z (4 months ago)
- Topics: chatgpt, command-line, gemma2, gpt4o, llama3, ollama-api, openai-api, python, terminal
- Language: Python
- Homepage:
- Size: 1.51 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ask LLMs in the Terminal
`ask_openai.py` – call the [OpenAI API](https://openai.com/api), `API_KEY` required
`ask_ollama.py` – call the [local Ollama API](https://ollama.com/) (localhost:11434)
required:
* [prompt_toolkit](https://github.com/prompt-toolkit/python-prompt-toolkit) (input)
* [openai](https://github.com/openai/openai-python) (ask_openai.py)
* [requests](https://requests.readthedocs.io/) (ask_ollama.py)
* [rich](https://github.com/Textualize/rich) (output)
## OpenAI API
[ask_openai.py](https://github.com/haalven/LLM_terminal/blob/main/ask_openai.py) uses the [openai Python library](https://github.com/openai/openai-python) to call the [OpenAI API](https://openai.com/api). An internet connection is required.
[ask_openai.toml](https://github.com/haalven/LLM_terminal/blob/main/ask_openai.toml) ➔ you have to insert your `API_KEY` by editing the `my_api_key = "sk-***"` line before running the script.
usage: `./ask_openai.py [question?]`
Choose a specific OpenAI model ➔ see: [platform.openai.com/docs/models](https://platform.openai.com/docs/models).
## Ollama API
[ask_ollama.py](https://github.com/haalven/LLM_terminal/blob/main/ask_ollama.py) uses the [requests Python library](https://requests.readthedocs.io/) to call the [local Ollama API](https://ollama.com/) (based on [llama.cpp](https://en.wikipedia.org/wiki/Llama.cpp)). An internet connection is not required. Install Ollama first and start the local server (localhost:11434). To download LLMs use the `ollama run ` command.
usage: `./ask_ollama.py [question?]`
Good general LLMs for computers with 8…16 GB of RAM in 2026 are `gemma3:12b` by Google (12B, 8.1GB) and `llama3.1:8b` by Meta (8B, 4.9 GB). See also: [ollama.com/models](https://ollama.com/models). and [canirun.ai](https://www.canirun.ai)
## Example
