gptme — AI Agent in Your Terminal
Personal AI assistant that writes code, runs commands, browses the web, and builds persistent agents. In your terminal. 3.7K+ stars.
What it is
gptme is an open-source personal AI assistant that operates entirely inside your terminal. It connects to OpenAI, Anthropic, or local models and can write code, run shell commands, browse the web, and manage files. Unlike cloud-based AI assistants, gptme keeps everything local and transparent.
It targets developers who want an AI pair programmer without leaving the command line. If you prefer terminals over GUIs and want full control over what the AI executes, gptme fits that workflow.
How it saves time or tokens
gptme reduces context-switching by keeping the AI conversation, code editing, and command execution in a single terminal session. Instead of copying code between a chat window and your editor, gptme writes files and runs commands directly. The tool logs all conversations to a local SQLite database, so you can resume sessions and avoid re-explaining context. Token usage stays efficient because gptme streams responses and only sends relevant context.
How to use
- Install gptme via pip and set your API key:
pip install gptme
export OPENAI_API_KEY='sk-...'
# Or: export ANTHROPIC_API_KEY='sk-ant-...'
- Start a conversation with a task:
gptme 'Create a Python script that scrapes HN top stories'
- Resume a previous conversation or use specific features:
# Resume last conversation
gptme --resume
# Use a specific model
gptme --model anthropic/claude-sonnet 'Refactor this module'
# Non-interactive mode for scripting
gptme --non-interactive 'Write tests for app.py'
Example
# Start gptme and ask it to build a web scraper
gptme 'Build a Python web scraper that extracts titles from news.ycombinator.com'
# gptme will:
# 1. Write a Python script with requests + BeautifulSoup
# 2. Save it to a file
# 3. Run it and show you the output
# 4. Fix any errors automatically
# You can then follow up:
# > 'Add error handling and save results to CSV'
Related on TokRepo
- AI coding tools -- Browse other AI-powered development tools
- CLI and automation tools -- More command-line AI utilities
Common pitfalls
- gptme executes commands on your real system by default. Use the sandbox mode or Docker integration for untrusted tasks to avoid accidental file modifications.
- API key management matters. If you switch between providers frequently, use environment variables or gptme's built-in key management rather than hardcoding keys.
- Large codebases can exhaust context windows quickly. Break tasks into smaller, focused requests rather than asking gptme to refactor an entire project at once.
Frequently Asked Questions
gptme supports OpenAI (GPT-4, GPT-4o), Anthropic (Claude), and local models through compatible APIs. You configure the provider by setting the appropriate API key environment variable or using the --model flag to specify a model like anthropic/claude-sonnet or openai/gpt-4o.
Yes. gptme can write files, run shell commands, and execute Python code directly on your system. It asks for confirmation before running commands by default. For safety, you can enable sandbox mode or run gptme inside a Docker container to isolate its actions from your host system.
gptme stores all conversations in a local SQLite database. You can resume any previous conversation with the --resume flag, which restores the full context. This avoids repeating setup instructions and saves tokens on subsequent interactions.
gptme supports a non-interactive mode (--non-interactive) designed for scripting and CI/CD pipelines. You can pipe tasks to it and capture output programmatically. However, for critical production workflows, add error handling around gptme invocations and review generated code before deployment.
gptme focuses on being a general-purpose terminal AI agent that goes beyond code editing. It can browse the web, run arbitrary commands, and manage files. Claude Code is tightly integrated with Anthropic models, while Aider specializes in git-aware code editing. gptme offers broader system access but requires more caution with permissions.
Citations (3)
- gptme GitHub Repository— gptme is an open-source personal AI assistant for the terminal
- gptme Documentation— gptme supports OpenAI, Anthropic, and local model providers
- Anthropic Tool Use Documentation— Tool-augmented LLM agents can execute code and interact with external systems
Related on TokRepo
Source & Thanks
Created by Erik Bjare. Licensed under MIT.
gptme — ⭐ 3,700+
Discussion
Related Assets
Claude-Flow — Multi-Agent Orchestration for Claude Code
Layers swarm and hive-mind multi-agent orchestration on top of Claude Code with 64 specialized agents, SQLite memory, and parallel execution.
ccusage — Real-Time Token Cost Tracker for Claude Code
CLI that reads ~/.claude logs and breaks down Claude Code token spend by day, session, and project — pluggable into your statusline.
SuperClaude — Workflow Framework for Claude Code
Adds 16+ slash commands, 9 cognitive personas, and a smart flag system to Claude Code in one pipx install.