Codex + DeepSeek Integration Tutorial: Three-Step API Proxy Script Setup

Connect Codex to DeepSeek and other LLMs via a local API proxy script in three steps
OpenAI Codex hard-codes Azure-style API request paths, making it incompatible with domestic LLMs that use standard OpenAI-compatible formats. This tutorial demonstrates how to use CC Switch configuration tool combined with a local API proxy script to convert Codex's special request format into a standard format recognizable by DeepSeek and other models, enabling low-cost, low-latency AI programming assistance.
Why Can't Codex Directly Connect to Chinese LLMs?
OpenAI Codex is a powerful AI programming assistant, but it only supports OpenAI's official API interface by default. Codex originally evolved from the GPT series of models and was specifically fine-tuned for code understanding and generation tasks. Its API calling method follows OpenAI's internal Azure OpenAI Service deployment specifications, using a path structure like /deployments/{deployment-id}/api, which is consistent with the RESTful style of resource deployment in Azure cloud services. For developers in China, domestic LLMs like DeepSeek, Kimi, and Qwen often offer better pricing and access speeds. However, when you try to directly enter DeepSeek's API address into the Codex configuration, you'll find it simply doesn't work.
The problem lies in incompatible API request formats. Codex has hard-coded specific request paths (like /deployments/xxx/api), while domestic LLMs follow the standard OpenAI-compatible format (such as /v1/chat/completions). The so-called OpenAI-compatible API means that third-party model providers fully align their interface design with OpenAI's request/response format specifications, including request paths, request body structure (model, messages, temperature, and other parameters), streaming output protocol (Server-Sent Events, SSE), and error code systems. The reason domestic LLMs like DeepSeek, Kimi, and Qwen choose to be compatible with this specification is that a massive number of development tools, SDKs, and frameworks worldwide (such as LangChain, OpenAI Python SDK) are built on this foundation—compatibility means developers can switch underlying models at virtually zero cost. However, Codex uses Azure-style deployment paths, and the differences between these two path specifications are the fundamental reason why directly replacing the API address doesn't work. No matter how you adjust Codex's configuration—switching to CHAT mode or other approaches—you'll get errors.

This article will walk you through using a proxy script to successfully connect Codex to DeepSeek V4 Pro and other domestic LLMs.
Prerequisites: Three Essential Tools for Connecting Codex to DeepSeek
Before starting the configuration, make sure you have the following tools ready:
CC Switch (Open-Source Configuration Management Tool)
CC Switch is an open-source AI model configuration management software specifically designed for customizing model configurations for Codex, OpenAI, and other AI tools. From a technical implementation perspective, such tools typically modify the target application's runtime configuration files, environment variables, or registry entries to change the application's network request behavior, belonging to the configuration management layer in the AI toolchain. Its core capabilities include:
- Multi-model management: Configure multiple different LLMs simultaneously
- Custom request addresses: Flexibly modify API endpoints
- Skill management: Conveniently manage prompts and skill configurations. The Skill management feature allows users to preset different System Prompt templates, which is crucial for controlling the LLM's output style and domain expertise—for example, you can configure dedicated prompt strategies for different scenarios like frontend development, backend architecture, and data analysis
It can be downloaded and installed from channels like the Microsoft Store.
Codex (AI Programming Assistant)
The programming tool we ultimately want to use, also available from the Microsoft Store.
Proxy Script (Core Component)
This is the key to the entire solution—a proxy service script running locally. It's responsible for converting the specially formatted requests sent by Codex into standard API formats that domestic LLMs can understand. From a technical perspective, the proxy script is essentially a lightweight HTTP reverse proxy service, typically implemented using Node.js (Express/Koa) or Python (Flask/FastAPI). It listens on a local port, intercepts HTTP requests from Codex, rewrites and maps the request path (URL Path), headers, and body, then forwards the request in a format compliant with the target model's specifications. Without this proxy layer, the entire solution cannot function.
Step-by-Step Configuration for Connecting Codex to DeepSeek
Step 1: Create a Custom Configuration in CC Switch
- Open CC Switch and find the configuration area related to Code/Codex and OpenAI Codex
- Click the plus (+) button to create a new custom configuration
- Fill in the following key information:
- Request address: Do NOT enter DeepSeek's official API address; instead, enter the local address provided by the proxy script (typically
localhostwith a specific port) - Model name: Fill in according to your actual needs, such as
deepseek-v4-proordeepseek-v4-fast. The DeepSeek V4 series comes in two versions: V4 Fast (focused on inference speed, suitable for high-frequency interaction scenarios) and V4 Pro (focused on inference quality, suitable for complex programming and long-chain reasoning tasks). DeepSeek performs excellently on multiple code benchmarks (such as HumanEval, MBPP, LiveCodeBench), with some metrics approaching or even surpassing GPT-4 level models, while API pricing is only a fraction of OpenAI's equivalent models. V4 Pro is currently on promotional discount, offering exceptional value - API Key: Enter the fixed format specified by the proxy script, NOT your own DeepSeek API Key (the proxy script has built-in Key handling logic)
- Click Save after completing the configuration
Step 2: Select the Custom Model in Codex
- Open Codex. If CC Switch is configured correctly, Codex will go directly to the main interface without requiring login
- In the model selection area, find Custom Hi (the custom model you configured in CC Switch)
- Select that model
Important Note: At this point, although both sides are configured, direct use will still fail. This is precisely why Step 3—launching the proxy script—is indispensable.
Step 3: Launch the API Proxy Script Service
- Run the proxy script program
- The script will first perform link verification to confirm network connectivity
- After verification passes, the script window will automatically disappear
- Press Enter (Continue) to confirm
- Click Start Script, and the proxy service begins running
At this point, the proxy service is listening on a local port, waiting to receive requests from Codex.
Step 4: Test and Verify Whether Codex Successfully Connects to DeepSeek
Return to the Codex interface and enter any code question for testing. If the configuration is correct, you'll see the DeepSeek V4 Pro model successfully returning response content.
Technical Principles: How the Proxy Script Achieves API Format Conversion
The technical principle behind the entire solution isn't complicated. The core is API format conversion:
Codex sends request → Special format (/deployments/xxx/api)
↓
Proxy script receives and converts
↓
Standard format request → DeepSeek API (/v1/chat/completions)
↓
DeepSeek returns response
↓
Proxy script forwards back to Codex
Codex's internal request path is fixed, using a format like /deployments/2121/api, which users cannot modify within Codex. After extensive testing, any path change results in errors.
The proxy script acts as a Local Proxy Server, which is a classic network middleware pattern that serves as a relay and transformation layer for requests between the client and the target server:
- Listens on a specific local port
- Receives specially formatted requests from Codex
- Parses the request body and reassembles it into the standard OpenAI-compatible format that DeepSeek can recognize
- Handles streaming (SSE, Server-Sent Events) data format differences to ensure Codex can correctly parse token-by-token returned content
- Returns model responses back to Codex via the same route
This approach borrows from the popular API proxy/gateway logic in the industry. Well-known open-source projects like One API and New API use the same architectural approach, except they are typically deployed in the cloud and support multi-user and multi-model unified management, load balancing, and usage billing. The reason many proxy services can connect various tools to different LLMs is essentially because they perform this kind of format conversion work.
List of Supported Domestic LLMs
Besides DeepSeek, this solution theoretically supports all domestic LLMs that provide OpenAI-compatible APIs:
| Model | Available Versions | Features |
|---|---|---|
| DeepSeek | V4 Fast, V4 Pro | Outstanding code capabilities, exceptional value, approaching GPT-4 level on multiple benchmarks |
| Kimi (Moonshot AI) | Latest version | Ultra-long context window (supports 2 million tokens), suitable for large codebase analysis |
| Qwen (Alibaba) | Qwen series | Deep integration with Alibaba Cloud ecosystem, strong multimodal capabilities, active open-source versions |
| Doubao (ByteDance) | Latest version | Leveraging ByteDance infrastructure, fast inference speed, highly competitive API pricing |
| Xiaomi LLM | Latest version | Integration with Xiaomi ecosystem, suitable for IoT and embedded development scenarios |
Simply modify the corresponding model name and API address in the proxy script to switch between models. It's worth noting that different models have varying strengths in code generation, logical reasoning, and context understanding, so developers can flexibly choose the most suitable model based on specific task scenarios.
Summary: Three Steps to Connect Codex with Domestic LLMs
The core challenge of connecting Codex to domestic LLMs lies in API format incompatibility, and the solution is format conversion through a local proxy script. The entire process can be summarized in three steps:
- Configure the model in CC Switch: Set up the local proxy address and model name
- Select the model in Codex: Choose the custom-configured model
- Launch the proxy script: Run the local proxy service to complete format conversion
For developers in China, this solution offers tremendous practical value—you can leverage Codex's excellent programming assistance capabilities while enjoying the low cost and low latency advantages of domestic LLMs, truly getting the best of both worlds. As domestic LLMs continue to improve and their API ecosystems mature, this flexible proxy-based integration approach will become a standard workflow configuration for an increasing number of developers.
Related articles
TutorialsChatGPT Plus Subscription Guide: Are GPT-5.5, image-2, and Codex Worth the Upgrade?
A detailed look at ChatGPT Plus features — GPT-5.5, image-2, and Codex — with a Plus vs Pro comparison and a complete step-by-step subscription guide for users outside the US.
TutorialsHarness AI Engineering in Practice: Using Claude Code to Master Enterprise-Level E-Commerce Development
Deep dive into Harness AI Engineering: master enterprise e-commerce development with Claude Code using the Rules, Skills, Wiki, and Changes framework.
TutorialsCursor + Codex Dual-IDE Collaboration: A Practical Methodology for Open-Source Project Customization
A complete methodology for open-source project customization based on real-world experience, detailing the Cursor+Codex dual-IDE workflow, seven-stage process, MVP validation, and AI source code reading techniques.