Codex China Direct Access Tutorial: Guide to Using DeepSeek as a ChatGPT Replacement

How to run Codex in China by replacing the ChatGPT backend with the DeepSeek API for just 10 RMB.
A complete guide to using Codex in China without a ChatGPT account. By configuring the DeepSeek API as Codex's backend through the Codex++ management tool, users can access this powerful AI programming agent at extremely low cost—covering installation, API Key setup, and account top-up.
OpenAI Codex China Direct Access Solution: Using DeepSeek to Replace the ChatGPT Backend
OpenAI's Codex has become an essential AI tool for a growing number of developers—and even non-programmers. For context, it's worth understanding that Codex represents a major paradigm shift in AI programming tools—it's no longer just a "code completion" plugin, but an AI Agent capable of autonomously reading and writing files, executing terminal commands, and completing entire programming tasks.
The Fundamental Difference Between AI Agents and Traditional Code Completion: Traditional code completion tools (like early versions of GitHub Copilot) are essentially "suggestion systems"—they predict the next line of code, but still require humans to confirm and trigger execution line by line. The AI Agent paradigm, on the other hand, introduces a "perceive-plan-act" loop: the Agent can read the file system state, analyze error messages, break down task steps, and execute multiple rounds of operations continuously without human intervention. Codex's Agent capabilities manifest specifically as: it can autonomously open the terminal, install dependencies, run tests, and modify code based on error reports—the entire workflow is like having a junior engineer sitting next to you. Behind this leap is the maturation of "Tool Use / Function Calling" technology—the model's output is no longer limited to plain text, but can output structured "intent instructions" (such as opening a certain file or executing a certain command), which are parsed and actually executed by an external execution engine, with the results fed back to the model for the next round of reasoning. This "perceive-plan-act" loop essentially transplants the agent concept from reinforcement learning into the large language model scenario, and began to be deployed at scale after OpenAI released its function calling API in 2023.
Codex's predecessor was OpenAI's 2021 code model of the same name, fine-tuned on GPT-3. At that time, it was trained on code corpora at a scale of roughly 159 billion parameters, becoming the underlying engine for GitHub Copilot. However, limited by its context window of about 4K tokens and its pure completion paradigm, it was essentially just an "intelligent Tab key." The desktop version re-released in 2025 uses o3/o4-mini reasoning models as its backend, paired with a sandboxed tool execution environment, expanding the context window to hundreds of thousands of tokens. It truly achieves autonomous engineering tasks that span across files and sessions, completing the qualitative transformation from "code suggestion" to "autonomous engineer." But as an overseas product, it presents natural barriers for domestic Chinese users—you need a ChatGPT Plus account and a stable overseas network connection. This article systematically walks through a China direct access solution: using third-party management tools to integrate domestic large models like DeepSeek into Codex, enabling users without overseas accounts to get started smoothly.
Why We Need a Domestic Large Model Alternative
Codex natively only supports login with a ChatGPT account, which imposes three restrictions on domestic Chinese users: you need a ChatGPT account, a Plus membership (about $20/month), and an overseas network environment. Satisfying all three conditions simultaneously is not easy for most people.
The good news is that Codex is essentially a tool shell, with its underlying capabilities coming from a large model. Therefore, it's entirely possible to swap the backend—using a domestic large model (such as DeepSeek or Doubao) to drive it. DeepSeek is a series of large language models developed by the Hangzhou-based company DeepSeek. Leveraging a Mixture of Experts (MoE) architecture and efficient training methods, it reaches world-class levels in benchmark tests for code generation and logical reasoning, while its API call cost is only about 1/30 to 1/50 that of GPT-4o.
Technical Background of the Mixture of Experts (MoE) Architecture: The Mixture of Experts (MoE) architecture adopted by DeepSeek is the key to understanding its "high performance, low cost." Traditional dense large models activate all parameters during inference, while the MoE architecture splits the model into multiple "expert subnetworks," routing and activating only a few experts (typically 2-8) during each inference. Although the total parameter count is large, the actual computation is greatly reduced. DeepSeek V3 has about 671B total parameters, but only activates about 37B parameters per token, with computational efficiency close to that of a dense model with the same activated scale. This architecture was first systematized by Google in the 2017 Sparsely-Gated MoE paper, and was later engineered at scale by Mistral's Mixtral series and DeepSeek. The engineering challenges of MoE mainly focus on two points: first, the "expert collapse" problem—early in training, the router tends to assign all tokens to just a few experts, wasting most expert parameters; second, the communication overhead during distributed inference—different experts may be distributed across different GPU nodes, and the cross-node communication generated by token routing can become a performance bottleneck. DeepSeek forces load balancing across experts by introducing an auxiliary loss function, and made dedicated communication optimizations for domestic interconnect hardware. This is precisely the fundamental engineering reason it can achieve top-tier performance at a training cost far below its peers.
Beyond the MoE architecture, DeepSeek's strong performance on international benchmarks (HumanEval, MBPP, LiveCodeBench) also benefits from two key innovations: the "Multi-head Latent Attention (MLA)" mechanism compresses the KV Cache through low-rank compression, reducing memory usage during inference by about 5-13 times, allowing the same hardware to serve more concurrent requests; the "FIM (Fill-in-the-Middle)" code training strategy enables the model not only to continue writing code, but also to fill in missing middle fragments given existing context before and after, more closely matching completion needs in real-world programming scenarios. These two optimizations together lay the foundation for DeepSeek's practical performance on code tasks approaching or even surpassing GPT-4o.
DeepSeek V3 and subsequent Pro versions are optimized for complex programming tasks, with stable performance and extremely low prices—offering excellent value for learning and daily testing.
The overall approach can be summed up in one sentence: Codex handles the interactive interface and tool capabilities, while DeepSeek handles the underlying reasoning, with the two connected through an API interface.
Technical Principle of Backend Replacement: This approach originates from the "frontend-backend separation" architecture of modern AI applications. The frontend handles user interaction, task scheduling, file reading/writing, and other engineering capabilities, while the backend (i.e., the "backend model") handles language understanding and code generation. The two communicate through a standardized API protocol—as long as the replacement model is compatible with the same interface specification (such as OpenAI's Chat Completions API), the frontend tool requires almost no modification to switch backends.
The OpenAI Chat Completions API Protocol Standard: This protocol defines a universal message structure: the request body contains core fields such as model (model name), messages (an array of conversation history, with each message containing role and content), etc. It supports three roles—system (system prompt), user (user input), and assistant (model's previous replies)—and the response body returns a choices array and usage statistics. The stream parameter supports streaming output based on the Server-Sent Events protocol, enabling a typewriter effect; the tools and tool_choice fields allow the model to declare external functions it needs to call, supporting Agent capabilities. Because of its clear logic and obvious first-mover advantage, this specification was quickly adopted by vendors such as Anthropic (Claude), Mistral, Moonshot (Kimi), and DeepSeek. DeepSeek's compatibility manifests as: its API gateway layer implements complete field mapping, including sampling parameters such as temperature, top_p, and max_tokens, ensuring that client code written for OpenAI can switch over with almost zero modifications—you only need to change the two parameters base_url and api_key. This "protocol as standard" ecosystem effect also means the configuration method in this article is highly universal—once mastered, it can be seamlessly migrated to any model service compatible with the OpenAI protocol.
Step 1: Install Codex and the Codex++ Management Tool
The China direct access solution requires downloading two tools: the native Codex installation package and the Codex++ management tool.
Installing Native Codex
Windows users can directly open the system "Store," search for Codex to find the corresponding app, and click "Free Download" to complete the installation. Mac users do the same, searching and installing via the app store—the entire process is no different from any ordinary software.
Critical reminder: After installation is complete, do NOT open Codex directly! By default, launching it will require logging in with a ChatGPT account, which is exactly the step we need to bypass.

Installing the Codex++ Management Tool
Codex++ is a third-party management tool that does not modify any of Codex's core functions—it only adjusts the login method. From a technical standpoint, Codex++ is essentially a "configuration proxy layer"—since Codex is built on the Electron framework (the same origin as VS Code), its configuration reading logic is relatively transparent. Codex++ redirects API requests that would originally point to OpenAI's servers to a user-defined endpoint (such as DeepSeek) by modifying OS-level environment variables (such as OPENAI_API_BASE) or the configuration JSON files in the application data directory. Since it doesn't touch Codex's core binary files, this "only change config, don't touch binaries" approach not only preserves Codex's full tool capabilities (file operations, terminal execution, etc.), but also allows it to stay in sync with official Codex version updates without needing to re-crack it. Through it, you can configure a domestic large model as the backend and complete login.
This tool can be downloaded from the release page on GitHub for the latest version. If your domestic network cannot access GitHub, you can use the installation package prepared in advance by the tutorial author (with separate versions for Windows / Mac). The installation process is likewise a default "Next" all the way through.
After installation, three programs will appear on the desktop: Codex, Codex++ Management Tool, and Codex++. Be sure to identify the right one—you should open the "Codex++ Management Tool," don't pick the wrong one.

Step 2: Configure the DeepSeek API as the Backend
After opening the Codex++ Management Tool, the interface has many features, but we only need to focus on one module—Model Provider Configuration.
Adding a Provider
Click "Model Providers" on the left; by default there is only one blank configuration. Click "Add Provider" to begin filling it out:
- Name: Customize as you like, for example enter "DeepSeek"—it's just a label for your own recognition.
- Access Mode: Be sure to select "Pure API", because we are integrating DeepSeek through its API interface.
Filling in the Base URL and API Key
The core of the configuration is two pieces of information:
The Base URL is DeepSeek's API request address—enter api.deepseek.com. This address basically won't change, so it's recommended to copy and paste it directly to avoid manual input errors. The reason DeepSeek can be recognized by Codex++ is precisely that it is compatible with OpenAI's standard interface protocol; once the tool has this address filled in, it will communicate with the model according to a unified specification.
The API Key is the unique credential for your DeepSeek account. Here's how to obtain it:
- Go to the DeepSeek official website and click "API Open Platform"
- Find "API Keys" on the left and click "Create"
- The system will pop up a string of keys—copy and save it immediately
There's an extremely important detail here: the API Key is displayed only once! After closing the window, you cannot view it again and must create a new one. After creating it, please immediately save it to a note or local document for later use.
API Key Generation and Security Mechanism: An API Key is typically a random string generated through cryptographic hashing (for example, DeepSeek uses a 32-64 character random string with the sk- prefix). Its security design follows the "least knowledge" principle—the platform only displays the complete key once at creation, after which only its hash value is stored in the database. Even if the platform's database is attacked, the original key cannot be reverse-engineered. From an engineering practice perspective, API Key management has a complete set of best practices: in local development environments, it's recommended to use the dotenv library to store the key in a .env file and add that file to .gitignore to prevent accidental commits to the code repository; in production environments, a more secure approach is to use a secrets management service (such as AWS Secrets Manager or HashiCorp Vault) to inject the key dynamically; for team collaboration scenarios, you can also create independent keys for different members or services and set call frequency limits and usage caps to achieve fine-grained permission control. Code hosting platforms like GitHub have also deployed automatic scanning mechanisms—once they detect that submitted content contains an API Key in a known format, they immediately issue a security warning and notify the corresponding service provider to revoke that key.
API Key Security Notes: An API Key is essentially your account's access credential—whoever holds it can call the model and consume your balance under your identity. Therefore, you should follow a few principles: don't commit it to public code repositories like GitHub; don't expose it in screenshots; don't share it with others. Once you suspect a leak, you should immediately delete the key in the DeepSeek console and create a new one. The platform's "display only once" design is precisely for security considerations—forcing users to actively save it, avoiding the passive leak risk caused by the page retaining it. Once a key leak occurs, "immediately revoke and recreate" is the only correct response—because a leaked key, no matter how briefly, could be abused en masse by automated scripts.

Fetching Models and Saving
After filling in the Base URL and API Key, keep the protocol option at its default and click "Fetch from Upstream". The tool will test whether the current configuration can connect successfully—if it can pull the model list, the configuration is correct.
Among the models DeepSeek offers, we recommend selecting the Pro version (such as DeepSeek V4 Pro), which performs better while still being affordably priced. After confirming a successful fetch, scroll up and click "Save," then move your mouse to the right side of the newly appeared configuration item, click "Use," and confirm it switches to the "In Use" state.
Step 3: Top Up Your DeepSeek Account
Completing the configuration doesn't mean you can run it immediately. When Codex runs tasks through DeepSeek, it consumes tokens, so your account must have a balance.
Token Billing Mechanism Explained: A token is the basic unit large models use to measure text, produced by a tokenizer that splits raw text. Token efficiency varies significantly across languages: an English word typically corresponds to 1-2 tokens, while Chinese, due to its large character set, has each character correspond to about 1.5-2 tokens—meaning Chinese users consume more tokens for the same amount of information. Large model pricing is usually measured per million tokens ($/MTok), billed separately for input and output. Using 2025 prices as a reference: GPT-4o costs about $2.5/MTok for input and about $10/MTok for output; while DeepSeek V3 costs about $0.07/MTok for input and about $0.28/MTok for output—a huge gap.
To establish a more intuitive understanding of cost, let's do a quantitative estimate using a typical Codex programming task. Suppose the task is "add unit tests to a 200-line Python script": the Agent needs to read the source file (about 800 tokens), analyze the code structure, and generate test code (about 300 tokens output). Adding the system prompt and intermediate reasoning process, a single task consumes about 3000-5000 tokens total. Calculated at DeepSeek V3 pricing, this amounts to about 0.002-0.003 RMB—just a few thousandths of a yuan; while using GPT-4o to complete an equivalent task would cost about 0.06-0.1 RMB, a gap of roughly 30-50 times, which aligns closely with the "1/30 to 1/50" estimate.
In Codex's programming task scenarios, you also need to pay special attention to the impact of the "context window." Before each operation, the Agent needs to pass the task history, contents of already-read files, error messages, etc. into the model as context. As task complexity increases, the context keeps accumulating—not just the final code output, but the thinking process and file contents of every intermediate round are counted toward the cost. The token consumption of an entire programming task may far exceed expectations. Understanding this mechanism helps control costs: reasonably setting task granularity (breaking large tasks into independent smaller ones), promptly clearing irrelevant context, and avoiding pasting irrelevant code into prompts are all effective strategies for reducing API call costs.
DeepSeek uses a pay-as-you-go model rather than a fixed monthly subscription, which means intermittent learners don't have to pay for idle periods—compared to ChatGPT Plus's fixed subscription of about 145 RMB per month, DeepSeek API's "pay for what you use" model is especially friendly to learning users, which is precisely the core of its "ultimate cost-effectiveness."
Go to the top-up entry on the DeepSeek API platform; topping up 10 RMB is enough to meet most learning needs. According to the tutorial author's feedback, even with high-intensity use from morning till night (including running multiple parallel tasks in the background), a month's spending is only about 100 RMB. For ordinary learning users, 10 RMB of tokens is enough to last a considerable amount of time.
Step 4: Launch Codex and Complete Login
Once all the configuration is ready, remember NOT to click on Codex itself directly. Instead, launch it via the "Restart Codex++" button in the top-right corner of the Codex++ Management Tool. Only this way will the modified login method take effect.

After launching, Codex will pop up a login interface. Don't select the first option "Login with ChatGPT"; instead choose the second option "Login with another method." In the input box, although it's labeled OpenAI API Key, simply paste the DeepSeek API Key you saved earlier and click "Continue." The reason this step succeeds is precisely that DeepSeek is compatible with OpenAI's interface protocol—Codex only verifies the key's format and the interface's reachability, and cannot distinguish whether the underlying service is OpenAI or DeepSeek. As long as the format is correct, it passes verification.
The first login may take a moment. After entering the interface, check the model selection in the bottom-right corner—click the dropdown menu, confirm you can see the DeepSeek model you just configured, and switch to DeepSeek V4 Pro. At this point, the China direct access solution is fully connected.
Comparing the Two Solutions: How to Choose
This tutorial actually provides two usage paths:
- Solution 1 (China Direct Access): Suitable for users without a ChatGPT account or overseas network. Configure the DeepSeek backend via the Codex++ Management Tool—it takes a few more steps, but it's a one-time setup with extremely low usage costs.
- Solution 2 (Native Login): Suitable for users who already have a ChatGPT Plus membership. Simply download Codex, select "Login with ChatGPT," and enter your account and password—the simplest process.
It's worth mentioning that, according to the tutorial author, the official Codex team has issued a statement that they will natively support third-party large model integration in the future. At that point, you may be able to configure models like DeepSeek and Doubao directly without third-party tools like Codex++. This trend aligns with the direction of the entire industry—as the OpenAI-compatible protocol becomes a de facto standard, more and more tools are natively supporting multi-backend switching. This is a major benefit for domestic Chinese users and worth continued attention.
Summary
For domestic Chinese users who want to experience Codex but are limited by account and network constraints, "Codex++ Management Tool + DeepSeek API" is a verified, viable path. The core logic of the entire process is swapping the backend: switching Codex's large model driver from ChatGPT to a domestic model. The reason this operation works fundamentally lies in DeepSeek's compatibility with OpenAI's standard API protocol (the Chat Completions interface), which means the tool layer doesn't need to be aware of the backend change—just like swapping engine brands while the car's body frame remains unchanged. Once you master this method, whether you later integrate Doubao or another new model, you only need to replace the Base URL and API Key—the operational logic is entirely the same. With a 10 RMB token threshold, plus DeepSeek's pay-as-you-go, no-fixed-monthly-fee pricing model, even ordinary users who can't write code can get started with this powerful AI programming tool at extremely low cost.
Key Takeaways
Key Takeaways
Related articles

Domain Renewal Jumps from $10 to $3,000: Exposing Hover's Renewal Trap and How to Protect Yourself
A Hover user's domain renewal jumped from $10 to $3,000. Learn about premium domain pricing, registrar traps, and practical strategies to protect yourself.

Vendor C++ Toolchains Silently Swallowing Compiler Warnings: Risks and Prevention Strategies
Analysis of how chip vendor C++ toolchains silently suppress compiler warnings, the risks involved, and prevention strategies including cross-validation and static analysis.

Vendor C++ Toolchains Silently Swallowing Compiler Warnings: Risks and Mitigation Strategies
Analysis of how chip vendor C++ toolchains silently suppress compiler warnings, the risks involved, and mitigation strategies using cross-validation and static analysis tools.