Connect Codex, Claude Code and other tools
Choose your app and operating system, then follow its setup. Sign in to use your API key and available models.
ChatGPT
ChatGPT desktop · Local Codex · Responses
Official docs · Codex gateway setup guideSupported
- Streamed responses
- Function calls
- Local Codex tools including apply_patch
- Usage and cost accounting
Limits and notes
- The Responses endpoint is stateless: stored conversations, previous_response_id, and background mode are unsupported
- Provider-hosted web search and file search are not supported
- This affects new local tasks only; Codex cloud chats are unchanged
- Base URL
- https://router-api.xiu.ai/v1
- Request path
- /v1/responses
- Models
- Open API keys in the XiuAI workspace, then choose Configure client to select a key and an available model.
Before you start
Need to install ChatGPT?
Skip this if ChatGPT is already installed. Otherwise, copy the address below into your browser’s address bar and follow the official installation instructions for your operating system. Continue with the configuration below before entering any XiuAI key.
Browser address bar https://chatgpt.com/download/Check the app and key first
This guide is for local Codex tasks in the current ChatGPT desktop app. Click Get started in the site navigation (open the menu first on mobile), sign in to XiuAI, then open API keys and choose Configure client to select an available key and model. If you are already on the configuration page, make those selections there. The “OpenAI API key” field on the ChatGPT sign-in screen is for the official service; configure XiuAI outside the app first.
Open the command window
Press Command + Space, type Terminal, and press Return. Paste each command into that window and press Return.
1. Quit ChatGPT completely
Choose ChatGPT → Quit ChatGPT in the menu bar, or press Command + Q. Closing the window is not enough.
2. Back up and open the config file
Return to the command window and run the entire block below. It creates the folder and config file if needed, makes a timestamped backup, then opens the file in a text editor without overwriting the existing configuration.
macOS Terminal mkdir -p "$HOME/.codex" touch "$HOME/.codex/config.toml" cp "$HOME/.codex/config.toml" "$HOME/.codex/config.toml.backup-$(date +%Y%m%d-%H%M%S)" open -e "$HOME/.codex/config.toml"The opened file is ~/.codex/config.toml. Its backup is in the same folder with a name starting with config.toml.backup-.
3. Set the model and provider
Put the three lines below at the top of the opened file, before any section starting with [. If model, model_provider, or web_search already exists, update its value instead of adding a duplicate. Keep other settings.
~/.codex/config.toml · top of file model = "YOUR_MODEL_ID" model_provider = "xiurouter" web_search = "disabled"Replace YOUR_MODEL_ID with the exact model ID, or select a model in the XiuAI console to fill it automatically. web_search disables OpenAI-hosted search for the initial test.
4. Add the XiuAI configuration and save
Put the entire block below at the end of the file. If [model_providers.xiurouter] already exists, replace it and its xiurouter.auth subtable if present, without adding duplicates. Keep other providers.
~/.codex/config.toml · end of file [model_providers.xiurouter] name = "XiuAI" base_url = "https://router-api.xiu.ai/v1" env_key = "XIUROUTER_API_KEY" wire_api = "responses"Press Command + S in TextEdit, then close the file. If it uses rich text, choose Format → Make Plain Text first. Keep the filename config.toml.
5. Save the XiuAI key
Return to the command window, copy the entire block below, and run it. Copying in the XiuAI console inserts the selected key. On the public page, replace YOUR_XIUROUTER_API_KEY with your key.
macOS Terminal launchctl setenv XIUROUTER_API_KEY "YOUR_XIUROUTER_API_KEY"Returning to the prompt with no output means the command finished. This lasts for the current sign-in session. After signing out or restarting the computer, repeat this step before opening ChatGPT.
6. Reopen ChatGPT
Open ChatGPT from Applications or the Dock. Complete the first-use setup if shown, switch to Codex, and create a new local task. Existing tasks keep their previous connection.
7. Verify in a new local task
Open a local folder in Codex, create a new task, and send the test message below. After the reply, return to XiuAI workspace → API keys → Configure client → Check a real request and refresh usage. Confirm the selected model, /v1/responses, and a succeeded status.
Composer of a new local Codex task Tell me the current folder name without changing any files.Opening ChatGPT alone does not prove the connection. Confirm the request in XiuAI.
Confirm the connection
Codex answers normally and the console’s verification panel shows a succeeded record on /v1/responses with the model you selected.
Troubleshooting
8Continue in the console
The console fills in your API key and available models, then checks for a matching request.