Gemini CLI: Switch or Change Accounts
Save each Gemini CLI account as an aisw profile, then switch with aisw use gemini <profile> and start a new gemini session. Use eligible enterprise sign-ins, Vertex AI or API-key profiles. Individual free, Pro and Ultra Google sign-ins now use Antigravity CLI; an aisw profile does not change that eligibility.
Gemini CLI keeps its eligible enterprise login or API-key configuration under ~/.gemini, and holds one active profile at a time. Switching by hand means signing out and back in, or backing up and swapping that directory yourself. aisw works as a Gemini CLI account switcher: each account becomes a named profile, and changing accounts is one command you can check before you open a repository.
Before you start
Google ended Gemini CLI service for free, Google AI Pro and Google AI Ultra individual sign-ins on June 18, 2026. Enterprise Code Assist and API-key authentication remain available; aisw also supports file-backed Vertex AI profiles. If you want to switch individual Google subscriptions, use the Antigravity CLI account guide instead. Saving an old login does not restore upstream access.
Install aisw if you haven’t already:
brew tap burakdede/tap && brew install aiswCLI method
1. Capture the account you’re currently signed into.
aisw initIf Gemini CLI is already signed in, init detects it and offers to import it as a named profile right in the prompt, accept it and skip the next command. Otherwise, or if you already ran init on this machine before, capture it explicitly:
aisw add gemini work --from-liveRe-running aisw init later is safe, it re-detects live accounts and reports current state without touching profiles you’ve already saved.
2. Add another eligible profile.
aisw add gemini clientFor an eligible enterprise Google sign-in, aisw runs your installed gemini against a temporary directory (it sets GEMINI_CLI_HOME), so the sign-in doesn’t touch your live ~/.gemini. When you finish, it copies the new token cache into the profile and prints the Captured account it found. Sign in with a different eligible enterprise account here. Do not use a free, Pro or Ultra individual sign-in for this Gemini CLI path.
To add an API key instead, keep the key out of your shell history: --from-env reads it from GEMINI_API_KEY, and --api-key-stdin reads it from a pipe.
aisw add gemini work-api-key --from-env3. Switch between them.
aisw use gemini workaisw use gemini client4. Confirm the active profile, then start a new session.
aisw statusaisw verifygeministatus shows the active profile and auth method for each tool. verify checks that the live ~/.gemini files actually match that profile and reports pass or a fix. A Gemini CLI session that was already running keeps the account it started with, so treat a switch as a boundary: switch, check, then launch gemini.
This output illustrates two API-key profiles; use the names you saved in your own setup.
$ aisw list geminiGemini CLI ○ personal [api-key] ○ work-api-key [api-key]
$ aisw use gemini work-api-keyGemini CLI → work-api-key
Auth : api-key Backend : file
Effects Live tool configuration updated. Active profile updated. Backup created before switching.What aisw changes in ~/.gemini when you switch
What a switch writes depends on how the profile signs in:
- Eligible enterprise Google-login profile. aisw restores Gemini-owned files under
~/.geminiand removes stale Gemini-owned files from the previous profile, including its API-key.envwhen selecting OAuth. It preserves Antigravity’santigravity-cli/,antigravity/,antigravity-ide/andconfig/subtrees. - API-key profile. aisw writes
GEMINI_API_KEYto~/.gemini/.envand selectssecurity.auth.selectedType: gemini-api-keyin settings. An imported Vertex AI key profile retains its Vertex provider selection. Writing a key alone would not override an old OAuth provider.
Before switching away from a Google-login profile, aisw checks whether the live ~/.gemini still belongs to the same Google account. If it does, it saves the live files back into that profile first, so token refreshes and local changes from your last session aren’t lost. Every switch also takes a backup first, as the Backup created before switching line shows.
Bind the right account to a repository
Remembering to switch is the weak point. For a repository that must always use your work Gemini account, put the profile in a context and bind the repository to it:
aisw context create work --gemini workaisw workspace bind . --context workaisw workspace guard --mode strictWith the guard in strict mode, the shell hook blocks a gemini launch in that repository when the active profile doesn’t match, instead of letting the session start on the wrong account. Prevent the wrong account in a repository covers the guard modes in detail, and profiles vs contexts explains when a context is worth it. If you also switch Claude Code, Codex CLI or Antigravity, add them to the same context and switch all four tools together.
Desktop method
The current public AI Switcher Desktop release covers macOS, Windows x64, and Linux x64. Download the matching build from the download page, then follow the same Gemini profile flow below.

- Open AI Switcher Desktop and go to Overview.
- In the Gemini CLI column, select the profile you want and click Activate.
- The state-mode badge always reads Isolated for Gemini, this is expected.
The CLI suits shell hooks and scripts; Desktop gives you a visible profile list and diagnostics for the active Gemini state. Both read and write the same profiles.
Common problems
If Google rejects a free, Pro or Ultra individual sign-in, use Antigravity CLI; recapturing that login as an aisw profile will not make it eligible.
If aisw add gemini <name> --from-live reports nothing to import, confirm Gemini CLI has actually completed a sign-in first, aisw can only capture credentials that already exist on disk.
If --from-live prints Both Gemini API key (.env) and OAuth cache were found. Imported .env by precedence., you had both a GEMINI_API_KEY in ~/.gemini/.env and a Google login cached, and aisw saved the profile as an API key profile. To save the Google login instead, move ~/.gemini/.env aside and run the command again with --yes.
If adding a Google login fails with Gemini login completed but no credential files were found in the token cache, the browser sign-in didn’t finish within the two minutes aisw waits. Run aisw add gemini <name> again, or add the account with an API key. aisw also warns that some Google-account logins still require GOOGLE_CLOUD_PROJECT; if your account type does, set it before adding the profile.
If add fails with an error naming a different existing profile, that Gemini account is already saved under that name, aisw checks the underlying Google identity, not just the profile name, and won’t create a duplicate. Use the existing profile or remove it first if you want to re-add it under a new name.
If add fails with “profile already exists” instead, that’s a plain name collision, pick a different name, or re-run with --yes to overwrite the existing profile.
For keeping an eligible work profile and a separate API-key profile apart day to day, see work and personal Gemini CLI accounts.
Frequently asked questions
Can I use Gemini CLI with two Google accounts?
Only if both are eligible enterprise accounts. Google ended Gemini CLI access for free, Pro and Ultra individual sign-ins on June 18, 2026. Use Antigravity CLI for those accounts, or manage supported Gemini API-key and Vertex AI profiles. aisw does not change upstream account eligibility.
How do I switch my Gemini CLI account?
For an eligible enterprise or API-key profile, save the current login with aisw add gemini <profile> --from-live, add the other account with aisw add gemini <profile>, then run aisw use gemini <profile>. Check it with aisw status and start a new gemini session, because a running one keeps the account it started with.
What happens to GEMINI_API_KEY in ~/.gemini/.env when I switch to a Google login?
aisw deletes ~/.gemini/.env as part of applying a Google-login profile, so a key from a previous API key profile doesn't stay behind next to the login you selected. Switching back to an API key profile writes that profile's key again.
Why does Gemini CLI behave differently from Claude Code and Codex CLI here?
aisw can switch only the credentials for Claude Code and Codex CLI and keep the rest of their local configuration shared (the --state-mode option). Gemini CLI keeps its login and local state together under ~/.gemini, so aisw restores Gemini-owned files and --state-mode does not apply. Antigravity-owned subtrees remain untouched; this is one live Gemini directory, not concurrent isolated sessions.
Does an account switcher bypass Gemini usage limits?
No. aisw only manages which saved login or key is active on your machine. Each account signs in through Gemini CLI's normal flow and keeps its own quotas and terms.