Many people get stuck at three steps the first time they use the OpenAI API: they do not know where to create a key, how to top up, or what to put in the Base URL after they have a key. This article walks through the complete flow with ZSQH AI Gateway and provides Python, Node.js, and curl examples.

This article is about pay-as-you-go API billing, not a ChatGPT Plus subscription. They are different: Plus is a membership for the web and app; the API is an interface for programs.

1. Register a ZSQH account

Open the ZSQH AI Gateway, click Sign up, complete email verification, and sign in.

After registration you land in the console. Three areas matter most:

  • API Keys: create and delete keys.
  • Wallet / Top-up: check your balance and add funds.
  • Usage logs: inspect the model, tokens, and cost of each call.

2. Create an API Key

Go to the "API Keys" page and click Create:

  1. Name: describe the purpose clearly, for example openai-api-test or production-backend.
  2. Quota: start with a low limit and adjust after the integration works.
  3. Expiration: test keys can be set to 7 or 30 days.
  4. Save and copy the key. Keys usually start with sk- and are shown in full only once.

Do not send keys to chat groups, put them in screenshots, or commit them to Git. If you suspect a leak, delete the old key and create a new one.

3. Top-up

On the "Wallet" page, choose a top-up method and complete payment as prompted. Once the funds arrive, the balance appears in the console.

If you are only testing, start with a small amount. Unit prices vary widely between models; see model pricing for details. Run the integration with a cheap small model first, then switch to your primary model.

4. What to put in the Base URL

ZSQH's OpenAI-compatible endpoint is:

https://ai.zhongshangqihang.com/v1

Notes:

  • OpenAI-compatible tools such as the OpenAI SDK, Cursor, Chatbox, LobeChat, and Dify usually take https://ai.zhongshangqihang.com/v1.
  • If a tool asks for "API Base", "Base URL", or "Endpoint", enter the same address.
  • Do not omit /v1, and do not append /chat/completions; the client adds it automatically.

5. Test with curl

First put the key in an environment variable to avoid leaking it through command history:

export OPENAI_API_KEY="sk-your-key"
export OPENAI_BASE_URL="https://ai.zhongshangqihang.com/v1"

Then make the call:

curl "$OPENAI_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5",
    "messages": [
      {"role": "user", "content": "Explain what an API gateway is in one sentence"}
    ]
  }'

If the returned JSON contains choices, both the key and the Base URL are working. Model names are subject to what the model pricing page currently shows; a wrong model name usually returns model not found.

6. Calling from Python

Install the OpenAI SDK:

pip install openai

Example:

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["OPENAI_API_KEY"],
    base_url="https://ai.zhongshangqihang.com/v1",
)

response = client.chat.completions.create(
    model="gpt-5",
    messages=[
        {"role": "system", "content": "You are a concise technical assistant."},
        {"role": "user", "content": "Explain what a token is"},
    ],
)

print(response.choices[0].message.content)

7. Calling from Node.js

npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
  baseURL: "https://ai.zhongshangqihang.com/v1",
});

const response = await client.chat.completions.create({
  model: "gpt-5",
  messages: [{ role: "user", content: "Write a JavaScript debounce function" }],
});

console.log(response.choices[0].message.content);

8. Common errors

Error Cause What to do
401 Unauthorized Wrong key, deleted key, or missing Bearer Copy the key again and check the request headers
404 Not Found Missing /v1 or duplicated path Enter only up to /v1
model not found Wrong model name or not enabled Copy the model name from the pricing page
insufficient quota Insufficient balance Top up and retry
429 Concurrency or rate limit exceeded Reduce concurrency and retry later
Empty response Parameter or model does not support the request Check the messages format and model capabilities

9. Security and cost recommendations

  1. One key per person: do not share a single key across a team; you cannot trace problems otherwise.
  2. Set quotas: low limits for test keys, budget-based limits for production keys.
  3. Never put keys in front-end code: a key in the browser will be seen. Front-end calls must go through your own backend.
  4. Use environment variables or secret management in production: do not put keys in code or Dockerfiles.
  5. Rotate regularly: rotate important keys every 90 days.
  6. Review usage logs: break them down by model, project, and member to find abnormal consumption.

10. How is the API different from ChatGPT Plus?

Item ChatGPT Plus OpenAI API
How it is used Chat on the web or in the app Programmatic calls
Billing Fixed subscription Pay by token usage
Who it suits Individual daily use Developers, products, teams
Quota Plan limits Prepaid balance
Can it be integrated into a product? No Yes

If you only chat for yourself, a subscription is simpler. If you want to connect models to products, scripts, agents, or tools, the API is a better fit.

FAQ

Can I see the key again after creating it?

Usually it is shown in full only once at creation. If you did not save it, delete it and create a new one.

Can one key call multiple models?

Yes. A key is an identity credential; the model is specified in the request parameters. See the pricing page for available models.

Why does a successful call not change my balance?

There may be a delay, or the call may have used free credits or cache. Refer to the usage logs and bill.

Can I give the key to a colleague?

Not recommended. Create a separate key for each colleague so you can set limits, audit usage, and disable it.

Next steps

If you do not have an account yet, register for the ZSQH AI Gateway, create a test key, and make your first request with curl. Once it works, check model pricing to choose your primary model.

Related reading: