Connect Codex to ModelGo: Setup & Troubleshooting
Codex is OpenAI's command-line coding assistant. A custom model_provider sends its Responses API requests to ModelGo. Before you start, create an API key in the ModelGo console and pick a logical model name your key can call from the Model Catalog.
1. Install
bash
npm install -g @openai/codex
codex --versionIf the first launch offers an update, you can choose Skip for now.

2. Configure ModelGo
Edit ~/.codex/config.toml (Windows: %USERPROFILE%\.codex\config.toml):
toml
model_provider = "modelgo"
model = "your-model-id"
[model_providers.modelgo]
name = "ModelGo"
base_url = "https://api.modelgo.ai/v1"
env_key = "MODELGO_API_KEY"
wire_api = "responses"Put the API key in an environment variable, not in config.toml (Windows PowerShell: [Environment]::SetEnvironmentVariable("MODELGO_API_KEY", "mgk_your_api_key", "User")):
bash
echo 'export MODELGO_API_KEY="mgk_your_api_key"' >> ~/.zshrc
source ~/.zshrc3. Start and verify
Run codex in a project directory, trust the directory when prompted, and send a simple request. A normal reply means the setup works.


To check the key and the models it can call:
bash
curl https://api.modelgo.ai/v1/models \
-H "Authorization: Bearer $MODELGO_API_KEY"Troubleshooting
- Provider not found: the file must be
~/.codex/config.toml, andmodel_providermust match[model_providers.modelgo]. - 401: make sure
MODELGO_API_KEYis set in the current terminal, with no extra spaces or line breaks. - 403 / model unavailable:
modelmust be a logical model name your API key can call. - 404:
base_urlmust behttps://api.modelgo.ai/v1, not the full/v1/responsespath. - Chat wire API deprecation warning: set
wire_api = "responses"and upgrade withnpm install -g @openai/codex@latest. 400 invalid_encrypted_content: the conversation carries encrypted context from another upstream account; start a new conversation.