{"id":13484657,"url":"https://github.com/kharvd/gpt-cli","last_synced_at":"2025-05-14T15:03:03.003Z","repository":{"id":143548119,"uuid":"612816791","full_name":"kharvd/gpt-cli","owner":"kharvd","description":"Command-line interface for ChatGPT, Claude and Bard","archived":false,"fork":false,"pushed_at":"2025-03-23T22:08:54.000Z","size":1831,"stargazers_count":685,"open_issues_count":33,"forks_count":86,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-12T21:18:44.900Z","etag":null,"topics":["anthropic","anthropic-claude","assistant","bard","chatgpt","claude","cli","command-line","google-bard","gpt-3","gpt-4","gpt-cli","gpt-client","llm","openai","palm2"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kharvd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-12T03:54:20.000Z","updated_at":"2025-04-09T07:39:16.000Z","dependencies_parsed_at":"2024-01-27T23:39:04.364Z","dependency_job_id":"6952bdea-7b24-4688-9e53-250a9ee50b14","html_url":"https://github.com/kharvd/gpt-cli","commit_stats":{"total_commits":137,"total_committers":14,"mean_commits":9.785714285714286,"dds":"0.17518248175182483","last_synced_commit":"5f686f99654ae22d3d587644b6e6d6cc3a5442ce"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kharvd%2Fgpt-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kharvd%2Fgpt-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kharvd%2Fgpt-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kharvd%2Fgpt-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kharvd","download_url":"https://codeload.github.com/kharvd/gpt-cli/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248631798,"owners_count":21136569,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anthropic","anthropic-claude","assistant","bard","chatgpt","claude","cli","command-line","google-bard","gpt-3","gpt-4","gpt-cli","gpt-client","llm","openai","palm2"],"created_at":"2024-07-31T17:01:28.668Z","updated_at":"2025-04-12T21:18:51.656Z","avatar_url":"https://github.com/kharvd.png","language":"Python","readme":"# gpt-cli\n\nCommand-line interface for chat LLMs.\n\n## Try now\n```\nexport ANTHROPIC_API_KEY=xcxc\nuvx --from gpt-command-line gpt\n```\n\n## Supported providers\n\n- OpenAI\n- Anthropic\n- Google Gemini\n- Cohere\n- Other APIs compatible with OpenAI (e.g. Together, OpenRouter, local models with LM Studio)\n\n![screenshot](https://github.com/kharvd/gpt-cli/assets/466920/ecbcccc4-7cfa-4c04-83c3-a822b6596f01)\n\n## Features\n\n- **Command-Line Interface**: Interact with ChatGPT or Claude directly from your terminal.\n- **Model Customization**: Override the default model, temperature, and top_p values for each assistant, giving you fine-grained control over the AI's behavior.\n- **Extended Thinking Mode**: Enable Claude 3.7's extended thinking capability to see its reasoning process for complex problems.\n- **Usage tracking**: Track your API usage with token count and price information.\n- **Keyboard Shortcuts**: Use Ctrl-C, Ctrl-D, and Ctrl-R shortcuts for easier conversation management and input control.\n- **Multi-Line Input**: Enter multi-line mode for more complex queries or conversations.\n- **Markdown Support**: Enable or disable markdown formatting for chat sessions to tailor the output to your preferences.\n- **Predefined Messages**: Set up predefined messages for your custom assistants to establish context or role-play scenarios.\n- **Multiple Assistants**: Easily switch between different assistants, including general, dev, and custom assistants defined in the config file.\n- **Flexible Configuration**: Define your assistants, model parameters, and API key in a YAML configuration file, allowing for easy customization and management.\n\n## Installation\n\nThis install assumes a Linux/OSX machine with Python and pip available.\n\n```bash\npip install gpt-command-line\n```\n\nInstall latest version from source:\n\n```bash\npip install git+https://github.com/kharvd/gpt-cli.git\n```\n\nOr install by cloning the repository manually:\n\n```bash\ngit clone https://github.com/kharvd/gpt-cli.git\ncd gpt-cli\npip install .\n```\n\nAdd the OpenAI API key to your `.bashrc` file (in the root of your home folder).\nIn this example we use nano, you can use any text editor.\n\n```\nnano ~/.bashrc\nexport OPENAI_API_KEY=\u003cyour_key_here\u003e\n```\n\nRun the tool\n\n```\ngpt\n```\n\nYou can also use a `gpt.yml` file for configuration. See the [Configuration](README.md#Configuration) section below.\n\n## Usage\n\nMake sure to set the `OPENAI_API_KEY` environment variable to your OpenAI API key (or put it in the `~/.config/gpt-cli/gpt.yml` file as described below).\n\n```\nusage: gpt [-h] [--no_markdown] [--model MODEL] [--temperature TEMPERATURE] [--top_p TOP_P]\n              [--thinking THINKING_BUDGET] [--log_file LOG_FILE] \n              [--log_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [--prompt PROMPT] \n              [--execute EXECUTE] [--no_stream] [{dev,general,bash}]\n\nRun a chat session with ChatGPT. See https://github.com/kharvd/gpt-cli for more information.\n\npositional arguments:\n  {dev,general,bash}\n                        The name of assistant to use. `general` (default) is a generally helpful\n                        assistant, `dev` is a software development assistant with shorter\n                        responses. You can specify your own assistants in the config file\n                        ~/.config/gpt-cli/gpt.yml. See the README for more information.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --no_markdown         Disable markdown formatting in the chat session.\n  --model MODEL         The model to use for the chat session. Overrides the default model defined\n                        for the assistant.\n  --temperature TEMPERATURE\n                        The temperature to use for the chat session. Overrides the default\n                        temperature defined for the assistant.\n  --top_p TOP_P         The top_p to use for the chat session. Overrides the default top_p defined\n                        for the assistant.\n  --thinking THINKING_BUDGET\n                        Enable Claude's extended thinking mode with the specified token budget.\n                        Only applies to Claude 3.7 models.\n  --log_file LOG_FILE   The file to write logs to. Supports strftime format codes.\n  --log_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}\n                        The log level to use\n  --prompt PROMPT, -p PROMPT\n                        If specified, will not start an interactive chat session and instead will\n                        print the response to standard output and exit. May be specified multiple\n                        times. Use `-` to read the prompt from standard input. Implies\n                        --no_markdown.\n  --execute EXECUTE, -e EXECUTE\n                        If specified, passes the prompt to the assistant and allows the user to\n                        edit the produced shell command before executing it. Implies --no_stream.\n                        Use `-` to read the prompt from standard input.\n  --no_stream           If specified, will not stream the response to standard output. This is\n                        useful if you want to use the response in a script. Ignored when the\n                        --prompt option is not specified.\n  --no_price            Disable price logging.\n```\n\nType `:q` or Ctrl-D to exit, `:c` or Ctrl-C to clear the conversation, `:r` or Ctrl-R to re-generate the last response.\nTo enter multi-line mode, enter a backslash `\\` followed by a new line. Exit the multi-line mode by pressing ESC and then Enter.\n\nThe `dev` assistant is instructed to be an expert in software development and provide short responses.\n\n```bash\n$ gpt dev\n```\n\nThe `bash` assistant is instructed to be an expert in bash scripting and provide only bash commands. Use the `--execute` option to execute the commands. It works best with the `gpt-4` model.\n\n```bash\ngpt bash -e \"How do I list files in a directory?\"\n```\n\nThis will prompt you to edit the command in your `$EDITOR` it before executing it.\n\n## Configuration\n\nYou can configure the assistants in the config file `~/.config/gpt-cli/gpt.yml`. The file is a YAML file with the following structure (see also [config.py](./gptcli/config.py))\n\n```yaml\ndefault_assistant: \u003cassistant_name\u003e\nmarkdown: False\nopenai_api_key: \u003copenai_api_key\u003e\nanthropic_api_key: \u003canthropic_api_key\u003e\nlog_file: \u003cpath\u003e\nlog_level: \u003cDEBUG|INFO|WARNING|ERROR|CRITICAL\u003e\nassistants:\n  \u003cassistant_name\u003e:\n    model: \u003cmodel_name\u003e\n    temperature: \u003ctemperature\u003e\n    top_p: \u003ctop_p\u003e\n    thinking_budget: \u003ctoken_budget\u003e  # Claude 3.7 models only\n    messages:\n      - { role: \u003crole\u003e, content: \u003cmessage\u003e }\n      - ...\n  \u003cassistant_name\u003e:\n    ...\n```\n\nYou can override the parameters for the pre-defined assistants as well.\n\nYou can specify the default assistant to use by setting the `default_assistant` field. If you don't specify it, the default assistant is `general`. You can also specify the `model`, `temperature` and `top_p` to use for the assistant. If you don't specify them, the default values are used. These parameters can also be overridden by the command-line arguments.\n\nExample:\n\n```yaml\ndefault_assistant: dev\nmarkdown: True\nopenai_api_key: \u003copenai_api_key\u003e\nassistants:\n  pirate:\n    model: gpt-4\n    temperature: 1.0\n    messages:\n      - { role: system, content: \"You are a pirate.\" }\n```\n\n```\n$ gpt pirate\n\n\u003e Arrrr\nAhoy, matey! What be bringing ye to these here waters? Be it treasure or adventure ye seek, we be sailing the high seas together. Ready yer map and compass, for we have a long voyage ahead!\n```\n\n### Read other context to the assistant with !include\n\nYou can read in files to the assistant's context with !include \u003cfile_path\u003e.\n\n```yaml\ndefault_assistant: dev\nmarkdown: True\nopenai_api_key: \u003copenai_api_key\u003e\nassistants:\n  pirate:\n    model: gpt-4\n    temperature: 1.0\n    messages:\n      - { role: system, content: !include \"pirate.txt\" }\n```\n\n### Customize OpenAI API URL\n\nIf you are using other models compatible with the OpenAI Python SDK, you can configure them by modifying the `openai_base_url` setting in the config file or using the `OPENAI_BASE_URL` environment variable .\n\nExample:\n\n```\nopenai_base_url: https://your-custom-api-url.com/v1\n```\n\nUse `oai-compat:` prefix for the model name to pass non-GPT model names to the API. For example, to chat with Llama3-70b on [Together](https://together.ai), use the following command:\n\n```bash\nOPENAI_API_KEY=$TOGETHER_API_KEY OPENAI_BASE_URL=https://api.together.xyz/v1 gpt general --model oai-compat:meta-llama/Llama-3-70b-chat-hf\n```\n\nThe prefix is stripped before sending the request to the API.\n\nSimilarly, use the `oai-azure:` model name prefix to use a model deployed via Azure Open AI. For example, `oai-azure:my-deployment-name`.\n\nWith assistant configuration, you can override the base URL and API key for a specific assistant.\n\n```yaml\n# ~/.config/gpt-cli/gpt.yml\nassistants:\n  llama:\n    model: oai-compat:meta-llama/llama-3.3-70b-instruct\n    openai_base_url_override: https://openrouter.ai/api/v1\n    openai_api_key_override: $OPENROUTER_API_KEY\n```\n\n## Other chat bots\n\n### Anthropic Claude\n\nTo use Claude, you should have an API key from [Anthropic](https://console.anthropic.com/) (currently there is a waitlist for API access). After getting the API key, you can add an environment variable\n\n```bash\nexport ANTHROPIC_API_KEY=\u003cyour_key_here\u003e\n```\n\nor a config line in `~/.config/gpt-cli/gpt.yml`:\n\n```yaml\nanthropic_api_key: \u003cyour_key_here\u003e\n```\n\nNow you should be able to run `gpt` with `--model claude-3-(opus|sonnet|haiku)-\u003cdate\u003e`.\n\n```bash\ngpt --model claude-3-opus-20240229\n```\n\n#### Claude 3.7 Sonnet Extended Thinking Mode\n\nClaude 3.7 Sonnet supports an extended thinking mode, which shows Claude's reasoning process before delivering the final answer. This is useful for complex analysis, advanced STEM problems, and tasks with multiple constraints.\n\nEnable it with the `--thinking` parameter, specifying the token budget for the thinking process:\n\n```bash\ngpt --model claude-3-7-sonnet-20250219 --thinking 32000\n```\n\nYou can also configure thinking mode for specific assistants in your config:\n\n```yaml\nassistants:\n  math:\n    model: claude-3-7-sonnet-20250219\n    thinking_budget: 32000\n    messages:\n      - { role: system, content: \"You are a math expert.\" }\n```\n\n**Note**: When thinking mode is enabled, the temperature is automatically set to 1.0 and top_p is unset as required by the Claude API.\n\n### Google Gemini\n\n```bash\nexport GOOGLE_API_KEY=\u003cyour_key_here\u003e\n```\n\nor\n\n```yaml\ngoogle_api_key: \u003cyour_key_here\u003e\n```\n\n### Cohere\n\n```bash\nexport COHERE_API_KEY=\u003cyour_key_here\u003e\n```\n\nor\n\n```yaml\ncohere_api_key: \u003cyour_key_here\u003e\n```\n","funding_links":[],"categories":["Python","CLIs"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkharvd%2Fgpt-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkharvd%2Fgpt-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkharvd%2Fgpt-cli/lists"}