gpt-4o · gpt-4-turbo · o1

OpenAI API Relay Setup Guide

Step-by-step guide to configuring OpenAI API relays — environment variables, ChatBox/NextChat integration, Python SDK setup, and Codex CLI configuration.

Environment SetupApp IntegrationCLI ToolsSDK IntegrationFAQ

Recommended Platforms

These platforms have strong OpenAI API (GPT series) support

💳

QCode — 1:1 Official Pricing

1:1 multiplier equals official pricing, but with CNY payment and Alipay support — no credit card needed.

🔗

Weelinking — 200+ Model Aggregation

Full OpenAI model coverage plus Claude, Gemini, and more — unified management across all models.

💰

Right Codes — Start from ¥1

¥1 top-up gives ¥5 credit, GPT 5.4 at ¥1.25/7.5 per million tokens — ultra low barrier.

Environment Setup

Core: Set OPENAI_BASE_URL

01

Register and Get API Key

Sign up on your chosen relay platform and get your API key (usually in format sk-xxxx).

02

Set Environment Variables

Set the following environment variables in your terminal or config file:

03

Verify Connection

Run a test command to verify your configuration works.

Code Examples

SDK integration for various languages

python

Python (OpenAI SDK)

Use the openai Python package, specify base_url to point to your relay.

from openai import OpenAI

client = OpenAI(
    api_key="your-relay-api-key",
    base_url="https://your-relay.com/v1"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}]
)
node

Node.js (OpenAI SDK)

Use the openai npm package, configure baseURL.

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "your-relay-api-key",
  baseURL: "https://your-relay.com/v1"
});

const response = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello!" }]
});
curl

cURL

Use curl directly to test API connectivity.

curl https://your-relay.com/v1/chat/completions \
  -H "Authorization: Bearer your-relay-api-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello!"}]}'

App Integration

Configure popular tools to use your relay

ChatBox

A cross-platform AI chat client with simple, intuitive configuration.

NextChat (ChatGPT Next Web)

An open-source ChatGPT web client with custom API endpoint support.

OpenWebUI

A powerful open-source Web UI supporting OpenAI and OAI-compatible relays.

FAQ

Q1.Is the relay API key format the same as official?
Most relays use the same key format as OpenAI (sk-xxxx) and keep the API endpoint compatible, so most tools supporting OpenAI format can connect seamlessly. But some platforms use custom formats — check the platform docs before purchasing.
Q2.Do they support GPT-4o and o1/o3 models?
It varies by platform. Mid-to-high-tier platforms (like QCode, Weelinking) typically support new OpenAI models quickly. Some budget platforms may delay or not support the latest models. Check the platform website for the supported model list.
Q3.How much slower is relay vs direct to official?
Depends on relay server quality. Quality platforms (like QCode) use Asia-accelerated nodes, keeping latency under 150ms — barely noticeable vs direct. Budget platforms may use low-quality routes, with latency reaching 500ms~1s.
Q4.How do I prevent API key leaks?
1) Never hardcode API keys in code; 2) Use .env files for key management and ensure .env is in .gitignore; 3) Never share keys on public platforms; 4) Regularly check your dashboard for unusual usage and rotate keys immediately if anything looks off.
Q5.Are there rate limits on relay calls?
Yes — every platform has its own rate limits. Free/budget plans are usually stricter, premium plans are more relaxed. QCode limits within a 4-hour sliding window; additional capacity can be purchased. Some platforms offer paid upgrades to remove limits.

Browse All Platforms

View Platform List
OpenAI API Relay Setup Guide | ProxyCC