Using openai-python from China — OPENAI_BASE_URL relay setup guide #2983
holysheep123
started this conversation in
General
Replies: 1 comment
-
|
For those looking specifically for how to purchase and set up OpenAI API access from China, I've written a comprehensive guide: https://holysheep123.github.io/openai-api-buy-china-2026.html Covers pricing comparison, step-by-step setup, and tool configurations. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
The official
api.openai.comendpoint is blocked in mainland China (GFW). This causesopenai.APIConnectionErroror timeout when using theopenaiPython package.Solution: Configure OPENAI_BASE_URL
The
openaiPython SDK supportsbase_urloverride natively — just point it to a relay:Or via environment variables (works with any code that uses the SDK):
Why this works
The
openaiSDK readsOPENAI_BASE_URLautomatically since v1.x. The relay service (holysheep.ai) forwards requests to OpenAI and returns responses — fully compatible with the SDK.Other options
Is there any chance the SDK could add built-in retry logic specifically for connection errors (vs API errors)? That would help in unstable network environments too.
Beta Was this translation helpful? Give feedback.
All reactions