Skip to content

Claude Code

The claude-code template ships Anthropic's Claude Code CLI preinstalled. Create a sandbox, pass your Anthropic key, and the agent has a whole machine — filesystem, shell, network — that is not yours.

Setup

bash
pip install ovrin
export OVRIN_API_KEY="ovrin_..."

Run the agent

python
import ovrin

client = ovrin.Client()  # reads OVRIN_API_KEY

sandbox = client.sandboxes.create(
    template="claude-code",
    env={"ANTHROPIC_API_KEY": "sk-ant-..."},
    timeout=1800,
)

result = sandbox.run('claude -p "Compute 1+1 and explain it"')
print(result.stdout)

sandbox.kill()

claude is already on the PATH — there is no install step to wait through.

Give it a repository to work on

The point of a sandbox is that the agent can edit files freely. Write the code in, let the agent change it, read the result back out:

python
sandbox.files.write("/workspace/app.py", open("app.py").read())

result = sandbox.run(
    'cd /workspace && claude -p "add type hints to app.py"',
    timeout=600,
)
print(result.stdout)

print(sandbox.files.read("/workspace/app.py"))

Nothing the agent does reaches your machine. If a run goes wrong, kill the sandbox and start another.

Watch a long run

A refactor can take minutes. stream yields output as it is produced, so a slow run is distinguishable from a stuck one:

python
for event in sandbox.stream('cd /workspace && claude -p "run the tests and fix failures"'):
    print(event)

Auth

VariablePurpose
ANTHROPIC_API_KEYAnthropic API key
ANTHROPIC_AUTH_TOKENAlternative to the API key
ANTHROPIC_BASE_URLPoint at a proxy or gateway
ANTHROPIC_MODELOverride the default model

Passing a provider key through env is the supported pattern today. See Secrets & Credential Vault for where that is going.