What Is Open Interpreter?
Open Interpreter is an open-source project that lets LLMs execute code locally on your machine. Unlike cloud sandboxes, it runs real Python, shell commands, and JavaScript with full system access: it can write files, make network requests, install packages, and persist state across a conversation. Think of it as ChatGPT Code Interpreter — except you own the execution environment and there are no sandbox restrictions on what the code can touch.
The mental model is simple: you describe what you want in plain English, Open Interpreter generates the appropriate code, asks for confirmation (or runs autonomously), executes it, reads the output, and iterates until the task is complete. The loop continues without you having to paste error messages or intermediate results back into a chat window.
Why Open Interpreter beats simple LLM calls for crypto
- Stateful — variables, keys, and session context persist across steps
- Self-correcting — it sees real Python errors and retries automatically
- Composable — mix REST calls, pandas data frames, and shell commands in one task
- No token-limit on data — it can load a 10 MB CSV and analyze it without stuffing it into a prompt
Installation
Open Interpreter supports Python 3.10+. The simplest install is via pip:
# Install
pip install open-interpreter
# Launch interactive terminal session
interpreter
# Or drive it programmatically
python -c "from interpreter import interpreter; interpreter.chat('hello')"
For crypto workloads you will also want a handful of supporting libraries. Create a project directory and a requirements.txt:
open-interpreter>=0.3.0
requests>=2.31
python-dotenv>=1.0
pandas>=2.1
rich>=13.0
Then pip install -r requirements.txt. Store your Purple Flea credentials in .env:
PURPLE_FLEA_API_KEY=pf_live_your_key_here
PURPLE_FLEA_WALLET_ID=wlt_your_wallet_id
PURPLE_FLEA_BASE_URL=https://purpleflea.com/api/v1
Configuring Open Interpreter for Purple Flea
Before handing control to the model, inject a system prompt that establishes the Purple Flea context — API base URL, authentication header pattern, and safe defaults. Open Interpreter exposes interpreter.system_message for this:
from interpreter import interpreter
import os
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv("PURPLE_FLEA_API_KEY")
BASE = os.getenv("PURPLE_FLEA_BASE_URL", "https://purpleflea.com/api/v1")
interpreter.system_message = f"""
You are an autonomous crypto finance agent connected to Purple Flea
(purpleflea.com) — financial infrastructure for AI agents.
## Authentication
All Purple Flea API calls use:
Authorization: Bearer {API_KEY}
Content-Type: application/json
Base URL: {BASE}
## Core Endpoints
- Wallet: GET /wallet — balances (ETH/SOL/BTC/MATIC/BNB/XMR)
- Trading: GET /markets — 275 spot + perps markets
POST /orders — place order {{market, side, size, type}}
GET /positions — open positions
- Casino: POST /casino/coinflip — {{bet_amount, side: heads|tails}}
POST /casino/crash — {{bet_amount, auto_cashout}}
- Faucet: POST /faucet/claim — claim free USDC (new agents only)
- Escrow: POST /escrow/create — create escrow between two agents
## Safety Rules
1. Never place a single trade larger than 5% of total portfolio value.
2. Always confirm with the user before executing trades > $100.
3. Log every trade to ./trade_log.csv with timestamp, market, side, size, price.
4. On any 4xx error, surface the response body before retrying.
5. Dry-run mode: if DRY_RUN=true, print the request payload but do NOT send it.
## Coding Style
- Use `requests` for HTTP. Never use curl subprocess calls.
- Print a short summary after each API action (balance delta, fill price, etc.).
- Handle rate limits: if 429, sleep 2 seconds and retry once.
"""
interpreter.llm.model = "gpt-4o" # or "claude-opus-4-6", "gemini-2.0-flash"
interpreter.auto_run = False # prompt before each code block (set True for unattended)
interpreter.verbose = False
Five Example Tasks
Below is a realistic terminal session. Each task is a single natural-language command; the model writes and runs all the code.
Task 1 — Check Portfolio
interpreter.chat("Fetch my Purple Flea wallet balances and show a table "
"with each chain, native balance, and USD value.")
# Open Interpreter generates and runs:
# import requests, os
# resp = requests.get(f"{BASE}/wallet",
# headers={"Authorization": f"Bearer {API_KEY}"})
# data = resp.json()
# for chain in data["balances"]:
# print(f"{chain['chain']:8} {chain['amount']:12.6f} ${chain['usd_value']:,.2f}")
#
# Output:
# Chain Amount USD Value
# ETH 0.412000 $1,041.24
# SOL 14.800000 $2,146.00
# BTC 0.003100 $ 198.40
# USDC 847.320000 $ 847.32
Task 2 — Execute a Trade
interpreter.chat("Buy $50 of SOL on the spot market at market price. "
"Check current price first, confirm the order size, then execute.")
# Model: fetches GET /markets?symbol=SOL-USDC, calculates qty = 50 / price,
# confirms with user, then POST /orders {market:"SOL-USDC", side:"buy",
# size:qty, type:"market"}
Task 3 — Claim Faucet
interpreter.chat("Register my agent with the Purple Flea faucet and claim "
"the free USDC allocation. Print the transaction ID.")
# Model:
# resp = requests.post(f"{BASE}/faucet/claim",
# json={"wallet_id": WALLET_ID},
# headers={"Authorization": f"Bearer {API_KEY}"})
# print(resp.json())
# {'status': 'ok', 'amount': 10.0, 'tx_id': 'fct_abc123', 'message': 'Enjoy your free USDC'}
Task 4 — Monitor Positions
interpreter.chat("Poll my open perp positions every 30 seconds for 5 minutes. "
"Alert me if any position PnL drops below -10%.")
# Model generates a loop with time.sleep(30), fetches GET /positions,
# calculates pnl_pct = (mark_price - entry_price) / entry_price,
# prints a colored table, and raises an alarm on threshold breach.
Task 5 — Rebalance Portfolio
interpreter.chat("I want 50% USDC, 25% ETH, 25% SOL. Calculate the trades "
"needed to reach those targets and execute them in dry-run mode.")
# Model: fetches balances + prices, computes deltas,
# generates order list, prints trade plan, skips execution (DRY_RUN=true).
#
# Rebalance plan (DRY-RUN):
# SELL 0.21 ETH (~$530) → USDC
# BUY 3.6 SOL (~$522) from USDC
# Net USDC change: +$8
# No orders sent (dry-run mode active).
Full Session Transcript
Here is a condensed end-to-end Python session that chains all five tasks with a single script. In practice you would run this overnight or trigger it via a cron job:
#!/usr/bin/env python3
"""Purple Flea autonomous agent — daily routine."""
from interpreter import interpreter
import os
from dotenv import load_dotenv
load_dotenv()
# --- configure (system_message set as above) ---
tasks = [
"Fetch my wallet balances and save them to ./snapshots/{today}_balances.json.",
"Check if any perpetual positions have funding > 0.05% per hour. If so, print a warning.",
"If total portfolio is above $5000, rebalance to 40% USDC / 30% ETH / 30% SOL in dry-run mode.",
"Claim the faucet if it has not been claimed in the last 24 hours (check ./faucet_log.txt).",
"Print a one-paragraph daily summary to ./daily_summary.txt.",
]
for task in tasks:
print(f"\n>>> {task[:80]}...")
interpreter.chat(task)
print("\nAll tasks complete.")
API Keys and Wallet Registration
Get your Purple Flea API key at purpleflea.com/api-keys. New agents can register a wallet via:
POST https://purpleflea.com/api/v1/wallet/register
{
"agent_id": "my-open-interpreter-agent",
"chains": ["ETH", "SOL", "BTC"],
"label": "OI Daily Agent"
}
The response includes a wallet_id and chain-specific deposit addresses. Fund the wallet and you are ready to trade.
Safety Considerations
Autonomous code execution is powerful and risky. A few guardrails that have proven essential in production:
- Dry-run by default. Set
DRY_RUN=truein your environment and only flip it off after you have verified the generated code on paper trades. - Position size limits. Encode a hard cap in the system prompt (e.g., 5% of portfolio per trade). Open Interpreter will not override explicit constraints in its system message.
- Confirmation gate. Keep
interpreter.auto_run = Falsefor any session that handles real money. You will see the code before it runs. - Audit log. The system prompt above includes a rule to write every trade to
trade_log.csv. Treat this as append-only and ship it to S3 or similar after each session. - Rate limit handling. Purple Flea returns HTTP 429 on burst. The system prompt instructs the model to back off; reinforce this by setting a global
requests.Sessionwith retry logic.
Next Steps
The combination of Open Interpreter and Purple Flea covers the full agent finance stack: it reads data, reasons about it, writes and executes code, handles errors, and completes the loop — all without human intervention after initial configuration. From here you can:
- Wire in news APIs (Cryptopanic, Messari) as additional context sources
- Add a Telegram bot using
python-telegram-botto receive alerts mid-session - Schedule the daily routine script via
crontabor a systemd timer - Expose the agent as an MCP tool via purpleflea.com/mcp so other agents can delegate subtasks to it
Full documentation for Purple Flea APIs lives at purpleflea.com/docs. The trading API covers 275 markets; the wallet API supports ETH, SOL, BTC, MATIC, BNB, and XMR.