Run the Codex agent on your own servers
Codex Cloud suits teams that want OpenAI to prepare the environment, run the sandbox and review pull requests on GitHub. Agenhood suits teams that need the sandbox on their own server, or want Codex next to Claude Code and Opencode under one API.
Last updated
If you searched for Codex Cloud self-hosted, here is the short version: Codex Cloud runs your tasks on OpenAI's side, but Codex itself also ships as an open-source CLI. Agenhood runs that CLI in a sandboxed container on your server, with your own OpenAI API key. You lose Codex Cloud's hosted extras, like automatic environment setup and code review on GitHub. You gain a sandbox you control, agents that keep their files, and Claude Code and Opencode under the same API.
The short answer
Pick Codex Cloud if
- You want zero setup: Codex prepares the environment for you.
- You want @codex review and automatic code reviews on GitHub.
- You want a button that opens the pull request.
- You're fine with OpenAI running the sandbox.
Pick Agenhood if
- The sandbox, the code and the task history must stay on your own server.
- You want Codex next to Claude Code and Opencode under one API.
- You want agents that keep their workspace between tasks and run on schedules.
- You want to run Codex with an OpenAI API key.
Side by side
| Topic | Codex Cloud | Agenhood |
|---|---|---|
| Where it runs | A VM on OpenAI's side, built from a cloud environment you publish. source | One hardened Docker container per agent, on one VM you run. No Kubernetes. |
| Sign-in | Codex Cloud requires signing in with ChatGPT. source | An OpenAI API key, or your own ChatGPT plan through OpenAI's sign-in flow. |
| Agents and models | Codex with the OpenAI models on your ChatGPT plan. source | Codex, Claude Code, Opencode and two more drivers, chosen per agent. Anthropic and OpenAI models, plus Opencode's own plans. |
| Workspace | Each task gets its own isolated workspace from the published environment, and keeps its files for follow-ups. source | A /workspace volume per agent, shared by all its tasks, that survives restarts, pauses and weeks of idle. |
| Network | Internet access is a setting: package managers, custom domains or unrestricted. Network secrets are filled in by a proxy. source | No direct route out. A filtering egress proxy blocks private IP ranges and cloud metadata endpoints. |
| Ways to start a task | ChatGPT on the web, mobile and desktop, the Codex CLI, and Slack. source | Console, REST API, schedules, workflows, a GitHub issue or PR comment, or a Slack message. |
| GitHub | @codex review and automatic reviews post a standard GitHub code review on the pull request. source | A new issue or PR comment starts a task. The connector posts a reply and edits it in place with progress and the result. |
| Pull requests | Built in. You commit or open a pull request from the task when you are ready. source | Not built in. An agent can push a branch and open a PR with its own git tools and credentials. |
| Scheduling | Scheduled tasks in ChatGPT on the web and in the desktop app. source | One-time or recurring schedules in your timezone, with a calendar. Workflows chain tasks across agents. |
| Pricing model | Part of ChatGPT plans. Cloud tasks share the plan's usage allowance. See their pricing page. source | Free. You pay for your server and for model usage on your own keys. |
| License | The Codex CLI is open source under Apache-2.0. Codex Cloud is a hosted service. source | MIT. The full source is on GitHub. |
The same agent in a different sandbox
In Codex Cloud, you start by creating a cloud environment. Codex inspects your GitHub repositories, installs dependencies and tests the setup with you, and you publish it. Each new task then gets its own isolated workspace from that environment, on a VM whose reachable domains you set. Internet access is something you turn on, with a package manager preset, custom domains or full access, and network secrets are swapped in by a proxy so the raw value never sits in a process or file.
In Agenhood, the Codex driver runs the codex binary from OpenAI's GitHub releases inside
the agent's container. Codex's own sandbox is switched off there, because the container is the
boundary: a read-only root filesystem, dropped Linux capabilities, CPU and memory caps, and an
internal network with no gateway. A filtering egress proxy is the only way out, and it blocks private
IP ranges and cloud metadata endpoints. Task history, files and logs stay in your own database and
Docker volumes. Model calls still go to OpenAI, so the difference is where the sandbox runs and where
the results are stored.
API key first, ChatGPT plan as an option
OpenAI's authentication docs say Codex Cloud requires signing in with ChatGPT, and recommend API key sign-in for programmatic Codex workflows such as CI jobs. Their pricing page lists the API key option as having no cloud-based features, and says cloud tasks share your plan's usage allowance with local work, with weekly limits that may apply.
Agenhood works the other way around. You add an OpenAI API key under Settings, Credentials. It is stored encrypted (AES-GCM) on your server, never sent to the browser, and usage is billed to the key owner. You can also connect your own ChatGPT plan, on your own server, through OpenAI's sign-in flow. Agenhood asks you to confirm it is your own account. Plan limits still apply, so we recommend an API key for scheduled and background work.
Workspaces that stay, and schedules
A Codex Cloud task keeps its own files, including uncommitted changes, while you send follow-ups, and each new task starts fresh from the published environment. OpenAI's docs say plainly that saved state doesn't replace source control. ChatGPT also has scheduled tasks on the web and in the desktop app.
An Agenhood agent is long-lived. Link a repository and Agenhood generates an SSH deploy key, clones the
branch into the agent's /workspace and keeps it there across tasks, restarts and weeks of
idle. Idle agents pause and wake on the next task. Schedules run a saved prompt or a workflow once or
on a recurring cadence in your timezone. Here is a Codex agent that fixes failing tests every night,
with make dev running and an OpenAI API key added. Use the id from the first
two responses as $AGENT_ID and $PROMPT_ID. The prompt assumes a linked repo.
# Create a Codex agent
curl -X POST http://localhost:5173/v1/containers \
-H "Authorization: Bearer tk_live_seedkey" \
-H "Content-Type: application/json" \
-d '{"name": "test-fixer", "config": {"driver": "codex", "model": "gpt-5.5"}}'
# Save the prompt it should run
curl -X POST http://localhost:5173/v1/prompts \
-H "Authorization: Bearer tk_live_seedkey" \
-H "Content-Type: application/json" \
-d '{"name": "Nightly test fix", "body": "Pull the latest changes, run the test suite, fix any failing tests and list every file you changed"}'
# Run it every night at 02:00 UTC
curl -X POST http://localhost:5173/v1/scheduled-tasks \
-H "Authorization: Bearer tk_live_seedkey" \
-H "Content-Type: application/json" \
-d '{
"name": "Nightly test fix",
"target": {"kind": "prompt", "container_id": "'"$AGENT_ID"'", "prompt_id": "'"$PROMPT_ID"'"},
"schedule": {"kind": "recurring", "unit": "day", "time": "02:00"},
"timezone": "UTC"
}'
Swap "codex" and "gpt-5.5" for "claude-code" and
"sonnet" to give the same job to Claude Code. The task viewer streams every message, tool
call and file change live, and you can cancel a task at any point.
What Codex Cloud does better
- Setup is done for you. Codex works out the runtimes, packages and services your repositories need and tests them before you publish the environment. In Agenhood, you prepare the agent yourself.
- Code review on GitHub. Comment
@codex reviewor turn on automatic reviews, and Codex posts a standard GitHub review focused on serious issues, guided by yourAGENTS.md. A deeper Security Review is in research preview. Agenhood has no review feature. - Pull requests in one step. You commit or open a pull request straight from the task. Agenhood leaves that to the agent's own tools.
- Nothing to run, from anywhere. OpenAI runs the VMs, and you start or follow tasks from ChatGPT on the web, your phone or the desktop app, or from Slack where your workspace enables it.
Moving over, or using both
Using both is often the best fit. Keep @codex review on your pull requests, and move the
implementation work that has to stay on your network, or run on a schedule, to Codex agents on
Agenhood. Each Codex Cloud environment becomes an agent with a linked repo, and its setup steps go
into your first prompt or into a skill.
If all you need is Codex in CI, OpenAI's own GitHub Action runs
codex exec on your runners with an API key. Agenhood is for agents that live longer than
one job, with a console, schedules and a sandbox per agent.
Agenhood is self-hosted on one server. The self-hosted AI agents guide shows what that takes.
What it doesn't do
- No GitHub code review and no pull request button. An agent can push a branch and open a pull request with its own tools and credentials, but there is no built-in step.
- It is a hardened container, not a VM. Agents share the host's kernel. For a stronger boundary, give Agenhood its own VM and keep other workloads off it.
- You run it. There is no hosted version, so updates, backups and capacity are on you. It is built for a trusted team, not as a public, multi-tenant service.
Questions people ask
Is it the same Codex agent?
It is the same open-source Codex CLI. Agenhood's Codex driver downloads the codex binary from OpenAI's GitHub releases and runs it inside the agent's container. You don't get Codex Cloud's own features, such as its environment setup, the pull request button or code review on GitHub.
Should I use an OpenAI API key or my ChatGPT plan?
Use an API key for background and scheduled work. OpenAI recommends API key sign-in for programmatic Codex workflows. You can also sign in with your own ChatGPT plan, on your own server, through OpenAI's sign-in flow. Plan usage limits still apply, so don't count on a plan to cover agents running all day.
Can Agenhood review pull requests like @codex review?
Not as a built-in feature. A new comment on a pull request can start a task on an agent, and the connector writes the agent's answer into its own reply comment. It doesn't post GitHub review comments on lines of the diff. If you want that, keep using Codex code review next to Agenhood.
Does Agenhood open pull requests?
No. Codex Cloud has a button for it, Agenhood has no built-in step. An agent can push a branch with git and the deploy key you gave it, and open a pull request with its own tools and credentials if your prompt asks for it.
Can I run Codex next to Claude Code?
Yes. Each agent picks its driver: Codex, Claude Code, Opencode, Vanilla (Agenhood's own tool loop) or API. They are created and tasked through the same API, and they use Anthropic and OpenAI models, plus Opencode's own model plans.
What does each one cost?
Codex Cloud is part of ChatGPT plans, and cloud tasks share the plan's usage allowance with local work. OpenAI's pricing page has the current plans and limits. Agenhood is free and MIT licensed: you pay for your server and for model usage on your own keys.