Using OpenAI API from China: GPT SDK, Cursor and troubleshooting
The short answer: OpenAI API can be accessed through an API gateway. Get a key and point base_url to https://api.yomiapi.com/v1 to connect the official OpenAI SDK, Cursor or other compatible tools. Below are three setup options and a troubleshooting guide.
Introduction
Last month, a small e-commerce team planned a GPT support bot but spent a week stuck on official registration and payments: overseas cards, billing addresses and identity checks. The prompt was ready, but the project could not start.
The hurdle was access rather than the model. A gateway replaces this with email registration, RMB top-ups and an OpenAI-compatible interface requiring almost no SDK changes. This tutorial covers getting a key, three integrations and troubleshooting.
Key takeaways
- Get a key: register → generate in console
#keys→ copy base_url (https://api.yomiapi.com/v1, including /v1).- Option 1: official OpenAI SDK in Python or Node.js; change base_url and use
gpt-5.5,gpt-5.6-sol, subject to the current model listing.- Option 2: set Override OpenAI Base URL in Cursor's Settings → Models.
- Option 3: any OpenAI-compatible tool with a custom base_url follows the same approach.
- Errors: 401 / 403 / 429 / 500. For 403, prioritize key permissions and balance.
- RMB payments through WeChat Pay/Alipay, separate input/output token rates and itemized records.
Get a key: register, generate and copy base_url
The gateway workflow is simpler than direct registration and requires no overseas payment method.
First, register at Yomi API with an email address that can receive messages.
Second, generate a key in the console's Keys page. Create one per project to isolate permissions and quotas. Replace an exposed key without disrupting other services; creating another takes only seconds.
Third, copy the OpenAI-compatible base_url:
https://api.yomiapi.com/v1
Include the trailing /v1. You now have three values:api_key, base_url, model. All three configurations below use them.
Option 1: official OpenAI SDK in Python and Node.js
Both languages can use the official SDK, changing configuration rather than application structure. Python example:
from openai import OpenAI
client = OpenAI(
api_key="sk-YOUR-YOMI-API-KEY", # Generated on the console Keys page
base_url="https://api.yomiapi.com/v1" # OpenAI-compatible address ending in /v1
)
resp = client.chat.completions.create(
model="gpt-5.5", # Use model names from the current Model Explorer listing
messages=[{"role": "user", "content": "You are a support bot. Write a welcome message"}]
)
print(resp.choices[0].message.content)
Node.js follows the same pattern:
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "sk-YOUR-YOMI-API-KEY",
baseURL: "https://api.yomiapi.com/v1",
});
const resp = await client.chat.completions.create({
model: "gpt-5.6-sol",
messages: [{ role: "user", content: "Hello" }],
});
console.log(resp.choices[0].message.content);
Use gpt-5.5 for everyday chat and gpt-5.6-sol for deep reasoning. For details, see the GPT-5.5 model page and GPT-5.6 SOL model page. Find other models in Model Explorer using its current listing. Responses, streaming, tool calls and multi-turn conversations follow the OpenAI format.
Run the example to verify connectivity. For production, enable stream=true for faster first-token delivery and steadier long responses. Function calling uses the official parameter format without extra adaptation.
After the first call, spend a few minutes trying gpt-5.5 and gpt-5.6-sol to compare style and speed. For short support or document Q&A tasks, gpt-5.5 is more economical; for long summaries and complex analysis, use gpt-5.6-sol. Switching changes only model, so production configuration can change without application code changes.
Option 2: Cursor and Override OpenAI Base URL
Cursor needs no plugin for GPT integration, just two settings:
- Open Cursor → Settings → Models.
- Enter your Yomi key under OpenAI API Key.
- Under Override OpenAI Base URL, enter
https://api.yomiapi.com/v1. - Add the model name
gpt-5.5and save to use it in chat and completion.
With Override enabled, the model list uses the names you enter. Add missing names manually, save and restart Cursor. Chat, completion and code review then share one channel, with token charges recorded in the console.
Option 3: other OpenAI-compatible tools
ChatGPT-Next-Web, LobeChat, open-source panels and custom gateways can also accept a custom base_url. The process is the same:
- Find the custom API address / Base URL setting.
- Enter
https://api.yomiapi.com/v1. - Enter your key.
- Enter the model name and start chatting.
Use the actual model ID, such as gpt-5.5 , rather than "GPT-5.5". Match case and hyphens exactly to avoid model-not-found errors. The same principle applies to all OpenAI-compatible tools.
Before production, choose a gateway with no content storage, TLS 1.3 and accessible itemized records. Some unusually cheap APIs have unclear credential sources. The June 8, 2026 advisory named exposed data, substituted models, malicious implants and outbound transfers. Do not experiment with business data on unknown services.
Troubleshooting: 401 / 403 / 429 / 500
Start by checking the key and base_url, where most setup errors occur, then use this table.
| Error | Meaning | Checks |
|---|---|---|
| 401 Unauthorized | Authentication failed | Check that the key is complete, has no extra spaces and is enabled; check whether base_url is missing /v1 or has an extra trailing slash |
| 403 Forbidden | Insufficient permissions or balance | Check for a zero balance, which causes rejection, and whether key permissions allow the selected model |
| 429 Too Many Requests | Rate limit reached | Check concurrency; separate project keys to isolate usage and review current quota and usage in the console |
| 500 Internal Server Error | Server error | Often transient: retry later and enable stream=true to reduce timeout risk; intelligent routing can switch to available routes |
For 403, check balance first, then key permissions. Both are visible in the console and faster to verify than changing code. For other errors, compare the complete message with the relevant integration documentation; configuration spelling is often the cause.
RMB top-ups: validate small, then scale
Gateways replace direct USD settlement and international-card requirements with RMB payments through WeChat Pay/Alipay. Input/output tokens are priced separately at clearly displayed model rates.
Start with a few dozen yuan, confirm stability, then scale. Try the three configurations, compare latency and stability, then increase the quota if suitable. Global low-latency access is adequate for most workloads. Every charge is visible without hidden deductions. Small teams can review weekly bills before deciding whether monthly billing fits.
Final thoughts
That e-commerce team made its first successful call the afternoon it changed access methods. The bot launched the next week, leaving them to refine prompts rather than registration and billing.
How can OpenAI API be used from China?The key is the access path: let a gateway handle registration, payments and routing while you focus on the product. Choose a reliable channel instead of repeatedly struggling with the official setup process.
Register for a key, run an SDK example, then use Cursor for daily testing. The platform aggregates 200+ models from 30+ providers, including GPT, Claude, Gemini and DeepSeek.GPT and Claude can share the same key, with model switching by one field and management in one console. For access across all models, see one-key integration guide.
Start with your first GPT request and explore the rest as you go.
Yomi API