Command-line interface for querying large language models
pip install llm-cli
# basic query
llm-cli "explain recursion in python"
# specify model
llm-cli --model gpt-4 "write a haiku about debugging"
# streaming output
llm-cli --stream "tell me a story"
# read from stdin
cat input.txt | llm-cli --stdin
# save to file
llm-cli "generate test data" > output.json
# set temperature
llm-cli --temperature 0.2 "what is 2+2"
# multi-line input
llm-cli --multiline
> first line
> second line
> ^D| flag | description | default |
|---|---|---|
--model, -m |
model to use | gpt-3.5-turbo |
--temperature, -t |
sampling temperature (0.0-2.0) | 0.7 |
--max-tokens |
maximum response length | 2048 |
--stream, -s |
stream output token by token | false |
--stdin |
read prompt from stdin | false |
--multiline |
enable multi-line input mode | false |
--system |
system prompt | null |
--api-key |
api key (or use env var) | $LLM_API_KEY |
export LLM_API_KEY="your-api-key"
export LLM_DEFAULT_MODEL="gpt-4"
export LLM_API_BASE="https://api.openai.com/v1"Create ~/.llm-cli/config.json:
{
"default_model": "gpt-3.5-turbo",
"temperature": 0.7,
"max_tokens": 2048,
"api_key": "your-api-key"
}- OpenAI:
gpt-4,gpt-3.5-turbo - Anthropic:
claude-3-opus,claude-3-sonnet - Local:
ollama/llama2,ollama/mistral
prs welcome. open an issue first for big changes.
MIT