This Resource Manager stack launches an OCI compute instance for OpenClaw, discovers which OCI Generative AI models are actually usable for the supplied API key through the OCI Responses API, and automatically configures OpenClaw to use those discovered models.
The following diagram shows the high-level architecture this stack provisions.
Before deploying this stack:
- Navigate to Analytics & AI → AI Services → Generative AI → API Keys and create an OCI Generative AI API key.
- Copy the API key value.
- Copy the API key OCID.
- Create an IAM policy that allows that API key to use OCI Generative AI in the root compartment.
- Use the API key value in the
oci_genai_api_keystack variable when launching this stack. - Have an SSH Key to be used for instance configuration
Example IAM policy:
allow any-user to use generative-ai-family in tenancy where ALL {request.principal.type='generativeaiapikey', request.principal.id='<your-generative-ai-api-key-ocid>'}
Notes:
- Create the Generative AI API Key in the same region you plan to spin up your instance
- The API key value is what you paste into the Resource Manager stack variable.
- The API key OCID is what you use in the IAM policy condition.
Launch this stack directly in OCI Resource Manager.
After the stack opens in OCI Resource Manager, provide the required deployment inputs such as compartment, availability domain, image, SSH public key, and OCI Generative AI API key.
The stack implements an end-to-end automated flow that:
- provisions the VM and required network resources
- installs OpenClaw automatically
- discovers usable OCI Responses API models at instance startup
- binds those discovered models into OpenClaw as a custom
ociprovider - configures OpenClaw to use the OCI OpenAI-compatible Responses API path
- installs and starts the OpenClaw gateway automatically
First, SSH into the instance using your private key.
ssh -i /ABSOLUTE/PATH/TO/YOUR/PRIVATE_KEY opc@<INSTANCE_PUBLIC_IP>Do not run openclaw commands immediately after the VM becomes reachable.
Wait until first-boot bootstrap has fully completed.
Run this command on the VM:
sudo cloud-init status --long || trueExample output while the instance is still provisioning OpenClaw and discovery assets:
[opc@openclaw ~]$ sudo cloud-init status --long || true
status: running
extended_status: running
boot_status_code: enabled-by-generator
last_update: Thu, 01 Jan 1970 00:00:31 +0000
detail: DataSourceOracle
errors: []
recoverable_errors: {}
If the output shows status: running, wait and run the command again in a minute.
Example output after bootstrap has finished successfully:
[opc@openclaw ~]$ sudo cloud-init status --long || true
status: done
extended_status: done
boot_status_code: enabled-by-generator
last_update: Thu, 01 Jan 1970 00:06:45 +0000
detail: DataSourceOracle
errors: []
recoverable_errors: {}
[opc@openclaw ~]$
Only after the output shows status: done should users proceed with openclaw commands.
For instances provisioned from this updated stack, openclaw should then be directly available from the shell:
openclaw --versionIf your SSH session was opened before bootstrap finished and the command is still not found, exit and SSH back in once, then retry:
openclaw --versionAfter you have verified that openclaw is installed, exit that SSH session.
From your local machine, open a new SSH session with local port forwarding enabled:
ssh -i /ABSOLUTE/PATH/TO/YOUR/PRIVATE_KEY -L 18789:127.0.0.1:18789 opc@<INSTANCE_PUBLIC_IP>Keep that SSH session open while you use the UI.
In that port-forwarded SSH session, print the current OpenClaw gateway token with:
sudo -u opc bash -lc 'python3 -c "import json; print(json.load(open(\"/home/opc/.openclaw/openclaw.json\"))[\"gateway\"][\"auth\"][\"token\"])"'This prints the token currently configured in /home/opc/.openclaw/openclaw.json. You will use this token to sign in to the OpenClaw UI.
With the SSH local port forward still running, open this URL locally in your browser:
http://127.0.0.1:18789/
When prompted, paste the token printed from the terminal.
The OpenClaw gateway is intentionally configured as loopback-only:
- bind:
127.0.0.1 - port:
18789
That means the Control UI is not directly exposed on the VM public IP.
Because the gateway is configured with:
bind = loopbackauth.mode = token
you must both:
- access it through the SSH local port forward, and
- provide the current gateway token to log in.
Use the following commands only if you want to validate the deployment in more detail or troubleshoot an issue. These commands are not required just to sign in and use OpenClaw.
sudo cloud-init status --long || true
sudo tail -n 250 /var/log/cloud-init-output.log
sudo systemctl status openclaw-model-discovery.service --no-pager
sudo cat /opt/openclaw/runtime/03-oci-genai-chat-models.json
sudo -u opc bash -lc 'cat /home/opc/.openclaw/openclaw.json'
sudo -u opc bash -lc 'export PATH="/home/opc/.npm-global/bin:$PATH"; export XDG_RUNTIME_DIR="/run/user/$(id -u)"; openclaw gateway status'
sudo -u opc bash -lc 'export PATH="/home/opc/.npm-global/bin:$PATH"; export XDG_RUNTIME_DIR="/run/user/$(id -u)"; openclaw health --verbose'Expected outcomes:
- cloud-init completes successfully
- discovery service succeeds
- discovery output contains usable OCI models
openclaw.jsoncontains theociprovider binding and discovered models- OpenClaw gateway is installed, running, and healthy
The bootstrap has been hardened to improve reliability on first boot. In some environments, the OpenClaw installer may need more than one attempt before the binary becomes available. The current bootstrap flow retries the installer and only continues once the OpenClaw binary is present.
The bootstrap also creates a guarded symlink at /usr/local/bin/openclaw after verifying the installed binary path. This is intended to make the command available more consistently for operators without depending solely on shell startup files.
If /usr/local/bin/openclaw already exists and does not point to /home/opc/.npm-global/bin/openclaw, bootstrap stops instead of overwriting it.
You may also see non-fatal installer output such as non-interactive /dev/tty warnings during bootstrap.
If cloud-init finishes with:
status: doneerrors: []
and the gateway plus discovery checks succeed, those warnings can be treated as informational rather than deployment failure.
At first boot, the instance performs these phases:
- Install discovery assets and systemd unit.
- Create the OpenClaw runtime/config home under
/home/opc/.openclaw. - Wait for DNS resolution and outbound HTTPS readiness before network-dependent bootstrap steps begin.
- Refresh package metadata and install bootstrap dependencies with bounded retries.
- Download and run the OpenClaw installer only after the installer endpoint is reachable.
- Verify that the OpenClaw binary exists before running configuration commands.
- Create a guarded system-wide symlink at
/usr/local/bin/openclawafter verifying the installed binary path. - Configure OpenClaw gateway basics:
gateway.mode = localgateway.bind = loopbackgateway.auth.mode = token
- Start the OCI model discovery systemd unit.
- Wait for discovery output to exist.
- Create a custom OpenClaw provider named
oci. - Configure the discovered OCI models into OpenClaw.
- Set the default OpenClaw model to the first discovered usable OCI model.
- Install and start the OpenClaw gateway service.
The current model discovery process is intentionally dynamic. It is implemented so that users can supply an OCI Generative AI API key associated with any currently supported region in OCI, and the stack will keep only the regions and models that actually respond as usable through the OCI Responses API for that key.
The stack currently probes these OCI regions:
eu-frankfurt-1ap-hyderabad-1ap-osaka-1us-ashburn-1us-chicago-1us-phoenix-1
The discovery process uses the candidate catalog in:
/opt/openclaw/discovery/01-oci-genai-chat-candidates.json
At startup, the discovery script:
- Iterates through each supported region.
- Builds the OCI Responses API endpoint for that region.
- Selects the first configured candidate model for that region as the probe model.
- Sends a minimal request to the region’s
responsesendpoint using:- the candidate model ID
input: "Reply with exactly the word OK"
- Classifies the result.
If the first probe for a region returns one of the following classifications:
usableinvalid_model_idbad_requestrate_limited
then the script continues testing all configured candidate models for that region and keeps only the ones that are actually usable.
If the first probe returns one of the following classifications:
auth_failedforbiddentransport_errorother
then the script does not enumerate all models in that region, because the region is treated as unavailable or not usable for the supplied key in its current state.
This means:
- the same API key may succeed in one supported region and fail in another
- region-level
401or403diagnostics are not automatically a full deployment failure - the deployment is considered successful as long as discovery finds at least one usable region with at least one usable model
- only the discovered usable region/model set is written into the resulting OpenClaw provider config
- the stack currently applies only the first usable region returned by discovery
The stack is now functionally working end-to-end, but later improvements may still include:
- stronger secret handling beyond direct API-key rendering into cloud-init and
~/.openclaw/.env - optional further refinement of model discovery heuristics and exclusions
- optional exposure improvements (for example Tailscale or reverse proxy / LB patterns) instead of SSH local forwarding
- optional networking/security hardening after bootstrap validation.
