gptme/gptme · 上手攻略

  • 仓库:gptme/gptme
  • 链接:https://github.com/gptme/gptme
  • 分类:ai-agent · terminal · coding-agent
  • 作者:Tom
  • 更新:2026-08-19

是什么

gptme(发音像 "GPT-mee")是一个运行在终端里的 AI 编程 Agent,配备本地工具集:写代码、执行命令、浏览网页、操作文件。你可以在自己的笔记本、SSH 会话、tmux、headless 服务器甚至 CI 流水线里运行它。定位是通用型终端 AI Agent,既是一个强大的编程助手,也可以处理各种知识工作。完全开源,支持 Anthropic、OpenAI、Google、xAI、DeepSeek、OpenRouter 或完全本地 llama.cpp 模型。

v0.32(2026-07)为当前稳定版,支持桌面应用(Linux AppImage / macOS / Windows)、自更新,以及 gptme.ai 云服务。


解决什么问题

  • 痛点:Claude Code/Cursor 等闭源或 IDE 绑定;需要本地优先、数据自主、不想被云服务绑定的开发者
  • 解决:pipx 一行安装,终端即用;Provider 可插拔;本地模型零成本无限用
  • 差异点:首批 Agent CLI 之一(2023 年 3 月),持续活跃开发;支持多 Agent 并发本地优先,不需要 API Key 也可用 Ollama

快速安装

一键安装(推荐)

curl -sSf https://gptme.ai/install.sh | sh

自动检测 uv 或 pipx 安装,含浏览器支持。参数 --help 查看选项(--dev--extras--no-extras--yes)。

手动安装

pipx install gptme
# 或
uv tool install gptme

⚠️ Windows 不直接支持,推荐用 WSL 或 Docker。

系统依赖

部分工具(playwright、tmux、gh 等)需要额外系统依赖,详见官方系统依赖文档


核心用法

启动对话

gptme

首次运行若未配置 API Key,会提示输入并自动保存到配置文件。

指定模型

# 使用本地 Ollama 模型(需先安装 Ollama)
export OPENAI_BASE_URL="http://127.0.0.1:11434/v1"
gptme "hello" -m local/llama3.2:1b

# 使用更大模型提升编程效果
ollama pull llama3.1:8b
gptme -m local/llama3.1:8b

常用命令示例

# 创建应用/游戏
gptme 'write a web app to particles.html with impressive colorful particle effect using three.js'
gptme 'create a performant n-body simulation in rust'

# 文件处理
gptme 'summarize this' README.md
gptme 'refactor this' main.py
gptme 'what do you see?' image.png   # 视觉理解

# 开发工作流
git status -vv | gptme 'commit'
make test | gptme 'fix the failing tests'
gptme 'implement this' https://github.com/gptme/gptme/issues/286

# 链式任务
gptme 'make a change' - 'test it' - 'commit it'

# 恢复会话
gptme -r

支持的 LLM Provider

Provider 环境变量 说明
Anthropic ANTHROPIC_API_KEY Claude 系列
OpenAI OPENAI_API_KEY GPT 系列
Google GEMINI_API_KEY Gemini 系列
xAI XAI_API_KEY Grok 系列
DeepSeek DEEPSEEK_API_KEY DeepSeek 系列
OpenRouter OPENROUTER_API_KEY 100+ 模型网关
llama.cpp 本地服务 完全本地

内置工具一览

工具 功能
shell 直接在终端执行 Shell 命令
ipython 运行 Python(可访问已安装库)
read 读文件和目录
save/append 创建或更新文件
patch/morph 对已有文件做增量修改
browser 通过 Playwright 搜索和浏览网页
vision 理解图片、桌面截图、网页截图
screenshot 捕获桌面截图
rag 本地文件检索增强(RAG)
gh 通过 GitHub CLI 操作 GitHub
tmux 在持久 tmux 会话中运行长命令
computer 完整桌面访问,操控 GUI 应用
subagent 派生子 Agent 并行或隔离任务
chats 引用和搜索历史对话

扩展机制

插件(Python 包,自定义工具/钩子/命令):

# gptme.toml
[plugins]
paths = ["~/.config/gptme/plugins", "./plugins"]
enabled = ["my_plugin"]

Skills(轻量工作流包,Anthropic 格式,提及即自动加载):

Lessons(基于关键词/工具/模式自动注入上下文指引,可自建团队知识库)。

MCP 支持:发现并动态加载任意 MCP 服务器,访问数据库、API、文件系统等。

自托管 Web UI

# 本地自托管 gptme Web UI
gptme --web
# 或访问 chat.gptme.org(官方托管)

典型适用场景

  1. 本地编程 Agent:不想用 API Key,用 Ollama 完全本地跑 Llama 代码助手
  2. SSH/CI 流水线:在远程服务器或 CI 里用 gptme 做自动化任务(审查 PR、修复测试、部署)
  3. 持久多 Agent:用 gptme-agent-template 搭建长期运行的自主 Agent(参考实现 Bob,持续 2024 年底运行至今)
  4. Zed/JetBrains 编辑器集成:通过 ACP 协议作为嵌入式编码 Agent
  5. 隐私敏感场景:数据不经过任何云服务,本地模型+本地文件 RAG

坑与注意

  • ⚠️ Windows 需要 WSL:gptme 不直接支持 Windows 原生,推荐 WSL2 内运行
  • ⚠️ 本地模型效果有限:Ollama llama3.2:1b 适合简单任务,复杂编程任务建议用 Claude/GPT-4o 等大模型
  • ⚠️ Playwright 依赖:browser 工具需要 playwright 系统依赖,首次安装较慢
  • ⚠️ 自建 Agent 需要配置:gptme-agent-template 提供了完整脚手架,但有一定学习曲线
  • 桌面应用(v0.32 新增)仅支持 Linux AppImage/macOS/Windows,Linux AppImage 需要 glibc 2.31+(⚠️ Ubuntu 20.04+ 可用,18.04 可能不兼容)

与同类对比

gptme Claude Code Cursor Jan
环境 任意终端 终端 IDE(需付费) 桌面应用
自主 Agent ✅ 多 Agent 并发
本地优先 ✅ 完全本地 ❌ 需 API ❌ 需 API
Provider 数 100+(含本地) Anthropic 为主 Anthropic/OpenAI/Google 本地模型为主
起步时间 2023 年 3 月 2024 年 2024 年 2024 年
开源 ✅ MIT

gptme 的核心优势是本地优先 + 多 Provider + 多 Agent 并发,适合不想被单一云服务绑定、追求数据自主的开发者。


一句话推荐结论

需要一个完全本地、可跑在 SSH/CI/树莓派上的终端 AI 编程 Agent?gptme 是目前开源生态里灵活性最高的选择,pipx 一行装好,支持 100+ 模型和多 Agent 并发。


  • 来源:https://github.com/gptme/gptme(README)· https://gptme.org/docs/getting-started · https://gptme.org
  • ⚠️ 版本标注:本文基于 v0.32.1(2026-07);获取最新版本建议 pipx install gptme 重新安装或查 GitHub Releases