> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-zh/ai-ping-tai-yu-zhi-neng-ti/open-interpreter.md).

# Open Interpreter

**Open Interpreter** 让语言模型通过自然语言聊天界面在你的机器上运行代码、浏览网页并编辑文件。它拥有 57K+ GitHub stars，是 ChatGPT Code Interpreter 最领先的开源替代方案——而且没有沙盒限制。

{% hint style="success" %}
所有示例都可以在通过以下方式租用的 GPU 服务器上运行 [CLORE.AI 市场](https://clore.ai/marketplace).
{% endhint %}

***

## 什么是 Open Interpreter？

Open Interpreter 将 AI 编程助手的能力直接带到你的终端。你无需在 ChatGPT 和 shell 之间复制粘贴，而是直接自然对话，模型会实时执行代码：

* **运行 Python、JS、shell、R、AppleScript** — 直接在你的服务器上
* **浏览网页** — 获取页面、填写表单、提取数据
* **编辑文件** — 在磁盘上创建、修改并管理任何文件
* **持久状态** — 变量、导入项和结果会在多轮消息之间保留
* **多个 LLM 后端** — OpenAI、Anthropic、通过 Ollama/LlamaCpp 的本地模型

{% hint style="info" %}
Open Interpreter 专为希望以对话方式访问整个计算环境的开发者和研究人员而设计。在 Clore.ai GPU 服务器上，你可以获得一台拥有完整互联网访问权限且没有执行限制的强大机器。
{% endhint %}

***

## 服务器要求

| 组件     | 最低            | 推荐                       |
| ------ | ------------- | ------------------------ |
| GPU    | 任意（可用 CPU 模式） | RTX 3090 / A100 用于本地 LLM |
| 显存     | —             | 24 GB+ 用于本地 13B 模型       |
| 内存     | 8 GB          | 16 GB+                   |
| CPU    | 4 核           | 8+ 核                     |
| 存储     | 20 GB         | 50 GB+                   |
| 操作系统   | Ubuntu 20.04+ | Ubuntu 22.04             |
| Python | 3.10+         | 3.11                     |
| 网络     | 必需            | 网页浏览所需高速网络               |

***

## 端口

| 端口   | 服务                      | 备注                |
| ---- | ----------------------- | ----------------- |
| 22   | SSH                     | 终端访问，网页 UI 隧道     |
| 8000 | Open Interpreter Server | REST API 和可选网页 UI |

***

## 使用 Docker 快速开始

Open Interpreter 没有官方 Docker 镜像，所以我们构建了一个干净的镜像。这种方式让你可以在任何 Clore.ai 服务器上获得可复现、隔离的环境。

### Dockerfile

```dockerfile
FROM python:3.11-slim

# 系统依赖
RUN apt-get update && apt-get install -y \
    git \
    curl \
    wget \
    build-essential \
    nodejs \
    npm \
    chromium \
    chromium-driver \
    && rm -rf /var/lib/apt/lists/*

# 安装包含所有扩展功能的 Open Interpreter
RUN pip install --no-cache-dir \
    open-interpreter \
    'open-interpreter[local]' \
    playwright \
    jupyter

# 安装 Playwright 浏览器
RUN playwright install chromium

WORKDIR /workspace

# 暴露服务器端口
EXPOSE 8000

# 默认：交互式终端
CMD ["interpreter"]
```

### 构建并运行

```bash
# 构建镜像
docker build -t open-interpreter:latest .

# 运行交互模式（终端聊天）
docker run -it --rm \
  -e OPENAI_API_KEY=sk-... \
  -v $(pwd)/workspace:/workspace \
  open-interpreter:latest

# 作为 REST API 服务器运行
docker run -d \\
  --name open-interpreter \
  -p 8000:8000 \
  -e OPENAI_API_KEY=sk-... \
  -v $(pwd)/workspace:/workspace \
  open-interpreter:latest \
  interpreter --server --port 8000 --host 0.0.0.0
```

***

## 在 Clore.ai 上安装（裸机）

如果你更喜欢直接在 Clore.ai 服务器上运行而不使用 Docker：

### 步骤 1 — 租用服务器

1. 前往 [Clore.ai 市场](https://clore.ai/marketplace)
2. 筛选条件 **RAM ≥ 16 GB**, **GPU** （可选，但对本地模型很有用）
3. 选择一台带有 **PyTorch** 或 **Ubuntu** 基础镜像
4. 打开 **SSH 22 端口** 并且可选地 **8000** 在你的订单中

### 步骤 2 — 通过 SSH 连接

```bash
ssh root@<server-ip> -p <ssh-port>
```

### 步骤 3 — 安装依赖

```bash
# 更新系统
apt-get update && apt-get upgrade -y

# 安装 Python 3.11
apt-get install -y python3.11 python3.11-venv python3.11-pip nodejs npm curl

# 创建虚拟环境
python3.11 -m venv /opt/open-interpreter
source /opt/open-interpreter/bin/activate
```

### 步骤 4 — 安装 Open Interpreter

```bash
# 基础安装
pip install open-interpreter

# 启用本地 LLM 支持（Ollama、LlamaCpp）
pip install 'open-interpreter[local]'

# 启用浏览器/网页支持
pip install playwright
playwright install chromium
```

### 步骤 5 — 配置 API 密钥

```bash
# 设置环境变量（如需持久化，可添加到 ~/.bashrc）
export OPENAI_API_KEY=sk-your-key-here
export ANTHROPIC_API_KEY=sk-ant-your-key-here

# 或者使用 .env 文件
cat > /workspace/.env << 'EOF'
OPENAI_API_KEY=sk-your-key-here
ANTHROPIC_API_KEY=sk-ant-your-key-here
EOF
```

### 步骤 6 — 首次运行

```bash
# 激活环境
source /opt/open-interpreter/bin/activate

# 启动交互式聊天
interpreter

# 或使用特定模型
interpreter --model gpt-4o
interpreter --model claude-3-5-sonnet-20241022
```

***

## 使用本地 LLM（无需 API 密钥）

Open Interpreter 在 Clore.ai GPU 服务器上的一个杀手级功能就是可以完全运行本地模型：

### 选项 A：Ollama 后端

```bash
# 安装 Ollama
curl -fsSL https://ollama.ai/install.sh | sh

# 拉取一个具备代码能力的模型
ollama pull codellama:13b
ollama pull deepseek-coder:6.7b
ollama pull mistral:7b

# 使用 Ollama 运行 Open Interpreter
interpreter --model ollama/codellama:13b
```

### 选项 B：LlamaCpp 后端

```bash
# 安装带 CUDA 支持的 llama-cpp-python
pip install 'llama-cpp-python[server]' --extra-index-url https://jllllll.github.io/llama-cpp-python-cuBLAS-wheels/AVX2/cu121

# 下载一个 GGUF 模型
wget https://huggingface.co/TheBloke/CodeLlama-13B-GGUF/resolve/main/codellama-13b.Q4_K_M.gguf

# 使用本地模型运行
interpreter --local --model /path/to/codellama-13b.Q4_K_M.gguf
```

***

## 作为服务器运行（REST API）

Open Interpreter 0.2+ 包含一个内置 HTTP 服务器，便于程序化访问：

```bash
# 启动服务器
interpreter --server --port 8000 --host 0.0.0.0

# 在另一个终端或客户端中发送请求：
curl -X POST http://<server-ip>:8000/run \
  -H "Content-Type: application/json" \\
  -d '{"language": "python", "code": "import os; print(os.listdir(\".\"))"}'

# 聊天端点
curl -X POST http://<server-ip>:8000/chat \
  -H "Content-Type: application/json" \\
  -d '{"message": "列出 /workspace 中所有 Python 文件并统计代码行数"}'
```

### 用于本地访问的 SSH 隧道

如果端口 8000 没有公开暴露，请使用 SSH 隧道：

```bash
# 在你的本地机器上
ssh -L 8000:localhost:8000 root@<server-ip> -p <ssh-port> -N
# 然后打开 http://localhost:8000
```

***

## 实用示例

### 示例 1：数据分析流水线

```
用户：下载 MNIST 数据集，训练一个简单的 CNN，并绘制准确率曲线。将图表保存为 mnist_results.png

Open Interpreter：当然！我会一步一步来...
[实时执行 Python 代码]
```

```python
# Open Interpreter 生成并运行：
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np

(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
# ... 训练模型、绘制结果、保存 PNG
```

### 示例 2：网页抓取

```
用户：抓取今天 GitHub 上前 10 个趋势仓库，并将它们保存到一个包含名称、stars 和描述的 CSV 文件中。
```

### 示例 3：文件管理

```
用户：查找 /var/log 中所有 7 天前的 .log 文件，并将它们压缩到 /backup/logs-$(date).tar.gz 的 tar 包中。
```

### 示例 4：系统监控脚本

```
用户：帮我写一个 Python 脚本，每 5 秒监控一次 GPU 显存使用情况，并在超过 90% 时发出警报。请在后台运行它。
```

***

## 配置文件

创建 `~/.interpreter/config.yaml` 用于设置默认值：

```yaml
model: gpt-4o
temperature: 0
system_message: |
  你是一个在 Clore.ai GPU 服务器上运行的有帮助的 AI 助手。
  始终优先使用高效、适合生产环境的代码。
  将重要输出保存到 /workspace/。
safe_mode: false
auto_run: true
verbose: false
```

***

## 使用 systemd 运行（持久化服务）

```ini
# /etc/systemd/system/open-interpreter.service
[Unit]
Description=Open Interpreter 服务器
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/workspace
Environment=OPENAI_API_KEY=sk-your-key
ExecStart=/opt/open-interpreter/bin/interpreter --server --port 8000 --host 0.0.0.0
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target
```

```bash
systemctl daemon-reload
systemctl enable open-interpreter
systemctl start open-interpreter
systemctl status open-interpreter
```

***

## 故障排查

### `interpreter` 未找到命令

```bash
# 确保虚拟环境已激活
source /opt/open-interpreter/bin/activate

# 或全局安装
pip install open-interpreter

# 检查 PATH
which interpreter
echo $PATH
```

### 代码执行被阻止 / 安全模式

```bash
# 禁用安全模式（仅在可信服务器上谨慎使用）
interpreter --safe_mode false

# 或在 config.yaml 中：
# safe_mode: false
# auto_run: true
```

### Playwright / 浏览器错误

```bash
# 为 Chromium 安装系统依赖
apt-get install -y \
    libnss3 libatk1.0-0 libatk-bridge2.0-0 \
    libcups2 libxcomposite1 libxdamage1 \
    libxrandr2 libgbm1 libxkbcommon0

playwright install chromium
playwright install-deps
```

### 本地 LLM 内存不足

```bash
# 使用更小的量化模型
ollama pull codellama:7b  # 而不是 13b

# 或减少上下文窗口
interpreter --model ollama/codellama:7b --context_window 4096
```

### 8000 端口连接被拒绝

```bash
# 检查服务器是否正在运行
ss -tlnp | grep 8000

# 检查防火墙
ufw allow 8000/tcp

# 重启服务
systemctl restart open-interpreter
```

### API 速率限制

```bash
# 切换到 Anthropic Claude 以获得更高限制
export ANTHROPIC_API_KEY=sk-ant-...
interpreter --model claude-3-5-sonnet-20241022

# 或使用本地模型，完全避免 API 限制
interpreter --model ollama/codellama:13b
```

***

## 安全注意事项

{% hint style="warning" %}
Open Interpreter 会直接在你的服务器上执行代码。始终：

* 生产环境请在 Docker 容器或 VM 中运行
* 切勿在没有认证的情况下公开暴露 8000 端口
* 远程访问请使用 SSH 隧道
* 在启用之前审查代码 `auto_run: true` 对于不受信任的输入
  {% endhint %}

***

## Clore.ai GPU 推荐

Open Interpreter 本身很轻量——GPU 需求取决于你作为后端运行的 **本地模型** 。

| GPU       | 显存    | Clore.ai 价格                       | 本地模型推荐                                                   |
| --------- | ----- | --------------------------------- | -------------------------------------------------------- |
| RTX 3090  | 24 GB | $0.07–0.21/小时                     | CodeLlama 13B Q8、Llama 3 8B、Mistral 7B —— 扎实的编码质量        |
| RTX 4090  | 24 GB | $0.14–0.42/小时                     | CodeLlama 34B Q4、DeepSeek Coder 33B Q4 —— 接近 GPT-4 的编码质量 |
| A100 40GB | 40 GB | [裸机](https://clore.ai/bare-metal) | Llama 3 70B Q4 —— 生产级自主编码代理                              |
| 仅 CPU     | —     | 约 $0.02/小时                        | 通过 OpenAI/Anthropic API 使用任意模型——无需本地 GPU                 |

{% hint style="info" %}
**如果你使用 OpenAI/Anthropic API：** 你只需要一台 CPU 实例（约 $0.02/小时）——由于推理在云端运行，GPU 并不重要。只有在运行 **本地模型** 以避免按 token 计费的 API 成本时，才选择 GPU 实例。

**最佳本地模型配置：** RTX 3090 + 运行中的 Ollama `codellama:13b` 让你以 $0.07–0.21/小时获得一个完全自主、保护隐私且没有 API 成本的编程代理。
{% endhint %}

***

## 有用链接

* **GitHub**: <https://github.com/OpenInterpreter/open-interpreter> ⭐ 57K+
* **文档**: <https://docs.openinterpreter.com>
* **Discord**: <https://discord.gg/Hvz9Axh84z>
* **Clore.ai 市场**: <https://clore.ai/marketplace>
* **Ollama 模型**: <https://ollama.ai/library>
* **HuggingFace GGUF 模型**: <https://huggingface.co/TheBloke>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-zh/ai-ping-tai-yu-zhi-neng-ti/open-interpreter.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
