To use your ChatGPT plan in the terminal, install OpenAI's Codex CLI, run codex in a project folder and choose Sign in with ChatGPT. OpenAI's docs say Codex is included in ChatGPT plans, and local terminal work draws on the same allowance as Codex in the cloud. An API key is the alternative, billed at API rates instead.
There is a second option if you want security built into the same session. Bring the Claude, ChatGPT or Codex plan you already pay for and use it inside the Safeguard CLI. Safeguard adds no extra charge for that usage; your plan's own usage limits and terms still apply. You can also connect ChatGPT to the Safeguard MCP server and use Safeguard from the chat you already work in.
This guide walks through both routes with real commands: sign-in, credential storage, usage limits, remote login, approval settings and common mistakes. Facts about OpenAI's tools come from OpenAI's own docs and repository, linked at the end.
What a ChatGPT plan covers in the terminal
A ChatGPT plan is a subscription to OpenAI's chat product, billed separately from the OpenAI API. For coding, what it gives you is Codex, OpenAI's coding agent, and Codex has a terminal client.
OpenAI's pricing docs say "ChatGPT Work and Codex are included in your ChatGPT Free, Go, Plus, Pro, Business, Edu, or Enterprise plan." The Codex CLI README names Plus, Pro, Business, Edu and Enterprise as plans you can sign in with. If you are on Free or Go, check the pricing page for what your plan includes before you rely on it for daily work.
Beyond the plan name, these details matter:
- One shared allowance. The pricing docs say "Local messages and cloud chats share your plan's usage allowance." Work you do in the terminal and tasks you run in Codex Cloud come out of the same pool.
- Five-hour and weekly windows. Plus and standard Business plans have local message estimates per five-hour period, and the docs add that "Weekly limits may also apply." The docs say Pro plans currently have no five-hour limit. Usage depends on the model, the size of the task and the tools used, so the estimates are not fixed numbers.
- What happens at the limit. If you hit a limit during an active turn, the agent can finish that turn, subject to fair use. Plus and Pro users can buy additional credits to keep going. Business, Edu and Enterprise plans with flexible pricing can buy workspace credits.
An API key works differently. OpenAI's auth docs say API key sign-in follows your API organization's retention and data sharing settings and bills at standard API rates "instead of ChatGPT plan credits." The pricing docs add that API key sessions do not draw on plan limits. Some people keep both: the plan for interactive work and a key for extra local chats once the plan's window is used up.
If you are comparing Codex with other agents more broadly, our guide to OpenAI Codex alternatives covers the wider field.
Set up Codex CLI with your ChatGPT plan, step by step
Codex CLI is open source under Apache 2.0. Its README describes it as "a coding agent from OpenAI that runs locally on your computer." It reads your code, makes changes and runs commands in the folder you start it in.
Step 1: Install
Pick one installer. On macOS or Linux:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
On Windows PowerShell:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
Or use a package manager:
npm install -g @openai/codex
# or
brew install --cask codex
The README says the standalone installers download from releases.openai.com and fall back to GitHub Releases. The CLI docs say the same install command also updates an existing install.
Step 2: Sign in with ChatGPT
Open a project folder and start Codex:
cd ~/code/my-service
codex
The CLI docs say: "The first time you run Codex, choose Sign in with ChatGPT or another available sign-in method." A browser window opens, you sign in to ChatGPT, and the CLI picks up the session. You can also sign in without starting a session:
codex login # ChatGPT sign-in, the default
codex login status # check which credential is active
If you belong to more than one ChatGPT workspace, the sign-in flow asks which one to use. With a ChatGPT sign-in, the auth docs say Codex usage follows your workspace permissions, role-based access and, on Enterprise, its retention and residency settings.
Step 3: Know where the credential lives
The auth docs say cached logins are saved in ~/.codex/auth.json or in your OS credential store, and the CLI and IDE extension share the same cached login. The cli_auth_credentials_store setting accepts four values: file, keyring, auto (keyring when available, otherwise the file) and ephemeral (memory only, for the current process). ChatGPT session tokens refresh before they expire.
The docs are blunt about the file: treat auth.json like a password. Do not commit it, do not bake it into a shared container image, and do not paste it into a ticket.
Step 4: Pick a safe starting mode
Codex separates two ideas. The sandbox mode sets what Codex can technically do. The approval policy sets when it must ask you first.
The Auto preset, which is what codex uses with no flags in a version-controlled folder, pairs workspace-write with on-request. Codex can edit files and run commands inside the workspace and asks before going outside it, for example to write elsewhere or reach the network. The approvals docs say network access is off by default, and that .git, .agents, .codex and .aws stay read-only even inside a writable workspace. In a folder that is not under version control, the docs recommend read-only, and Codex may start read-only until you trust the folder.
You can switch modes mid-session with /permissions, or start with flags:
# Look around without changing anything
codex --sandbox read-only --ask-for-approval on-request
The docs list --dangerously-bypass-approvals-and-sandbox, with the alias --yolo, and mark it "not recommended."
Step 5: Learn the handful of commands you will use daily
The CLI docs show these inside a session: /init writes an AGENTS.md file with instructions for Codex, /status shows the session configuration, /permissions changes what Codex may do, /model chooses the model and reasoning effort, and /review reviews your changes. Outside a session, codex resume reopens a recent chat from the current repository, codex exec runs Codex from scripts and pipelines, and codex mcp adds local or remote MCP servers.
Worked examples: ChatGPT sign-in in real situations
The basic flow is simple on a laptop. These are the cases that need a little more care.
Example 1: Signing in on a remote server or in SSH
A headless machine has no browser to complete the ChatGPT sign-in. The auth docs list a preferred route and two fallbacks.
The preferred route is device code login, marked beta. You first enable device code login in your ChatGPT security settings (or a workspace admin enables it in workspace permissions). Then:
codex login --device-auth
Open the link on any device, sign in and enter the one-time code.
If you cannot use device codes, the docs describe forwarding the local callback port over SSH and signing in from that session:
ssh -L 1455:localhost:1455 user@remote
# then, on the remote host
codex login
The last fallback is to sign in on a machine with a browser and copy ~/.codex/auth.json to the remote host. The docs note this does not work if your credentials live in an OS credential store. If you take this route, remember the file is a password.
Example 2: Falling back to an API key when the plan window runs out
You hit your five-hour window partway through an afternoon. You can wait, buy credits if your plan allows it, or switch to an API key for local work:
printenv OPENAI_API_KEY | codex login --with-api-key
codex login status
That session now bills at API rates and does not draw on your plan. When you want to go back, run codex login and choose ChatGPT again. Run codex login status after any switch so you know which one is paying.
Example 3: Running Codex in a pipeline
For automation, the CLI docs say to "call codex exec from repeatable workflows and pipelines." A minimal call looks like this:
codex exec "list the files that changed in this branch and summarise the risk"
The approvals docs list --sandbox read-only with --ask-for-approval never as the read-only, non-interactive combination for CI.
For pipelines on ChatGPT Enterprise, the auth docs say admins can let members create Codex access tokens for trusted non-interactive workflows, used with codex login --with-access-token. Codex Cloud, the hosted agent, always requires a ChatGPT sign-in.
Example 4: Making a team use the right workspace
If you manage a team, the auth docs describe admin settings that pin sign-in: forced_login_method set to "chatgpt" or "api", and forced_chatgpt_workspace_id. If the active credentials do not match, Codex logs the user out and exits. That stops a developer from quietly using a personal plan on company code.
Other terminal tools that accept a ChatGPT sign-in
Codex CLI is OpenAI's own client. Two open-source projects also offer a way to use a ChatGPT plan from your machine. Both are described here only from their own docs and repositories.
OpenCode. OpenCode is "the open source AI coding agent", MIT licensed, with a terminal UI and a beta desktop app. Its providers docs say that in the /connect menu "you can select the ChatGPT Plus/Pro option and it'll open your browser and ask you to authenticate." The same page lists 75 or more providers. Know before adopting: its README says the default build agent has full access, while a separate plan agent is read-only and asks before running bash. We cover the project in open-source OpenCode alternatives.
T3 Code. T3 Code is an MIT-licensed "agent harness control surface" with desktop, web and mobile clients. It does not ship its own model. It drives agents already set up on your computer, including Codex, and the README says you log in through the vendor's own CLI, for example codex login. Know before adopting: the README warns "We are very very early in this project. Expect bugs."
The comparison below sticks to what each source states. "Where the work runs" means where the tool executes; your prompts and the files the agent reads still go to the model provider.
| Route | Interface | Licence | How the ChatGPT plan is used | Where the work runs | Approvals by default |
|---|---|---|---|---|---|
| Codex CLI | Terminal | Apache 2.0 | Sign in with ChatGPT on first run or codex login | Your machine | Auto preset: workspace writes, asks to go outside |
| OpenCode | Terminal UI, beta desktop app | MIT | ChatGPT Plus/Pro option in /connect | Your machine | Build agent has full access; plan agent is read-only |
| T3 Code | Desktop, web, mobile | MIT | Through Codex after codex login | Your machine | Set by the agent it drives |
| Safeguard CLI | Terminal | Safeguard product | Bring your plan, no extra Safeguard charge | Your machine; only results go to the platform | Auto: approves known actions, asks for new ones |
| ChatGPT with Safeguard MCP | ChatGPT app | Hosted service | Your normal ChatGPT use | Safeguard-hosted server | You choose which tools are enabled |
Check each project's docs and your plan's terms before signing in.
Do the work properly with the Safeguard CLI
The Safeguard CLI is a terminal assistant that also knows your vulnerabilities. It scans code, container images and SBOMs on your own machine, sends only the results to the Safeguard platform, and includes an assistant that can fix what it finds. It writes code too, not only scans. If you want one terminal session where an assistant edits your project and checks the dependencies it touched, this is the route.
Keep the plan you already pay for
Switching does not mean giving up your subscription. Bring the Claude, ChatGPT or Codex plan you already pay for and use it inside the Safeguard CLI. Safeguard adds no extra charge for that usage; your plan's own usage limits and terms still apply. To connect a model, see the CLI docs or run /model in a session, which shows or switches the model. Read your provider's terms for the plan you connect, the same way you would for any tool.
Safeguard also has its own models, and a tenant admin decides which model families people may use. The next demo shows choosing a model per conversation, including bringing your own model on your own provider account and routing jobs such as chat or summaries to it.
Click through it at your own pace, or open it full screen.
Install
The CLI is one static binary with no Node, Python or JVM to install. It runs on macOS, Linux and Windows, on x86_64 or arm64, with Windows on x86_64 only.
# macOS and Linux
curl -fsSL https://cli.safeguard.sh/install | bash
# Windows
irm https://cli.safeguard.sh/install.ps1 | iex
First session
Run safeguard with no arguments to open the interactive terminal. Type /login to sign in through your browser, then /scan . to scan the current folder. After that you can ask in plain language, for example "how many critical vulns do we have". Type @ to attach a file from the folder you started in, and /resume to pick up your last session in that folder.
Writing and fixing code on your machine
The assistant has tools for your local files and for your Safeguard data, and picks whichever a question needs. The docs give examples such as "what's the latest file in ~/Downloads" and "fix the lodash CVE in this repo." So you can use it as a general terminal assistant: find and read files, edit code and run commands, with your approval, plus everything on the security side. For a longer tour, read the Safeguard CLI as an AI assistant on your machine.
Approvals
Tools that change things, such as writing a file, editing code or running a command, ask before they act. /permissions sets the mode: Ask prompts before every action, Auto approves known actions and asks for anything new (the default), and Yolo approves everything. Start in Ask on an unfamiliar repository.
Scans and CI with safeguard exec
The same binary works without the interactive terminal:
safeguard scan --dir .
safeguard scan --image my-api:latest
safeguard exec "summarise the critical findings in this repository"
safeguard scan builds an SBOM and matches it against vulnerability databases, and also takes --repo with a URL or --sbom with a file. Results land as JSON files under ./output, including vuln.json and license.json. safeguard validate checks CycloneDX, SPDX and VEX documents. safeguard exec runs one non-interactive assistant turn, which is what you want in CI. When the local runner runs platform scan jobs, your source code never leaves the machine; only SBOMs and findings are uploaded. Policies and gates are evaluated in the platform, not by the CLI.
Use Safeguard from ChatGPT itself
If you would rather stay in the ChatGPT app, connect it to the Safeguard MCP server. Safeguard's docs describe adding a custom MCP server in ChatGPT with the URL https://mcp.safeguard.sh/mcp, choosing OAuth, and authorising access on Safeguard's sign-in page. Nothing is installed locally, and a new workspace starts with a small read-only tool set that an administrator can widen. Account and workspace policies on the ChatGPT side apply, so ask your workspace admin if you do not see the option.
Click through it at your own pace, or open it full screen.
One platform on every surface
The terminal is one way in. The download page lists a desktop app for Windows, macOS and Linux (version 3.2.2), iOS and Android apps, IDE extensions for VS Code, JetBrains and Open VSX, and a Chrome browser extension. There are also cloud options with nothing to install: the web interface, a Cloud CLI that runs on Safeguard's infrastructure, and a cloud sandbox tenant against a seeded demo repo, free for seven days with no card. Start a fix in the terminal, review it on the desktop and check the findings on your phone.
Common mistakes
Leaving an API key in your shell. If OPENAI_API_KEY is exported in your profile and you signed in with that key once, you may be billing API rates while assuming your plan is paying. Run codex login status before a long session.
Copying auth.json around casually. The copy-the-cache fallback for remote hosts is real, but the file is a credential. Prefer device code login, and remove the file from hosts you no longer use with codex logout.
Assuming terminal and cloud have separate allowances. They share one pool. A long Codex Cloud task in the morning means less terminal headroom in the afternoon.
Reaching for full access to save clicks. The --yolo alias exists, and OpenAI's docs mark it not recommended. Auto already lets Codex edit and run inside the workspace. Use read-only for exploration and Auto for work.
Signing a third-party tool in without reading the terms. A tool offering a ChatGPT sign-in does not change what your plan allows. Read the provider's terms for the plan before connecting it anywhere. Anthropic's terms are stricter for Claude plans, which we cover in the FAQ.
Merging without scanning what the agent changed. Agents add and bump dependencies. Run a scan on the branch before you merge, whichever agent wrote the code. Our guide on checking coding agent changes with the Safeguard CLI shows the pattern.
FAQ
Can I use ChatGPT Plus in the terminal?
Yes. Install Codex CLI, run codex and choose Sign in with ChatGPT. The Codex README names Plus among the plans you can sign in with, and OpenAI's pricing docs list Plus as including Codex. Plus has a local message estimate per five-hour window, and weekly limits may apply.
Does terminal use count against my ChatGPT plan?
Yes, when you sign in with ChatGPT. OpenAI's pricing docs say local messages and cloud chats share your plan's usage allowance. Sessions signed in with an API key bill at API rates and do not draw on plan limits.
Can I use my ChatGPT plan inside the Safeguard CLI?
Yes. Bring the Claude, ChatGPT or Codex plan you already pay for and use it inside the Safeguard CLI. Safeguard adds no extra charge for that usage; your plan's own usage limits and terms still apply. See the CLI docs or /model for connecting a model.
If I switch to Safeguard, do I lose ChatGPT?
No. You can keep using your plan in the Safeguard CLI, and you can connect ChatGPT to the Safeguard MCP server so the chat you already use can call Safeguard tools after you sign in with OAuth.
How do I sign in to Codex on a server without a browser?
Use device code login: enable it in your ChatGPT security settings, then run codex login --device-auth. The auth docs list an SSH tunnel on port 1455 and copying auth.json as fallbacks.
Can I use a Claude Pro or Max plan in other terminal tools the same way?
Check Anthropic's terms first. Anthropic's Claude Code legal page says subscription sign-in is intended for Claude Code and Anthropic's native apps, and that third-party developers may not route requests through Free, Pro or Max credentials for their users. OpenCode's providers docs state that Anthropic prohibits plugins that use Claude Pro or Max models in OpenCode.
Does the Safeguard CLI send my source code anywhere?
When the local runner runs platform scan jobs, source code stays on your machine and only SBOMs and findings are uploaded. The model you connect still receives what you send it in a conversation, as with any assistant.
Try it yourself
This demo walks through setting up the runner on your own machine: pick the platform, start it, approve it with its device code, then use the same CLI to scan from the terminal.
Click through it at your own pace, or open it full screen.
When you are ready, download the Safeguard CLI and read the CLI docs to connect the plan you already have.
Quick check
Which command signs Codex CLI in with a ChatGPT plan on a machine with no browser?
codex login --device-auth, after device code login is enabled in your ChatGPT security settings or by a workspace admin.
What does Safeguard charge for using your ChatGPT plan inside the Safeguard CLI?
Nothing extra. Safeguard adds no extra charge for that usage; your plan's own usage limits and terms still apply.
Do local Codex CLI messages and Codex Cloud tasks have separate allowances?
No. OpenAI's pricing docs say local messages and cloud chats share your plan's usage allowance.
Sources
- OpenAI Codex repository and README
- Codex docs: CLI
- Codex docs: Authentication
- Codex docs: Pricing and plans
- Codex docs: Agent approvals and security
- OpenCode repository
- OpenCode docs: Providers
- T3 Code repository
- Claude Code docs: Legal and compliance
- Safeguard CLI docs
- Safeguard CLI docs: Interactive terminal
- Safeguard CLI docs: Slash commands
- Safeguard MCP docs: Connect ChatGPT
- Safeguard downloads
Last reviewed: 21 October 2026.