SkillsApr 2, 2026·2 min read

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.

TL;DR
gptme lets you chat with an AI that writes code and runs commands from your terminal.
§01

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.

§02

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.

§03

How to use

  1. Install gptme via pip and set your API key:
pip install gptme
export OPENAI_API_KEY='sk-...'
# Or: export ANTHROPIC_API_KEY='sk-ant-...'
  1. Start a conversation with a task:
gptme 'Create a Python script that scrapes HN top stories'
  1. 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'
§04

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'
§05

Related on TokRepo

§06

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

What LLM providers does gptme support?+

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.

Can gptme execute code on my machine?+

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.

How does gptme handle conversation persistence?+

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.

Is gptme suitable for production automation?+

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.

How does gptme compare to Claude Code or Aider?+

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)
🙏

Source & Thanks

Created by Erik Bjare. Licensed under MIT.

gptme — ⭐ 3,700+

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets