Migrating from OpenAI in 2 lines
NexToken is OpenAI-SDK compatible. You change two strings and your existing
code routes to nex-pro on Singapore-hosted GPUs at ~95% lower cost.
What you'll build
A chat call that hits NexToken instead of OpenAI's API — same OpenAI Python or Node SDK, no new dependency. By the end you'll have:
- A working
chat.completions.createcall againstnex-pro - An optional fallback: keep using
gpt-4oby passing it as the model — NexToken proxies it - Per-request cost printed (look for the
nex.cost_usdfield)
Step 1 · Get a key
Sign up at app.nextoken.biz. New accounts get 1,000 free nex-pro calls/day — no card required, no expiry until you top up. Your default API key is shown right after registration.
Step 2 · Change two lines
Python (OpenAI SDK ≥ 1.0)
from openai import OpenAI
client = OpenAI(
api_key="nex_live_YOUR_KEY", # ← change
base_url="https://api.nextoken.biz/v1", # ← change
)
response = client.chat.completions.create(
model="nex-pro", # Singapore-hosted, $0.10/1M input
messages=[{"role": "user", "content": "Explain quantum computing in 3 sentences."}],
)
print(response.choices[0].message.content)
print(f"Cost: ${response.nex.cost_usd}") # Nex extension — paid in USD
Node.js / TypeScript
import OpenAI from "openai";
const client = new OpenAI({
apiKey: "nex_live_YOUR_KEY",
baseURL: "https://api.nextoken.biz/v1",
});
const r = await client.chat.completions.create({
model: "nex-pro",
messages: [{ role: "user", content: "Explain quantum computing in 3 sentences." }],
});
console.log(r.choices[0].message.content);
curl
curl https://api.nextoken.biz/v1/chat/completions \
-H "Authorization: Bearer $NEX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nex-pro",
"messages": [{"role": "user", "content": "Hello"}]
}'
Step 3 · Use any other model
NexToken supports 44 models across 10 providers through the same endpoint — GPT-4o, Claude, Gemini, DeepSeek, Qwen, GLM, and more. Just pass the model name:
client.chat.completions.create(model="gpt-4o", messages=[...]) # OpenAI
client.chat.completions.create(model="claude-sonnet-4-6", messages=[...]) # Anthropic
client.chat.completions.create(model="gemini-2.5-pro", messages=[...]) # Google
client.chat.completions.create(model="nex-auto", messages=[...]) # let Nex pick
nex-reasoning for math/logic, or
nex-auto to let the gateway choose per-request.
Step 4 · Verify the savings
Every response includes a nex.cost_usd field — the exact USD billed to your wallet.
Compare it to OpenAI's per-request cost; for a 100-token round trip you should see something like:
// nex-pro: $0.000019
// gpt-4o: $0.000380 (20× more)
// gpt-4o-mini: $0.000022 (still 15% more than nex-pro)