Codex Client
Write ~/.codex so the Codex desktop app and IDE plugin call 58API at https://api.58api.net/v1, including a manual config.toml and checks when authentication fails.
Scope
This guide applies to Codex desktop clients, Codex IDE extensions, and Codex clients that read the local ~/.codex configuration directory. After setup, Codex will call models through the 58API relay.
Before You Start
- Sign in to 58API.
- Make sure your account has balance.
- Create an API key in the 58API console.
- Install the Codex client or the related IDE extension.

How It Works
Codex clients read configuration from the local Codex directory:
| File | Purpose |
|---|---|
~/.codex/config.toml | Sets the model, provider, API endpoint, API key, and protocol |
~/.codex/auth.json | OpenAI account login cache; normal 58API setup no longer writes API keys here |
Use the following values for the 58API relay:
| Option | Value |
|---|---|
| API base URL | https://api.58api.net/v1 |
| API key | The key created in the 58API console |
| Model | gpt-6.1-sol |
| Protocol | responses |
One-Click Setup
Windows
Open PowerShell and run:

The script's prompts are in Chinese; the values are the same as in the text.
Configure Codex Client
The one-click script only writes the 58API configuration for Codex. It does not install a proxy and does not change the system proxy.
curl.exe --ssl-no-revoke -fsSL https://58api.net/helper/codex-client-setup.ps1 -o "$env:TEMP\codex-client-setup.ps1"
PowerShell -NoProfile -ExecutionPolicy Bypass -File "$env:TEMP\codex-client-setup.ps1"Enter the following when prompted:
- API base URL (prompt
API 基础地址 [https://api.58api.net]): press Enter to use the defaulthttps://api.58api.net; the script adds/v1automatically. - API key: paste the key created in the 58API console (the input is not shown on screen; just press Enter after pasting).
The script writes (or config.toml in the CODEX_HOME directory, if that variable is set):
%USERPROFILE%\.codex\config.tomlWhen it finishes, the terminal shows API 基础地址: https://api.58api.net/v1 (API base URL) and 已写入: …\config.toml (written to).
Your existing config.toml is overwritten
The script rewrites the whole config.toml with only the 58API settings. Existing MCP servers, project trust entries, other providers and similar settings are not kept. The script first backs up the old file as config.toml.bak.<timestamp> (the terminal shows 已备份原配置: …); to keep your old settings, merge them back manually from the backup.
The script stores the 58API key in the active provider's experimental_bearer_token instead of relying on auth.json.OPENAI_API_KEY, avoiding API_KEY_REQUIRED / 401 Unauthorized errors in newer Codex builds.
macOS / Linux
Open Terminal and run:

The script's prompts are in Chinese; the values are the same as in the text.
bash <(curl -fsSL https://58api.net/helper/codex-client-setup.sh)Enter the following when prompted:
- API base URL (prompt
API 基础地址 [https://api.58api.net]): press Enter to use the defaulthttps://api.58api.net; the script adds/v1automatically. - API key: paste the key created in the 58API console (the input is not shown on screen; just press Enter after pasting).
The script writes (or config.toml in the CODEX_HOME directory, if that variable is set):
~/.codex/config.tomlWhen it finishes, the terminal shows API 基础地址: https://api.58api.net/v1 (API base URL) and 已写入: …/config.toml (written to).
Your existing config.toml is overwritten
The script rewrites the whole config.toml with only the 58API settings. Existing MCP servers, project trust entries, other providers and similar settings are not kept. The script first backs up the old file as config.toml.bak.<timestamp> (the terminal shows 已备份原配置: …); to keep your old settings, merge them back manually from the backup.
The macOS / Linux one-click setup script also uses the provider-scoped experimental_bearer_token and does not write the 58API key to auth.json.
Manual Setup
You can also create the files manually.
config.toml
Write this to ~/.codex/config.toml:
model = "gpt-6.1-sol"
model_provider = "58API"
model_reasoning_effort = "high"
[model_providers.58API]
name = "58API"
base_url = "https://api.58api.net/v1"
wire_api = "responses"
supports_websockets = false
experimental_bearer_token = "sk-your-58API-key"auth.json
Do not put the 58API key in auth.json for the current Codex configuration. Keep auth.json only as the OpenAI account login cache; model requests should use the provider-scoped experimental_bearer_token in config.toml.
Start the Client
After configuration, reopen the Codex client or restart your IDE.
If the client is already running, fully quit and start it again so it reloads ~/.codex/config.toml and ~/.codex/auth.json.
Verify Requests
- Start a simple task in the Codex client.
- Open the 58API console.
- Check Usage Logs for the corresponding request.

If the request appears in Usage Logs, the Codex client is using the 58API relay.
Troubleshooting
The client still uses the official account
Confirm that the client supports the local ~/.codex configuration. Some official cloud Codex entries only use ChatGPT account login and do not support a third-party API endpoint, so they cannot be relayed through 58API.
Authentication failed
Check that experimental_bearer_token under [model_providers.58API] (or your active provider) in config.toml is complete, with no leading or trailing spaces or line breaks.
If API_KEY_REQUIRED or 401 Unauthorized appears after a ChatGPT / Codex update, re-run the one-click setup script above so the active provider's experimental_bearer_token is rewritten.
Model unavailable
Confirm that your 58API account can use gpt-6.1-sol (your token's group must include it; if it does not, use gpt-6-astra). If your account uses a different Codex-compatible model, update the model field in config.toml.
The desktop model picker shows Custom or no models
This is a known display issue in the Codex desktop app with custom providers and does not affect requests. The model actually used is the model value in config.toml; to switch models, change that line (for example to gpt-6-astra), then fully quit and reopen the client.
Changes do not take effect
Fully quit the Codex client or IDE and reopen it. If needed, remove old official login cache and run the one-click setup script again.
Claude Code
Connect Claude Code on Windows, macOS, and Linux to 58API: set ANTHROPIC_BASE_URL to https://api.58api.net (no /v1) and ANTHROPIC_AUTH_TOKEN to a console token.
OpenAI Codex CLI
Install Codex CLI on Windows (WSL), macOS, and Linux, and set base_url in ~/.codex/config.toml to https://api.58api.net/v1 with a 58API token.