Skip to content

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

PowerTokens TypeScript / Node.js Examples

TypeScript and Node.js examples for building AI applications with the PowerTokens unified AI API.

Unified API for Chinese AI models — no Chinese account required. OpenAI-compatible.

Get started · Docs · Models

Examples

Example Model Path
MiniMax chat MiniMax-M3 chat/minimax_m3.ts
Qwen chat qwen3-max chat/qwen3_max.ts
GLM chat glm-5.2 chat/glm_5_2.ts

Requirements

  • Node.js 18+
  • A PowerTokens API key
  • The OpenAI Node.js SDK

Install

npm install openai
# optional runner for .ts files:
npm install -D tsx

Quickstart

Base URL for OpenAI-compatible SDKs: https://api.powertokens.ai/v1

export POWERTOKENS_API_KEY=your_key
npx tsx chat/minimax_m3.ts
# or: npx tsx chat/qwen3_max.ts
# or: npx tsx chat/glm_5_2.ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.POWERTOKENS_API_KEY,
  baseURL: "https://api.powertokens.ai/v1",
});

const resp = await client.chat.completions.create({
  model: "MiniMax-M3",
  messages: [
    { role: "system", content: "You are a concise assistant." },
    { role: "user", content: "Describe Paris in one sentence." },
  ],
  temperature: 0.3,
});

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

Create an API key in the dashboard.

FAQ (common search questions)

How do I call Qwen API without a Chinese account?

Use PowerTokens as an OpenAI-compatible gateway: set baseURL to https://api.powertokens.ai/v1, use your PowerTokens API key, and pick a Qwen model id from the catalog (for example qwen3-max). You do not need a mainland China phone / Alibaba account.

What is the OpenAI-compatible base URL for GLM / MiniMax / DeepSeek?

https://api.powertokens.ai/v1

Example model ids (always confirm in the live catalog):

  • GLM: glm-5.2
  • MiniMax: MiniMax-M3
  • DeepSeek: deepseek-v3-2-251201
const client = new OpenAI({
  apiKey: process.env.POWERTOKENS_API_KEY,
  baseURL: "https://api.powertokens.ai/v1",
});
const resp = await client.chat.completions.create({
  model: "deepseek-v3-2-251201",
  messages: [{ role: "user", content: "Hello" }],
});

PowerTokens vs OpenRouter for China-origin models?

Both can be OpenAI-compatible gateways. PowerTokens focuses on China-origin model families (Qwen, GLM, MiniMax, DeepSeek, Seed, video stacks) with no Chinese mainland account required and one unified key. Use the model catalog for current ids and pricing; see also awesome-chinese-model-apis for a neutral gateway comparison.

How do I call DeepSeek V3.2 with the OpenAI Node.js SDK?

Run npm install openai, create the client with your PowerTokens API key and baseURL: "https://api.powertokens.ai/v1", then pass model: "deepseek-v3-2-251201" to chat.completions.create. The code is the same as chat/qwen3_max.ts with only the model id changed.

Do I need a separate API key for each model?

No. One PowerTokens API key works for every model in the catalog, with no per-model binding, so switching between Qwen, GLM, MiniMax and DeepSeek V3.2 only means changing the model string (create a key).

Does PowerTokens work with Claude Code or Codex?

Yes. Besides OpenAI Chat Completions (/v1/chat/completions), PowerTokens serves the Anthropic Messages format (/v1/messages) used by Claude Code and the OpenAI Responses format (/v1/responses) used by Codex; GLM models are not available on the Responses path (protocol guide). The docs have setup guides for Claude Code, opencode, Kilo Code, Hermes Agent and OpenClaw.

How do I pay for PowerTokens?

Add Credits on the Billing page with a credit card or PayPal; no Chinese bank account or payment app is needed. See the quickstart.

Why PowerTokens

  • One API: video, image, audio, and LLM model families
  • OpenAI-compatible: reuse familiar OpenAI SDK patterns
  • No Chinese mainland account required

Useful links

Start building — powertokens.ai. New-user bonus Credits are offered only while a promotion is running; otherwise add Credits on the Billing page.

Maintained by @uselesssoso for PowerTokens.

About

TypeScript / Node.js examples for Chinese AI models (Qwen, GLM, MiniMax, DeepSeek V3.2) with the OpenAI SDK via PowerTokens' OpenAI-compatible API. No Chinese account required.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages