
Deploy OpenClaw OpenAI
Run OpenClaw on OpenAI GPT models with your API key
Just deployed
/data
Deploy and Host self hosted OpenClaw OpenAI (Self-Hosted AI Assistant on OpenAI GPT) on Railway
This template runs the OpenClaw gateway on Railway so your always-on assistant can call OpenAI GPT models. You bring either an OpenAI Platform API key or a ChatGPT/Codex sign-in.
About Hosting OpenClaw OpenAI open-source software on Railway (self hosted OpenClaw with OpenAI models template)
OpenClaw is MIT-licensed, so you can run, read, and change it. State and the workspace sit on a persistent volume at /data, so sessions survive redeploys.
Why Deploy OpenClaw OpenAI, the ChatGPT alternative on Railway (Railway Free Trial)
ChatGPT is the easy default, but you rent its interface and its model choices. Railway's $5 trial covers hosting, but model API costs bill separately.
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying OpenClaw OpenAI on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Railway vs Other Hosting Providers and VPS for OpenClaw OpenAI self hosting
Running OpenClaw on OpenAI models mostly means keeping one gateway online with a persistent volume, so the question is how much server work you want to own.
| Provider | What You Get with Railway | What You Get with the Other Provider |
|---|---|---|
| DigitalOcean | One service on port 18789 with a /healthz check and a /data volume. | A Droplet you control fully, but you handle Node or Docker, TLS, and updates. |
| AWS | The same one-service layout with a domain and volume attached. | Broad networking control, but EC2 or ECS, storage, and security rules are manual. |
| Hetzner | The gateway running with the token and device approval steps from the template. | Low-cost servers with generous bandwidth, but the OS, install, and service are yours. |
If you enjoy running Linux boxes, a VPS gives you more say over the host, while Railway is the faster route to a working assistant.
Common Use Cases for hosted OpenClaw OpenAI
- An always-on assistant on GPT models: Run the gateway on Railway so it stays reachable from your phone without a laptop awake. Point it at an
openai/model ref and it answers around the clock on your own key. - Using a ChatGPT subscription through Codex sign-in: Sign in with Codex OAuth so subscription use bills to that plan, not separate Platform keys. Keep
OPENAI_API_KEYfor Decision models, since subscription profiles don't cover them. - Picking a cheaper default model: Set
agents.defaults.decisionModelto a smalleropenai/model for quick routing and save the bigger one for hard questions. - Mixing OpenAI with a fallback provider: Keep GPT as the primary and wire in a second provider for rate limits or outages. Your assistant keeps answering instead of going quiet.
- Keeping chats off the ChatGPT app: Route day-to-day conversations through your own gateway so history lives in your
/datavolume, not someone else's product.
Dependencies for OpenClaw OpenAI Docker hosted on Railway
This section covers what the template needs to run and what you supply yourself. The moving parts are one service, one volume, one port, and one provider key.
Deployment Dependencies for Managed OpenClaw OpenAI Service (AI Assistant Gateway)
You need a Railway account, a public domain on the service, and an OpenAI Platform API key for direct per-token billing.
Implementation Details for OpenClaw OpenAI (Using OpenClaw official docker image)
The start command fixes volume ownership, applies OPENCLAW_RAILWAY_CONFIG, then runs openclaw gateway --bind lan --port 18789 --allow-unconfigured as the node user.
How does OpenClaw OpenAI compare against other ways to run a GPT-powered assistant
Running GPT models through OpenClaw is a different trade than using a hosted chat app or a coding agent. Here is where each option tends to win.
OpenClaw OpenAI vs ChatGPT
- Where you chat: OpenClaw runs as a gateway you reach through the Control UI, CLI, or TUI, and it can connect channels like Telegram or Slack.
- Who holds the data: Sessions and workspace live on your Railway volume at /data, not on OpenAI's side.
- Billing: Use OPENAI_API_KEY for Platform billing, or Codex OAuth so subscription use is billed to the subscription.
- Where ChatGPT wins: Nothing to host, no keys or gateway token to manage, so it is the easier pick if you just want a chat window.
OpenClaw OpenAI vs Hermes Agent
- Shape: Hermes Agent is a self-hosted agent framework. OpenClaw is an MIT-licensed gateway acting as the control plane for sessions, tools, and channels.
- Model routing: OpenClaw selects GPT models with the openai/ prefix in config.
- Limits of this comparison: The upstream docs do not cover Hermes Agent in enough depth for a detailed comparison, so check its own docs.
- Where Hermes Agent may win: If its framework fits your agent design better, that matters more than any gateway feature list.
OpenClaw OpenAI vs Claude Code
- Purpose: Claude Code is Anthropic's terminal coding agent. OpenClaw is an always-on assistant gateway for chat channels and long-running sessions.
- Model family: Claude Code runs Claude models, while OpenClaw OpenAI runs GPT models and can route to other providers as plugins.
- Where Claude Code wins: For hands-on code editing in a repository, a terminal agent built for that job is the more natural fit.
OpenClaw OpenAI vs OpenRouter
- Role: OpenRouter is a unified API gateway routing requests to many model providers. OpenClaw is the assistant layer above your model choices.
- Keys: OpenClaw uses OPENAI_API_KEY or Codex OAuth, while OpenRouter gives you one key across many providers.
- Where OpenRouter wins: One billing account and one key across many models simplifies that part, and OpenClaw can still point at other providers as a fallback.
How to use OpenClaw OpenAI (the OSS AI assistant gateway)?
Work through these first-day steps in order, since the model step depends on the key being set.
- Add
OPENAI_API_KEYon the service Variables tab with your Platform API key. - Redeploy so the gateway picks up the new variable.
- Open the Control UI from the public domain, paste
OPENCLAW_GATEWAY_TOKENinto settings, and runopenclaw devices approvein the service shell. - Set the default model to an
openai/model ref underagents.defaults.decisionModel, or pick it in the Decision picker. - Send a test message and confirm the reply comes from the model you picked.
- Optionally sign in with Codex OAuth for ChatGPT subscription access. Keep the API key in place, since Decisions need Platform billing.
{
"agents": {
"defaults": {
"decisionModel": "openai/gpt-6-luna"
}
}
}
How to self host OpenClaw OpenAI on other VPS Services (OpenClaw self hosting guide)
Running the gateway on your own VPS works the same way as on Railway, once you have the install and model config in place.
Clone the Repository
Grab the OpenClaw source, then move into the project folder.
git clone https://github.com/openclaw/openclaw.git your-domain-assistant
cd your-domain-assistant
Install Dependencies
Install the CLI on Node 24.16 or newer (or 26.1 or newer), then run onboarding with the daemon flag.
npm install -g openclaw@latest
openclaw onboard --install-daemon
Configure Environment Variables
Set your OpenAI key for Platform billing and a gateway token for the Control UI. Then point the default model at an openai/ ref such as openai/gpt-6-luna.
export OPENAI_API_KEY=sk-your-key-here
export OPENCLAW_GATEWAY_TOKEN=your-long-random-token
Start the OpenClaw OpenAI Application
Start the gateway on port 18789, open the Control UI on your domain, and approve the browser device with openclaw devices approve.
Official Pricing of OpenClaw OpenAI (OpenClaw pricing)
OpenClaw is free and open source under the MIT license, so there is no OpenClaw plan to buy. Decision models always need a Platform API key.
OpenClaw OpenAI cloud vs self hosted comparison (Pricing, features, costs, and more)
Running OpenClaw on OpenAI models splits into two bills: the Railway service that hosts the gateway, and the model usage you pay for.
Monthly cost of self hosting OpenClaw OpenAI on Railway
On Railway, the browser variant with Chromium runs roughly $10-25 per month and needs 1-2 GB of RAM. Model costs are separate. Railway's $5 trial covers early testing.
System Requirements for Hosting OpenClaw OpenAI on a VPS
On a VPS, plan for at least 1-2 GB of RAM for the browser variant and persistent disk for /data so state survives restarts.
Frequently Asked Questions (FAQs)
Should I use an API key or Codex OAuth?
Use OPENAI_API_KEY for direct Platform billing per token. Use Codex OAuth if you already pay for a ChatGPT or Codex subscription and want that usage billed to the subscription instead.
Which model ref should I use?
Use the openai/ prefix followed by the model name, such as openai/gpt-6-luna, set under agents.defaults.decisionModel.
Does it support the Responses API?
The docs I checked cover the openai/* route and auth paths but don't state Responses API support directly. Check the upstream OpenAI provider docs before you rely on it.
How do I control costs?
Pick a cheaper default model and reserve larger ones for tasks that need them.
Can I switch models per chat?
Yes, change the model per session from the Control UI or the Decision picker.
Can I set a fallback provider?
Yes, add a second provider key as a plugin and configure it as a fallback.
Template Content

