Codex access
Codex is a programming tool that can be used on the command line and in an editor. This page uses a custom model service and the Responses request format. The following uses qwen3.8-flash and this site’s /v1/responses interface.
If not yet installed, follow OpenAI Codex getting started to install the client.
Manual configuration
Open the configuration file in the user directory and merge the following contents:
- Windows:
%USERPROFILE%\.codex\config.toml - macOS / Linux:
~/.codex/config.toml
Official current description: model_provider and model_providers in .codex/config.toml in the project will be ignored, so the model service configuration should be placed in the above user file.
model = "qwen3.8-flash"
model_provider = "shanhai"
[model_providers.shanhai]
name = "ShangHai Do"
base_url = "https://shanghaido.com/v1"
env_key = "SHANHAI_API_KEY"
wire_api = "responses"
Set environment variables before starting:
$env:SHANHAI_API_KEY = "YOUR_API_KEY"
codex
Bash corresponds to export SHANHAI_API_KEY="YOUR_API_KEY". If you use other ShangHai Do sites, please replace the domain name of base_url and retain /v1. Editor extensions or desktop programs should be launched from an environment that can read this environment variable. Modifications usually require reopening the program. env_key fills in the name of the environment variable, not the token itself.
A custom supplier token is used here, and there is no need to use this site’s token as a ChatGPT account to log in. Do not configure the obsolete wire_api = "chat"; if using CC Switch, manage credentials as per CC Switch Documentation.
interface calling example
curl "https://shanghaido.com/v1/responses" \
-H "Authorization: Bearer $SHANHAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-flash",
"input": "Reply with OK.",
"max_output_tokens": 512
}'
Find type:"message" from output, and then read text of type:"output_text" in content. Do not assume that the final text must be in output[0] because other types may be returned at the same time. Tool requests are returned as type:"function_call".
Before switching models, please confirm that it supports Responses and tool calls; normal dialogue capabilities cannot replace these functions.
The above command is suitable for Bash, you need to replace the domain name when using other sites. Programming tasks also use continuous output and multiple rounds of tool calls. If you encounter session or tool execution problems, please contact the site customer service.
References: Codex configuration reference, Advanced configuration.
encountered a problem
If you encounter problems with calling or configuration, please contact the site customer service and provide the model name, error time and error information to facilitate troubleshooting.