| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Lightweight coding agent that runs in your terminal
npm i -g open-codex
Important Note: This is a fork of the original OpenAI Codex CLI with expanded model support and changed installation instructions. The main differences in this fork are:
- Support for multiple AI providers (OpenAI, Gemini, OpenRouter, Ollama)
- Uses the Chat Completion API instead of the Responses API which allows us to support any openai compatible provider and model.
- All other functionality remains similar to the original project
- You can install this fork globally with npm i -g open-codex
Codex CLI is an experimental project under active development. It is not yet stable, may contain bugs, incomplete features, or undergo breaking changes. We're building it in the open with the community and welcome:
Help us improve by filing issues or submitting PRs (see the section below for how to contribute)!
Install globally:
npm install -g open-codexNext, set your API key as an environment variable (shown here with OpenAI, but other providers are supported):
export OPENAI_API_KEY="your-api-key-here"Note: This command sets the key only for your current terminal session. To make it permanent, add the export line to your shell's configuration file (e.g., ~/.zshrc).
Run interactively:
open-codexOr, run with a prompt as input (and optionally in Full Auto mode):
open-codex "explain this codebase to me"open-codex --approval-mode full-auto "create the fanciest todo-list app"That's it – Codex will scaffold a file, run it inside a sandbox, install any missing dependencies, and show you the live result. Approve the changes and they'll be committed to your working directory.
Codex CLI is built for developers who already live in the terminal and want ChatGPT‑level reasoning plus the power to actually run code, manipulate files, and iterate – all under version control. In short, it's chat‑driven development that understands and executes your repo.
And it's fully open-source so you can see and contribute to how it develops!
Codex lets you decide how much autonomy the agent receives and auto-approval policy via the --approval-mode flag (or the interactive onboarding prompt):
| Mode | What the agent may do without asking | Still requires approval |
|---|---|---|
| Suggest (default) |
• Read any file in the repo | • All file writes/patches • All shell/Bash commands |
| Auto Edit | • Read and apply‑patch writes to files | • All shell/Bash commands |
| Full Auto | • Read/write files • Execute shell commands |
– |
In Full Auto every command is run network‑disabled and confined to the current working directory (plus temporary files) for defense‑in‑depth. Codex will also show a warning/confirmation if you start in auto‑edit or full‑auto while the directory is not tracked by Git, so you always have a safety net.
Coming soon: you'll be able to whitelist specific commands to auto‑execute with the network enabled, once we're confident in additional safeguards.
The hardening mechanism Codex uses depends on your OS:
macOS 12+ – commands are wrapped with Apple Seatbelt (sandbox-exec).
Linux – we recommend using Docker for sandboxing, where Codex launches itself inside a minimal container image and mounts your repo read/write at the same path. A custom iptables/ipset firewall script denies all egress except the OpenAI API. This gives you deterministic, reproducible runs without needing root on the host. You can read more in run_in_container.sh
Both approaches are transparent to everyday usage – you still run codex from your repo root and approve/reject steps as usual.
| Requirement | Details |
|---|---|
| Operating systems | macOS 12+, Ubuntu 20.04+/Debian 10+, or Windows 11 via WSL2 |
| Node.js | 22 or newer (LTS recommended) |
| Git (optional, recommended) | 2.23+ for built‑in PR helpers |
| RAM | 4‑GB minimum (8‑GB recommended) |
Never run sudo npm install -g; fix npm permissions instead.
| Command | Purpose | Example |
|---|---|---|
| open-codex | Interactive REPL | codex |
| open-codex "…" | Initial prompt for interactive REPL | codex "fix lint errors" |
| open-codex -q "…" | Non‑interactive "quiet mode" | codex -q --json "explain utils.ts" |
| open-codex completion <bash|zsh|fish> | Print shell completion script | codex completion bash |
Key flags: --model/-m, --approval-mode/-a, and --quiet/-q.
Codex merges Markdown instructions in this order:
Disable with --no-project-doc or CODEX_DISABLE_PROJECT_DOC=1.
Run Codex head‑less in pipelines. Example GitHub Action step:
- name: Update changelog via Codex
run: |
npm install -g open-codex
export OPENAI_API_KEY="${{ secrets.OPENAI_KEY }}"
open-codex -a auto-edit --quiet "update CHANGELOG for next release"Set CODEX_QUIET_MODE=1 to silence interactive UI noise.
Setting the environment variable DEBUG=true prints full API request and response details:
DEBUG=true open-codexBelow are a few bite‑size examples you can copy‑paste. Replace the text in quotes with your own task. See the prompting guide for more tips and usage patterns.
| ✨ | What you type | What happens |
|---|---|---|
| 1 | codex "Refactor the Dashboard component to React Hooks" | Codex rewrites the class component, runs npm test, and shows the diff. |
| 2 | codex "Generate SQL migrations for adding a users table" | Infers your ORM, creates migration files, and runs them in a sandboxed DB. |
| 3 | codex "Write unit tests for utils/date.ts" | Generates tests, executes them, and iterates until they pass. |
| 4 | codex "Bulk‑rename *.jpeg → *.jpg with git mv" | Safely renames files and updates imports/usages. |
| 5 | codex "Explain what this regex does: ^(?=.*[A-Z]).{8,}$" | Outputs a step‑by‑step human explanation. |
| 6 | codex "Carefully review this repo, and propose 3 high impact well-scoped PRs" | Suggests impactful PRs in the current codebase. |
| 7 | codex "Look for vulnerabilities and create a security review report" | Finds and explains security bugs. |
npm install -g open-codex
# or
yarn global add open-codex# Clone the repository and navigate to the CLI package
git clone https://github.com/ymichael/open-codex.git
cd open-codex/codex-cli
# Install dependencies and build
npm install
npm run build
# Get the usage and the options
node ./dist/cli.js --help
# Run the locally‑built CLI directly
node ./dist/cli.js
# Or link the command globally for convenience
npm linkCodex looks for config files in ~/.codex/.
// ~/.codex/config.json
{
"model": "o4-mini", // Default model
"provider": "openai", // Default provider
"fullAutoErrorMode": "ask-user" // or ignore-and-continue
}You can also define custom instructions:
# ~/.codex/instructions.md
- Always respond with emojis
- Only use git commands if I explicitly mention you shouldThis fork of Codex supports multiple AI providers:
To use a different provider, set the provider key in your config file:
{
"provider": "gemini"
}OR use the --provider flag. eg. codex --provider gemini
Here's a list of all the providers and their default models:
| Provider | Environment Variable Required | Default Agentic Model | Default Full Context Model |
|---|---|---|---|
| openai | OPENAI_API_KEY | o4-mini | o3 |
| gemini | GOOGLE_GENERATIVE_AI_API_KEY | gemini-2.5-pro-preview-03-25 | gemini-2.0-flash |
| openrouter | OPENROUTER_API_KEY | openai/o4-mini | openai/o3 |
| ollama | Not required | User must specify | User must specify |
export GOOGLE_GENERATIVE_AI_API_KEY="your-gemini-api-key-here"This is a fork of the original OpenAI Codex CLI project with expanded support for multiple AI providers beyond just OpenAI. The installation package is also different (open-codex instead of @openai/codex), but the core functionality remains similar.
How do I stop Codex from touching my repo?Codex always runs in a sandbox first. If a proposed command or file change looks suspicious you can simply answer n when prompted and nothing happens to your working tree.
Does it work on Windows?Not directly. It requires Windows Subsystem for Linux (WSL2) – Codex has been tested on macOS and Linux with Node ≥ 22.
Which models are supported?The default is o4-mini, but pass --model gpt-4o or set model: gpt-4o in your config file to override.
You can also use models from other providers like Gemini and OpenRouter. See the Configuration section for more details.
Note: Codex CLI does not currently support OpenAI organizations with Zero Data Retention (ZDR) enabled.
If your OpenAI organization has Zero Data Retention enabled, you may encounter errors such as:
OpenAI rejected the request. Error details: Status: 400, Code: unsupported_parameter, Type: invalid_request_error, Message: 400 Previous response cannot be used for this organization due to Zero Data Retention.
Why?
What can I do?
We’re excited to launch a $1 million initiative supporting open source projects that use Codex CLI and other OpenAI models.
Interested? Apply here.
This project is under active development and the code will likely change pretty significantly. We'll update this message once that's complete!
More broadly we welcome contributions – whether you are opening your very first pull request or you're a seasoned maintainer. At the same time we care about reliability and long‑term maintainability, so the bar for merging code is intentionally high. The guidelines below spell out what "high‑quality" means in practice and should make the whole process transparent and friendly.
Create a topic branch from main – e.g. feat/interactive-prompt.
Keep your changes focused. Multiple unrelated fixes should be opened as separate PRs.
Use npm run test:watch during development for super‑fast feedback.
We use Vitest for unit tests, ESLint + Prettier for style, and TypeScript for type‑checking.
Before pushing, run the full test/type/lint suite:
npm test && npm run lint && npm run typecheck# Watch mode (tests rerun on change)
npm run test:watch
# Type‑check without emitting files
npm run typecheck
# Automatically fix lint + prettier issues
npm run lint:fix
npm run format:fixIf you run into problems setting up the project, would like feedback on an idea, or just want to say hi – please open a Discussion or jump into the relevant issue. We are happy to help.
Together we can make Codex CLI an incredible tool. Happy hacking! 🚀
To publish a new version of the CLI, run the release scripts defined in codex-cli/package.json:
git add codex-cli/src/utils/session.ts codex-cli/package.json
git commit -s -m "chore(release): codex-cli v$(node -p \"require('./codex-cli/package.json').version\")"Have you discovered a vulnerability or have concerns about model output? Please e‑mail security@openai.com and we will respond promptly.
This repository is licensed under the Apache-2.0 License.
Original project: OpenAI Codex CLI
| Back | FazBrowse Home | New Git URL |