Write-and-run code & back-office batch jobs
Use case #5 · every command below was run as shown on a CPU-only production server (32-vCPU arm, 4B model) — timings are from those runs.
writes AND executesiterates to green66 s measuredknow the limits
The agent writes a script against your data, runs it, fixes what breaks, and shows the output — useful for one-off transformations and recurring back-office glue, with honest limits for bigger coding work.
Why run it locally: This is the native pi loop (write + bash). For internal data the payoff is that the script AND the data it reads stay on your box. It is also where small-model limits show first — so this page is as much about scoping as capability.
Model & hardware fit: 4B for single-shot scripts and batch glue; long autonomous coding chains want 27B + GPU or tight human review.
Setup (once, ~10 minutes)
1. The server — any install works; one line on Linux:
curl -fsSL https://inference-server.searchblox.com/install | sudo bash
2. The agent — pi, a minimal open-source coding agent (four tools: read, write, edit, bash), needs Node 22+:
npm install -g --ignore-scripts @earendil-works/pi-coding-agent
3. Connect them — create ~/.pi/agent/extensions/searchai.ts:
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
export default function (pi: ExtensionAPI) {
pi.registerProvider("searchai", {
baseUrl: "http://127.0.0.1:8081/v1",
apiKey: "$SEARCHAI_API_KEY",
api: "openai-completions",
models: [{ id: "q35-4b", name: "SearchAI q35-4b", reasoning: false,
input: ["text"], cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 32768, maxTokens: 4096 }]
});
}
export SEARCHAI_API_KEY='your-api-key' # printed by the installer
Full setup detail (and four more worked tasks) in the pi agents article. The server works with pi stock — no compatibility flags.
The walkthrough
pi --provider searchai --model q35-4b -p \
"Write a python script csv_report.py that reads ../contracts/summary.jsonl \
and produces report.csv with columns source_file, client_or_buyer, fee, \
governing_law — then RUN it and show the output. Fix any errors you hit \
until it runs clean."
Measured run (66 seconds, CPU 4B): the agent wrote the script, ran it, iterated to a clean run, produced the CSV — and notably flagged on its own that one requested column wasn't derivable from the input data rather than inventing values.
Honest notes
Public multi-turn benchmarks are unambiguous: all small generic models fall off steeply on long autonomous coding chains. Use 4B for one-clear-task scripts with a verify step; for refactoring or multi-file work, move to the 27B model with the GPU add-on and keep a human in the loop.
Measured: 66 s: script written, run, fixed, output produced.
Next: all the use cases · give the agent memory across sessions · 3–4× the speed with one GPU flag