Claude Code Quick Access Guide for OpenAI Hub
The purpose of this tutorial is simple: to help you use Claude Code smoothly in China, connect it to the latest mainstream models through OpenAI Hub, and avoid dealing with proxies.
1. Environment Preparation
Claude Code runs on Node.js, so your system must have Node.js installed first. Open the terminal and type:
node -v
If you see a version number, it means Node.js is installed. Node.js v18 or higher is recommended (by 2026 it’s usually v20+).
If not installed, go to the Node.js official website and download the version for your system.
Once Node.js is ready, you can install Claude Code.
2. Install Claude Code CLI
It is recommended to use the official Native Install method — more stable and can auto-update.
macOS / Linux / WSL users:
curl -fsSL https://claude.ai/install.sh | bash
Windows PowerShell users:
irm https://claude.ai/install.ps1 | iex
After installation, verify with:
claude --version
If you see a version number, installation was successful.
Note: There’s a small pitfall here — some Windows users need to restart the terminal after installation, otherwise the command may not be recognized.
3. Configure Third-Party Model Access (Core Step)
By default, Claude Code only recognizes Anthropic’s official models, but we can use environment variables to make it access the compatible OpenAI Hub interface.
Imagine you installed a “parcel locker” at your doorstep — Claude originally only deposits packages into the official locker, but now you tell it your locker is actually hosted on Hub.
Set up environment variables in the terminal:
macOS / Linux:
export ANTHROPIC_BASE_URL=https://api.openai-hub.com
export ANTHROPIC_API_KEY=sk-your-api-key
export ANTHROPIC_MODEL=claude-3-opus
Windows PowerShell:
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://api.openai-hub.com", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_API_KEY", "sk-your-api-key", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "claude-3-opus", "User")
Then close the terminal and reopen it to apply the configuration.
Note: If you have previously logged in to the official Claude account, run
/logoutto clear the old session, otherwise it may cause a conflict.
4. Create a Local Configuration File (Optional but Recommended)
After installation, Claude Code will create a .claude folder in your user directory.
If not, create a configuration file yourself:
Windows: C:\Users\YourUsername\.claude\config.json
macOS / Linux: ~/.claude/config.json
Write in the following content:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.openai-hub.com",
"ANTHROPIC_API_KEY": "sk-*****"
}
}
The advantage of this method is that you don’t have to set environment variables every time you start.
5. Launch Claude Code
Go to your project directory and run:
claude
The first launch will ask you to log in — just skip it, it will automatically use your configured API.
If you see the Claude Code CLI interface and it responds to input, it means you’ve successfully connected to OpenAI Hub.
6. Common Issues and Troubleshooting
- If the model cannot be found, check whether the model name is spelled correctly (OpenAI Hub uses compatible naming such as
claude-opus-4-6,claude-sonnet-4-6, etc.) - If you get a key error, confirm that your key generated in the OpenAI Hub console is valid
- If running
claude doctorshows a network error, it’s usually because the terminal wasn’t restarted or the environment variables didn’t take effect
Once you’ve done all this, you can use Claude Code locally to assist with coding.
Next Steps You Can Try
Connect Claude Code to VSCode — after installing the plugin, you can use AI to generate or refactor code directly in the editor, which feels much better than the CLI experience.
