Skip to main content
Run Claude Code inside a Cloud box. The CLI performs file and shell operations there, and boxlite exec returns its output. Complete the workstation setup. Run all commands below on your workstation.

Create the box and install Claude Code

Save create.py. The prompt reads the real model key on your workstation; only BoxLite’s Secret configuration receives it.
create.py
Install the agent:
The node image runs as the non-root boxlite user. Claude Code requires a non-root user for permission-bypass mode.

Connect your model

The create script uses Claude Code’s native ANTHROPIC_API_KEY setting. Its value inside the box is the literal <BOXLITE_SECRET:anthropic>; BoxLite supplies the real key on outbound requests to api.anthropic.com. Claude Code selects its default model. To select another, add its native --model option to the command below. For a different supported provider, follow Claude Code’s model configuration and match the Secret’s hosts to its API endpoint.

Run a task

Permission-bypass mode lets the task execute unattended inside the box. Use it for trusted tasks: the agent can use the model connection and access the files, local service credentials, and network available there. Claude Code is ready. Replace the prompt with your own task. Check is_error in the JSON response as well as the actual file.

Optional: wake on a request

This walkthrough creates a separate claude-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 Claude Code 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 as create-http.py. Its startup command waits for the files installed in step 3, then starts the service on every boot.
create-http.py
Use auto_stop=0 instead if you want this HTTP service to stay running. Keep the value shown to try automatic stop and wake. For an existing Anthropic Messages-compatible endpoint, add ANTHROPIC_BASE_URL and ANTHROPIC_MODEL to env, and change Secret.hosts to that endpoint’s hostname. Supply its key at the prompt; keep the placeholder unchanged.

2. Save the HTTP service

Save the complete code below as server.mjs. The service accepts {"prompt":"..."}, runs one Claude task at a time with a three-minute limit, and returns Claude’s JSON result. POST /tasks is this example’s application API.
server.mjs
Only give the caller token to clients allowed to run tasks in this box. This example uses Claude’s permission-bypass mode, as in the CLI task above.

3. Install and start the service

Generate the caller token and its hash locally:
Keep http-token on your workstation and out of Git. Install Claude Code, upload the service and token hash, then register port 8080:
The saved startup command starts the service as soon as these files exist. It starts it again after every wake; no attached terminal is required.

4. Send the first task

Set CLAUDE_URL to the HTTPS URL returned by the last command. Keep this shell open for the wake-up check.
If the service is still starting, retry this health request after a few seconds. Then ask Claude to create a file:
Success means the response contains "is_error": false and the independent file check prints CLAUDE_HTTP_READY.

5. Wait for automatic stop

Stop sending HTTP requests, including health checks. Run only this control-plane check until Status is stopped:
Allow two idle minutes. Do not use start, exec, or cp before the next request: the HTTP request should be the action that wakes the box.

6. Wake Claude with another task

Send a new task to the same URL:
Cloud starts the box; its saved command starts the HTTP service, which runs Claude. After the response, check both files:
The first file checks retained work; the second checks that Claude ran tools after wake. Leave the box idle again and it stops automatically. This stop/wake workflow was verified with real model and file-tool calls through an Anthropic Messages-compatible endpoint. If Cloud returns 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

For applications that already use Cloud exec, the CLI command above also supports wake on access; this HTTP service is optional.

When you are finished