Create the box and install Pi
Savecreate.py. Before running it, replace <YOUR_MODEL_HOST> with your model endpoint’s hostname, without the scheme or path. The prompt reads the real model key on your workstation; only BoxLite’s Secret configuration receives it.
create.py
Connect your model
Use an existing OpenAI Chat Completions-compatible endpoint with tool support. SetSecret.hosts in create.py to its hostname. Save models.json, replacing the API base URL and model ID; set the context and output limits to values supported by your model:
models.json
Run a task
stopReason: "error" means the model request failed, even if the CLI exited with code zero.
Pi is ready. Repeat the exec command with your own task. --no-session makes each call an independent turn.
Optional: wake on a request
This walkthrough creates a separatepi-http box with an authenticated POST /tasks endpoint. After two idle minutes, the box stops. Sending another task to the same URL starts the box and runs Pi again.
Run every command below on your workstation, in one directory. You will create two source files and a local caller token. The token’s hash goes into the box; the real model key stays in BoxLite’s Secret.
1. Create the HTTP box
Save this ascreate-http.py. Its startup command waits for the files installed in step 3, then starts the service on every boot.
create-http.py
auto_stop=0 instead if you want this HTTP service to stay running. Keep the value shown to try automatic stop and wake.
Use the same model endpoint and Secret settings as the CLI deployment above.
2. Save the HTTP service
Save the complete code below asserver.mjs. Replace <MODEL_ID> with the same model ID from models.json. The service accepts {"prompt":"..."}, runs one Pi task at a time with a three-minute limit, and returns Pi’s JSON result. POST /tasks is this example’s application API.
server.mjs — complete source
server.mjs — complete source
server.mjs
3. Install and start the service
Generate the caller token and its hash locally:http-token on your workstation and out of Git. Keep models.json from the model setup above. Install Pi, upload the model configuration, service and token hash, then register port 8080:
4. Send the first task
SetPI_URL to the HTTPS URL returned by the last command. Keep this shell open for the wake-up check.
"ok": true and the independent file check prints PI_HTTP_READY.
5. Wait for automatic stop
Stop sending HTTP requests, including health checks. Run only this control-plane check untilStatus is stopped:
start, exec, or cp before the next request: the HTTP request should be the action that wakes the box.
6. Wake Pi with another task
Send a new task to the same URL:503 BOX_STARTING, wait for Retry-After before retrying. The service returns 401 for a wrong caller token and 409 while another task is running. A timed-out request can have partial effects: inspect its output before resubmitting it.
7. Clean up the HTTP box
exec, the CLI command above also supports wake on access; this HTTP service is optional.

