Authentication
How Mogplex resolves stored credentials, when account login is enough, and what bare `mogplex`, `/login`, and `/logout` mean in the CLI.
Mogplex can run with either direct provider credentials or your Mogplex account. When a session starts, it resolves auth in this order.
Resolution order
-
Environment variable first. If a provider env var is set in your shell, Mogplex uses it.
Provider Environment variable Mogplex MOGPLEX_API_KEYAnthropic ANTHROPIC_API_KEYOpenAI OPENAI_API_KEYGoogle GOOGLE_GENERATIVE_AI_API_KEYGroq GROQ_API_KEYMistral MISTRAL_API_KEYDeepSeek DEEPSEEK_API_KEYxAI XAI_API_KEYCohere COHERE_API_KEYVercel VERCEL_API_TOKEN -
Fallback to stored credentials. If the env var is not set, Mogplex reads
~/.mogplex/auth.json. -
Stored Mogplex account login. If the only stored credential is your Mogplex browser login, the CLI starts against your account-backed model access and synced catalog.
-
No credentials → startup prompt or clear error. In interactive TTY startup, bare
mogplexprompts you to either sign in with Mogplex or store a provider API key. In non-interactive contexts it exits with a clear message telling you to runmogplex.
Mogplex account login
Running mogplex and choosing Sign in with Mogplex opens the webapp login
flow and stores a mogplex token in ~/.mogplex/auth.json.
That login now does three things for the CLI:
- unlocks your synced model catalog
- unlocks synced MCP configuration
- runs prompts through the model access configured for your Mogplex account
If your account does not have model access yet, add an AI Gateway, OpenAI, or Anthropic key in Settings > API Keys.
/login
Use mogplex as the normal entrypoint:
mogplexIf you prefer to jump straight into the auth flow, mogplex login opens the
same chooser.
Inside the TUI, /login still works for storing direct provider keys when you
want the CLI to use a specific provider credential locally.
Provider keys
Direct provider credentials still work and still take precedence over the account login path. This is useful for shell-driven setups and CI.
export OPENAI_API_KEY=sk-...
mogplex/logout
Removes the stored key from ~/.mogplex/auth.json.
Two things to know:
- If the matching env var is set, the next session still authenticates via the env var. This is by design — env vars are the source of truth for shell-driven setups.
- If you log out of Mogplex, synced models and MCP entries disappear on the next startup.
Logging and credential safety
Session logs at ~/.mogplex/logs/<session-id>.jsonl never contain:
- API keys or OAuth tokens
- Contents of
~/.mogplex/auth.json
All data is redacted before it is written to disk.
When MOGPLEX_DEBUG=1 is set, debug logs also capture stream chunks and tool
outputs. These may include prompt or tool content, so treat debug logs with the
same care as your source code.