Using Codex in China: How to Fix Connection Failures and the Lack of an Overseas Credit Card

Using Codex in China comes down to two sticking points: network and payment. The login page won't open, requests time out, and you have no overseas payment method. This article covers how to fix each.

4 分钟阅读
Using Codex in China: How to Fix Connection Failures and the Lack of an Overseas Credit Card

When using Codex in China, the most common blockers aren't installation. They're two things: you can't connect (the login page won't open, requests time out) and you can't pay (a ChatGPT subscription and the OpenAI API both require an overseas payment method). This article covers only how to fix those two problems.

For installation steps, see Codex Installation Guide, and for how to set your API Key, see How to Configure a Codex API Key.

First, figure out where you're stuck

SymptomProblem typeWhich section to read
Run codex and the login page won't open or just keeps spinningNetworkNetwork issue
It starts, but tasks fail with timeouts, connection resets, or TLS errorsNetworkNetwork issue
You have no ChatGPT subscription and can't add a credit card for the OpenAI APIPaymentPayment issue
You get 401, 404, or model not foundConfiguration, not networkHow to Configure a Codex API Key

A 401 or 404 means the request already reached the server. The problem is the Key or the address, and switching networks won't fix it.

Network issues: why you can't connect

Codex sends requests to OpenAI's official services by default. Signing in with a ChatGPT account also requires opening OpenAI's login page. Most of these addresses can't be reached directly from China, so the usual symptoms are:

  • The login page won't open in the browser, or the terminal keeps waiting for the callback after you finish signing in;
  • After you submit a task, there's no response for a long time and it eventually times out;
  • It works occasionally, then drops again later.

Option 1: Route Codex through a network that can reach OpenAI

If you already have a network setup that reliably reaches OpenAI, make sure that the terminal where you launch Codex is also using it. Being able to open OpenAI in a browser doesn't mean Codex in the terminal goes through the same route. Proxy setup for terminals varies by tool. On a work computer, follow your company's network policy first and don't try to bypass it.

Option 2: Use an API service that's directly reachable from China

If you'd rather not fiddle with networking, you can send Codex's model requests to an API service that's directly reachable in China. Taking AICodeWith as an example, it offers two routes:

  • Overseas direct route: relayed through Cloudflare Tunnel, it connects from most regions in China without a proxy, and the platform recommends it first;
  • Domestic route: relayed through Alibaba Cloud ESA, it needs no proxy at all. The path is longer and latency may be higher, so treat it as a backup.

Both routes use the same API Key, and quota and usage records are synced. When switching, change only the domain part of the API address and leave the path after it unchanged. For details, see the AICodeWith route selection docs.

Payment issues: what to do without an overseas credit card

Codex has two official ways to pay:

  • ChatGPT subscription (Plus, Pro, Business, and so on), where you sign in to Codex with a ChatGPT account;
  • OpenAI API pay-as-you-go, where you sign in with an API Key from the OpenAI Platform.

Both require a payment method that works overseas. Domestic bank cards, Alipay, and WeChat can't pay directly.

Users in China can switch to an API platform that accepts payment in RMB. Taking AICodeWith as an example:

  • It supports top-ups via Alipay and WeChat, with no overseas credit card needed;
  • Billing is based on actual usage, and quota can be shared across the multiple models the platform supports;
  • Under the terms of service, top-up quota is valid for 12 months from the last top-up.

For specific pricing, refer to the pricing page; for supported models, see the model list.

Note: a Key from a third-party platform can only be configured according to that platform's integration docs. It can't be used to sign in on OpenAI's website, and ChatGPT subscription quota can't be used as API balance.

Next step: connect Codex to AICodeWith

Once network and payment are sorted, follow the integration guide to finish setup and verify it with a small task:

View the guide to connect Codex to AICodeWith →

If you don't have an account yet, first sign up for AICodeWith →, then follow the API Key creation docs to generate a Key.

FAQ

My browser can open ChatGPT. Why can't Codex connect?

Your browser and terminal have separate network settings. Make sure the terminal where you launch Codex also goes through a network that can reach OpenAI, or switch to an API service that's directly reachable from China.

Do I still need a ChatGPT subscription after switching to a third-party API?

No. With a third-party API, you're billed against that platform's quota, which has nothing to do with a ChatGPT subscription.

What if the overseas direct route won't connect?

Switch to the domestic route first: replace the domain in the API address with the domestic route's domain and keep the path the same. If neither works, contact the platform's technical support.

Is a 401 a network problem?

No. A 401 means the request reached the server but authentication failed, so check your Key. See How to Fix Codex 401 Unauthorized.

相关文章

What is the UI SDK, and how do you use it? Vercel and shadcn's behavior library for agents, installed and tested in Claude Code / Codex / Cursor (0.1.0-beta.1)

What is the UI SDK, and how do you use it? Vercel and shadcn's behavior library for agents, installed and tested in Claude Code / Codex / Cursor (0.1.0-beta.1)

The UI SDK is Vercel's behavior library for agents, released on 12 November 2026 as 0.1.0-beta.1. Behaviors live in the framework-free @ui-sdk/core package and are rendered by adapters for React, Vue, Svelte, Solid, and Web Components. This guide follows the official docs on what it is, how to install it, and how to add the skill for Claude Code, Codex, and Cursor, and it records the commands, timings, and output from our test machine.

What Is AWS Emulator and How Do You Install It? Test AWS Apps Locally with Claude Code and Codex (Tested on 1.0.322)

What Is AWS Emulator and How Do You Install It? Test AWS Apps Locally with Claude Code and Codex (Tested on 1.0.322)

AWS Emulator is AWS's official local emulator of its service APIs, generally available since November 11, 2026 (US time). It has no additional service fee, its source is open, it needs no AWS account, and it covers more than 200 services. We tested version 1.0.322 on Debian 13. This guide covers the install commands, pointing the AWS CLI at the local endpoint to create an S3 bucket and a DynamoDB table, the errors we hit, and how to let Claude Code, Codex and Cursor write and test code against the emulator.

What Is T3 Code and How Do You Install It? Connect Claude Code and Codex, Use a Third-Party API Key, Fix Common Errors (Tested on 0.1.9)

What Is T3 Code and How Do You Install It? Connect Claude Code and Codex, Use a Third-Party API Key, Fix Common Errors (Tested on 0.1.9)

T3 Code is pingdotgg's open-source control surface for coding agents. It ships no model of its own; it drives the Claude Code, Codex, Cursor and other CLIs already on your machine. We tested T3 Code 0.1.9 on Linux. This guide covers the install commands, how to point Claude Code and Codex at an AICodeWith API Key so T3 Code can drive them, a full run of both agents with the t3 thread command, and the errors we hit along the way with their fixes.