Codex CLI on a Cloud Server: Install, Configure, and Run in the Background
Codex CLI can be installed on a QCode cloud server: with tmux or systemd in the background it keeps running after the SSH connection drops. The one-command script only writes the config by default, so on a server pick Codex CLI.
Updated 2026-10-19
Point this tool at the QCode endpoint — one key for Claude, GPT and Chinese models.
- Billed per token — live rates on /models
- Pay by card (Visa / Mastercard / AMEX), Apple Pay, Google Pay or crypto
- Self-service: top up and activate instantly
Four points: config, key, protocol, non-interactive
Top-level keys plus a provider table
The top level holds three keys, model_provider, model and model_reasoning_effort; base_url, wire_api and requires_openai_auth belong inside the [model_providers.qcode] table, and the two levels cannot be mixed up.
Pick one
With requires_openai_auth = true the key is read from OPENAI_API_KEY in ~/.codex/auth.json; to use an environment variable instead, replace that line with env_key = "QCODE_API_KEY" and export it. The official OpenAI documentation states that Codex ignores env_key when requires_openai_auth = true.
The protocol field is fixed
Codex speaks the Responses protocol, so wire_api is set to responses, and the official OpenAI Codex configuration reference states that this field currently supports only responses and defaults to responses when it is omitted.
Non-interactive runs
codex exec --sandbox workspace-write runs batch jobs on the server: it works non-interactively, prints the result to standard output and keeps changes inside the workspace.
Can Codex CLI run on a cloud server?
As of 2026-10-19, yes. A QCode cloud server is a machine you administer yourself, with 1 dedicated public IPv4, KVM and full root access, and it is usually ready within a few minutes; the console is currently available in Chinese and English, and once Codex CLI is installed, model calls go through the QCode endpoint with your QCode key. Cloud servers and AI services are sold separately, so you do not have to buy a personal plan first; Codex calls models with the key from your QCode dashboard, and you pick a plan in your QCode account to get that key.
Official docs and tool status (checked 2026-10-19)
As of 2026-10-19, the Codex quick start on docs.qcode.cc describes the Responses path, and the key starts with cr_ and goes into OPENAI_API_KEY in ~/.codex/auth.json.
Three dates in the timeline
Release date of the updated GPT-6 Sol (gpt-6.1-sol); the QCode Codex quick start lists it as the recommended default model.
Release of Codex CLI v0.162.1, the latest stable version, as recorded in the QCode Codex guide.
The QCode Codex guide was updated on this day, re-checking the config settings, the approval and sandbox parameters and the installation methods; that is the revision date of the documentation, not a Codex release.
Confirmed vs not published
Confirmed (verifiable in the source)
The Codex-related items can be checked in the source: (1) the endpoint, the key and the two config levels are described in the section on getting Codex running on the server above; (2) the recommended model is gpt-6.1-sol, and the reasoning effort can be set with model_reasoning_effort = "high"; (3) codex exec --sandbox workspace-write runs non-interactively, prints the result to standard output and keeps changes inside the workspace. The trial, refund and renewal rules for the cloud server are on qcode.cc/en/cloud.
Not published or not confirmed
qcode.cc/en/cloud does not publish bandwidth or latency figures for the lines, and starting prices change with restocks and sizes, so the line comparison is the reference. Changing the line or upgrading the size online is not possible today, and the page does not say whether that will change.
Local run vs. running in the background on a server
The config travels with you
config.toml and the key live on your own machine, so when that machine goes away, Codex goes away with it. Good for short tasks and interactive editing.
The machine is yours, and you keep the process alive
With tmux or systemd, Codex keeps running in the background after you close your laptop (see the FAQ); in the dashboard you can check the status, start, stop, reboot and renew the server. Good for long tasks and background jobs.
Getting Codex running on the server
First pick region, line, term and size on qcode.cc/en/cloud; the starting prices are in the line comparison. Second, log in with the connection details from the dashboard: ssh root@ followed by the server IP, using the root password you set when ordering. Third, run the one-command installer on the server: curl -fsSL https://qcode.cc/install/codex.sh | bash -s -- --lang en --target cli, and the script prompts are in English; the docs say it measures the api, asia and us endpoints and recommends the fastest one, prompts you to paste the cr_-prefixed key, writes the ~/.codex config and checks the connection. It first asks whether you want the desktop app or the CLI, and the default desktop app only writes the config without installing Node.js or the CLI, so pick Codex CLI on a server. Fourth, to configure by hand, put model_provider = "qcode", model = "gpt-6.1-sol" and model_reasoning_effort = "high" at the top of ~/.codex/config.toml, then add the [model_providers.qcode] table with name = "qcode", base_url = "https://api.qcode.cc/openai", wire_api = "responses" and requires_openai_auth = true (the provider name is up to you as long as it matches the table name; the docs example uses qcode). Fifth, put the cr_-prefixed key into OPENAI_API_KEY in ~/.codex/auth.json - the key comes from your QCode dashboard; to use an environment variable instead, replace requires_openai_auth = true in the table with env_key = "QCODE_API_KEY" and export that variable, the two variants are mutually exclusive. Sixth, verify with codex --version and then run a one-line hello-world prompt.
How to connect on QCode
On the server, Codex talks to the QCode endpoint; the full configuration is in the section on getting Codex running on the server above. The GPT models available through QCode are gpt-6.1-sol, gpt-6-sol, gpt-6-astra, gpt-5.6-sol and gpt-5.6-terra; calls are billed per token, and per-model rates are listed on /models; cloud servers and AI services share one account balance. Not ready for a monthly plan? Pay-as-you-go Packs start at $4 for a one-off quota that you use within 7 to 90 days (top-ups start at $1).
Frequently asked questions
How do I run Codex non-interactively on the server?
Use codex exec: it runs non-interactively and prints the result to standard output (add --json for JSONL), for example codex exec --sandbox workspace-write. The sandbox is limited to the workspace and does not touch the system outside it, which suits CI/CD integration and batch work.
How do I pay, and how do I order?
You can pay with Alipay, WeChat, a bank card or cryptocurrency. Pick region, line, term and size, then order; the server is usually ready within a few minutes. If provisioning fails, or the server is not delivered within 2 hours of the order, the full amount goes back to your balance. Spam, DDoS, scanning, mining and illegal content are forbidden; we shut the server down immediately, and the amount already paid is not refunded.
Which model should I use on the server?
The default model recommended in the docs is gpt-6.1-sol (the updated GPT-6 Sol), and you can switch temporarily with codex --model gpt-6.1-sol; the other GPT models available through QCode are gpt-6-sol, gpt-6-astra, gpt-5.6-sol and gpt-5.6-terra, and the full list is on qcode.cc/models.
How is the trial billed, and can I get a refund after signing up?
The trial is a paid one: it lasts 1 day (24 hours) and the price depends on the size; when it ends the server is deleted and the data is not kept. During the trial you can keep it from the panel by picking 1, 3, 6 or 12 months, and each account can have only one trial server at a time. There is no refund once the server is provisioned.
How do the one-command script and a hand-written config.toml relate?
By default the script only writes the config: when it runs it first asks whether you want the desktop app or the CLI, and it installs Node.js and the CLI only when you pick Codex CLI. If ~/.codex/config.toml already exists, the script updates only model_provider, model, review_model and model_reasoning_effort plus the provider table, keeps your existing MCP server, profile and approval_policy as they are, and saves a timestamped .bak copy of the file in the same folder before writing; it overwrites the whole file only when the original cannot be merged safely, and it says so.
How do I keep Codex running on the server after the SSH connection drops?
To keep the process running after SSH drops, the usual approach is to put Codex into a tmux session or write it as a systemd service; this is general Linux practice, not a QCode or OpenAI feature. You can check the machine status in the dashboard, and start, stop, reboot and renew it there.
First-hand sources
The QCode cloud server page (qcode.cc/en/cloud, fetched and checked on 2026-10-19): regions and lines, IPv4 and full administrative rights, trial and terms, refund rules, dashboard functions, forbidden uses, payment methods and the one-command install. The Codex quick start on docs.qcode.cc (fetched and checked on 2026-10-19): the provider, env_key and auth.json in config.toml, the available models and the sandbox parameters. The QCode Codex guide (fetched and checked on 2026-10-19): the Codex CLI version and release date, the config settings, the approval and sandbox parameters. The one-click install guide on docs.qcode.cc (fetched and checked on 2026-10-19): the endpoint speed test, the two targets (desktop app and CLI), the write and backup behaviour. The official OpenAI Codex pages on authentication and on the configuration reference (fetched and checked on 2026-10-19): how the key is read and the allowed values of the protocol field.
Open one now
One machine you administer, with Codex CLI calling GPT models such as gpt-6.1-sol through the QCode endpoint; calls are billed per token.
Related pages
Pay-as-you-go Packs
No subscription: one purchase of quota, used within 7 to 90 days.
Codex CLI Complete Guide
From installation to multi-model and proxy settings, the full Codex CLI configuration in one read.
Codex CLI third-party API setup guide
The config.toml syntax and common errors when pointing Codex at a third-party API.
Crypto payment guide
Nine coins, 56 networks, zero platform fee for AI coding API credits.
The content was checked on 2026-10-19 against the live pages on qcode.cc/en/cloud and docs.qcode.cc; as those pages are updated, the content may change without further notice. Model availability is what /models shows.