Run Codex CLI on Olares
Codex CLI is OpenAI's open-source coding agent for the terminal. It can inspect a repository, edit files, run commands and tests, and help you understand unfamiliar code through natural-language requests.
On Olares, Codex CLI runs inside a browser-based terminal with a preconfigured development environment. You can connect it to ChatGPT, use an OpenAI API key, or route it to a local OpenAI-compatible model.
Learning objectives
In this guide, you will learn how to:
- Install Codex CLI from Market.
- Connect Codex to ChatGPT, an OpenAI API key, or a local model.
- Run coding tasks and review the results.
- Switch model connections and clear stored credentials.
- Authenticate Olares CLI for Olares management tasks.
Prerequisites
Before you begin, you need:
An Olares device running Olares 1.12.6 or later, with sufficient disk space and memory.
A ChatGPT account with Codex access, if you plan to connect using ChatGPT.
An OpenAI API key, if you plan to connect through OpenAI Platform.
A local model optimized for coding running on your Olares device, if you plan to use local execution. This guide uses the following model:
Model type Model How to get it Chat Qwen3.6-27B MTP (llama.cpp) Install from Market
Optional: Use a different model
You can use a different model size or provider instead of the one listed above:
- Install a different model app from Market.
- Create a model instance from Engine Base apps to bring your own model.
If your AI agent app has the Olares CLI and Agent Skills installed, ask it to deploy the model and skip the manual setup. For example:
Deploy qwen3.5:9b on my Olares using the Ollama Engine Base.Install Codex CLI
- Open Market and search for "Codex CLI".
- Click Get, then Install, and wait for installation to complete.
Connect to a model
Choose one connection method. ChatGPT device code authentication is the simplest option in the browser-based Olares terminal.
Connect with ChatGPT
Codex's standard browser login returns credentials to a callback service on localhost:1455. In the Olares container, your computer's browser cannot reach that callback directly. Use device code authentication instead.
Open Codex CLI from Launchpad.
Run:
bashcodex login --device-authOpen the URL shown in the terminal, sign in to ChatGPT, and enter the one-time code.

If device code login is unavailable, enable it in your ChatGPT security settings or ask your workspace administrator to allow it.
Return to the terminal and check the active authentication method:
bashcodex login status
Fallback: Complete the browser callback inside the container
Use this method only when device code authentication is unavailable.
In the first Codex CLI terminal, run
codex loginand keep the process running.Complete the browser sign-in. When the browser opens a URL beginning with
http://localhost:1455/auth/callback, copy the complete URL from the address bar.Open Codex CLI in a second browser tab. Replace
localhostwith127.0.0.1, keep the query string unchanged, and run the URL withcurl:bashcurl -i "http://127.0.0.1:1455/auth/callback?code=<code>&scope=<scope>&state=<state>"Confirm that the response is
302 Foundand itsLocationheader contains/success.Return to the first terminal and run
codex login status.
The authorization code and callback URL are short-lived credentials. Do not share them or include them in screenshots.
Connect with an OpenAI API key
Use this method to bill Codex usage through your OpenAI Platform account.
- Navigate to Settings > Applications > Codex CLI > Manage environment variables.
- Set OPENAI_API_KEY to your OpenAI API key.
- Click Apply and wait for Codex CLI to restart.
- Open Codex CLI from Launchpad and run
codex.
Connect with a local model
This example connects Codex CLI to Qwen3.6-27B MTP (llama.cpp) through its OpenAI-compatible API.
Get the model connection details
Open Qwen3.6-27B MTP (llama.cpp) from Launchpad. Its Model Console opens automatically.
Wait until Model shows READY and Engine shows RUNNING.
Under Model, copy the Model name exactly as shown.
Under Engine:
a. For Connection source, select Apps in Olares.
b. For API format, select OpenAI-Compatible.
c. Copy the Base URL exactly as shown.
Configure Codex CLI
Navigate to Settings > Applications > Codex CLI > Manage environment variables.
Configure the following variables:
- OPENAI_BASE_URL: Paste the Base URL copied from Model Console exactly as shown, including the trailing
/v1. - OPENAI_API_KEY: Enter a non-empty placeholder value, such as
olares. The local model app does not require a real OpenAI key for requests from another app in the same Olares cluster. - CODEX_MODEL: Enter the exact Model name copied from Model Console.

- OPENAI_BASE_URL: Paste the Base URL copied from Model Console exactly as shown, including the trailing
Click Apply and wait for Codex CLI to restart.
Open Codex CLI from Launchpad and run:
bashcodex
Use Codex CLI
All project work happens in the /opt/data directory. Files stored there persist across app restarts.
Check the installed CLI version:
bashcodex --versionStart an interactive session:
bashcodexDescribe a focused task. For example:
textRead the current directory and summarize the project structure.Or ask Codex to create a small file:
textCreate a minimal README draft for this repository.Review the proposed commands and file changes before approving them.
Inspect the result and ask a follow-up question or request another change.

Manage Olares with Olares CLI
Codex authentication only grants access to the selected model service. To ask Codex to install Olares apps, inspect cluster status, or perform other Olares management tasks, authenticate Olares CLI separately:
olares-cli profile login --olares-id <your-olares-id>Complete two-factor authentication when prompted. For more details, see Log in to Olares CLI.
Switch connections or sign out
Switch from ChatGPT to an OpenAI API key
Set OPENAI_API_KEY in Settings > Applications > Codex CLI > Manage environment variables, click Apply, and wait for the app to restart.
Switch from an OpenAI API key to ChatGPT
Clear OPENAI_API_KEY, click Apply, and wait for the app to restart. Then run codex login --device-auth.
Switch from a local model to OpenAI
Clear OPENAI_BASE_URL and CODEX_MODEL. Keep a real OPENAI_API_KEY for API key authentication, or clear it and use ChatGPT authentication. Click Apply and wait for the app to restart.
Sign out
Run:
bashcodex logout codex login statusContinue when the status shows that Codex is signed out.
Signing out clears stored Codex credentials, but it does not remove OPENAI_API_KEY from the app environment or sign out Olares CLI.
FAQs
Why does browser login stop at localhost:1455?
The callback service runs inside the Codex CLI container, so your computer's browser cannot reach it through its own localhost. Use codex login --device-auth. If device code authentication is unavailable, use the callback fallback described in Connect with ChatGPT.
Why does Codex still use the local model after I sign in to ChatGPT?
OPENAI_BASE_URL and CODEX_MODEL still route Codex to the local service. Clear both variables in the app settings, click Apply, and wait for the app to restart.
Why does the local model return 404?
Open the model's Model Console and copy its Base URL again. Select OpenAI-Compatible and use the URL exactly as displayed, including /v1. Also confirm that Model shows READY and Engine shows RUNNING.
Why does Codex report model not found?
Compare CODEX_MODEL with the Model name in Model Console. The values must match exactly.
How do I remove a remaining login file?
First run codex logout. If codex login status still reports a stored login, remove the app's credential file and check again:
rm -f /opt/data/.codex/auth.json
codex login statusThis command only removes Codex credentials stored in the app data. It does not clear OPENAI_API_KEY or affect Olares CLI authentication.
What if Codex reports missing agentic execution capabilities?
Update the Codex binary in the app data directory:
curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_INSTALL_DIR=/opt/data/.local/bin shRestart the Codex CLI session and try again.
Learn more
- Codex CLI documentation: Learn about Codex CLI workflows and commands.
- Codex authentication: Review ChatGPT, API key, and headless login options.
- Host local large language models with Engine Base apps: Deploy and manage models through Model Console.
- Install Olares CLI: Set up Olares management commands and agent skills.