Python client library that wraps multiple AI provider APIs behind one simple interface for text, structured data, and conversations.
tbckr/sgpt
A Go command-line tool for querying OpenAI-compatible LLMs from the terminal, generating shell commands, code, and images.
- Stars
- 461
- Forks
- 34
- Open issues
- 3
- Last commit
- 5 days ago
What is it?
SGPT (also known as shell-gpt) is a command-line client for OpenAI models that lets you send questions, generate shell commands or code, and run chat sessions without leaving the terminal. Queries can be passed as arguments or piped in through stdin, and responses can be streamed as they are generated.
Beyond plain questions, SGPT offers personas such as sh for shell commands and code for code generation, with an option to execute a generated command directly after confirmation. It supports image input for vision-capable models, named chat sessions, and Go text/template prompt templating fed by YAML or JSON data. Bash aliases and functions can wrap it into everyday workflows.
SGPT works with OpenAI's API and any OpenAI-compatible endpoint, including OpenRouter, Requesty, Google Gemini's compatibility layer, and local backends such as Ollama, LiteLLM, vLLM, and llama.cpp, selected via the OPENAI_API_BASE variable. It is distributed through Homebrew, Scoop, Go install, Docker, and GitHub releases.
Key features
- 01Send one-off queries from arguments or piped stdin, with optional streaming output.
- 02Generate shell commands with the sh persona and optionally execute them after confirmation.
- 03Generate code snippets with the code persona.
- 04Attach local or URL images for vision-capable models.
- 05Keep named multi-turn chat sessions with --chat.
- 06Use Go text/template prompts filled with YAML or JSON data from stdin.
Use cases
- Looking up a quick answer or command syntax without opening a browser.
- Turning a plain-English task description into a shell one-liner and running it.
- Drafting a code snippet in an unfamiliar language from the terminal.
- Scripting repeatable prompts with bash aliases, functions, or templates.
Quick start
- 1
Install via Homebrew (macOS)
brew install tbckr/tap/sgpt - 2
Or install with Go
go install github.com/tbckr/sgpt/v2/cmd/sgpt@latest - 3
Set your OpenAI API key in your shell profile
- 4
Ask a question
sgpt "mass of sun"
Things to know
- Requires an OpenAI-compatible API key to function.
- The README notes that GPT-4o and vision API integration is in beta and may change.
- Go implementation; issues for the original Python shell-gpt should go elsewhere.
In collections
Topics
FAQ
- What is sgpt?
- A Go command-line tool for querying OpenAI-compatible LLMs from the terminal, generating shell commands, code, and images. SGPT (also known as shell-gpt) is a command-line client for OpenAI models that lets you send questions, generate shell commands or code, and run chat sessions without leaving the terminal. Queries can be passed as arguments or piped in through stdin, and responses can be streamed as they are generated.
- Is sgpt free to use? What license does it have?
- sgpt is open source under the MIT license. Check the license terms before using it in commercial products.
- Is sgpt still maintained?
- Actively maintained. The last commit to sgpt was on Nov 3, 2026.
- What can I use sgpt for?
- Looking up a quick answer or command syntax without opening a browser. Turning a plain-English task description into a shell one-liner and running it. Drafting a code snippet in an unfamiliar language from the terminal. Scripting repeatable prompts with bash aliases, functions, or templates.
- How do I install sgpt?
- Install via Homebrew (macOS): brew install tbckr/tap/sgpt Or install with Go: go install github.com/tbckr/sgpt/v2/cmd/sgpt@latest Set your OpenAI API key in your shell profile Ask a question: sgpt "mass of sun"
- Where can I get sgpt?
- The source code and installation instructions are on GitHub: https://github.com/tbckr/sgpt
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Ruby library for adding discrete LLM components to Ruby apps, with chat completions, tool calling, prompt chains and structured output.
AI code assistant plugin for Vim and Neovim that generates, edits and chats with OpenAI-compatible models from inside the editor.
A Python library that generates function implementations with an LLM at runtime, based on function names, arguments, and context, powered by OpenAI.
A multi-provider command-line client for ChatGPT-style LLMs, supporting OpenAI, Azure, Perplexity and LLaMA endpoints with streaming, interactive chat and agent mode.
A terminal CLI for chatting with OpenAI's GPT-3.5 and GPT-4 models, with interactive chat mode and pipeline support.