文档

快速开始

PingToken 提供统一的 API 端点来访问多种 AI 大模型。所有请求发送至 https://pingtoken.cn/api/v1

curl https://pingtoken.cn/api/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-pro",
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Base URL: https://pingtoken.cn/api/v1

认证方式

在控制台的令牌管理页面创建 API 令牌。每个令牌可以限制只能访问特定模型并设置速率限制。所有 API 请求必须在 Authorization 请求头中携带令牌。

Include your token in the Authorization header as a Bearer token:

Authorization: Bearer YOUR_API_TOKEN

Tokens are created from the Console → Token Management page. The raw token value is shown only once upon creation — store it securely.

对话补全

向 AI 模型发送消息并获取回复。支持流式和非流式两种模式。

Endpoint

POST https://pingtoken.cn/api/v1/chat/completions

Request Body

FieldTypeRequiredDescription
modelstringYesModel ID (e.g. deepseek-v4-pro)
messagesarrayYesArray of message objects with role and content
streambooleanNoEnable streaming (default: false)
temperaturenumberNoSampling temperature (0-2)
max_tokensintegerNoMaximum tokens in the response

Response

{
  "id": "chatcmpl-abc123",
  "model": "deepseek-v4-pro",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "Hello! How can I help you today?"
    },
    "finish_reason": "stop"
  }],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 9,
    "total_tokens": 19
  }
}

Code Examples

import requests

url = "https://pingtoken.cn/api/v1/chat/completions"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}
data = {
    "model": "deepseek-v4-pro",
    "messages": [
        {"role": "user", "content": "Hello, how are you?"}
    ]
}

response = requests.post(url, headers=headers, json=data)
result = response.json()

# Print the assistant's reply
print(result["choices"][0]["message"]["content"])
print(f"Tokens used: {result['usage']['total_tokens']}")

# Streaming example
data["stream"] = True
with requests.post(url, headers=headers, json=data, stream=True) as r:
    for line in r.iter_lines():
        if line:
            line = line.decode("utf-8")
            if line.startswith("data: ") and line != "data: [DONE]":
                import json
                chunk = json.loads(line[6:])
                content = chunk["choices"][0].get("delta", {}).get("content", "")
                if content:
                    print(content, end="", flush=True)
import java.net.URI;
import java.net.http.*;
import java.io.*;
import com.google.gson.*;

public class ChatExample {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();

        JsonObject data = new JsonObject();
        data.addProperty("model", "deepseek-v4-pro");
        JsonArray messages = new JsonArray();
        JsonObject msg = new JsonObject();
        msg.addProperty("role", "user");
        msg.addProperty("content", "Hello, how are you?");
        messages.add(msg);
        data.add("messages", messages);

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://pingtoken.cn/api/v1/chat/completions"))
            .header("Authorization", "Bearer YOUR_API_TOKEN")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(data.toString()))
            .build();

        HttpResponse<String> response = client.send(request,
            HttpResponse.BodyHandlers.ofString());

        JsonObject result = JsonParser.parseString(response.body())
            .getAsJsonObject();

        String content = result.getAsJsonArray("choices")
            .get(0).getAsJsonObject()
            .getAsJsonObject("message")
            .get("content").getAsString();
        System.out.println(content);

        int totalTokens = result.getAsJsonObject("usage")
            .get("total_tokens").getAsInt();
        System.out.println("Tokens used: " + totalTokens);
    }
}

// Requires: JDK 11+ (HttpClient), Gson for JSON parsing
// Add to pom.xml:
// <dependency>
//   <groupId>com.google.code.gson</groupId>
//   <artifactId>gson</artifactId>
//   <version>2.10.1</version>
// </dependency>
// Node.js 18+ (built-in fetch)
// For older Node.js, install: npm install node-fetch

const url = "https://pingtoken.cn/api/v1/chat/completions";
const headers = {
  "Authorization": "Bearer YOUR_API_TOKEN",
  "Content-Type": "application/json"
};
const body = {
  model: "deepseek-v4-pro",
  messages: [
    { role: "user", content: "Hello, how are you?" }
  ]
};

// Non-streaming request
const response = await fetch(url, {
  method: "POST",
  headers,
  body: JSON.stringify(body)
});
const result = await response.json();

console.log(result.choices[0].message.content);
console.log(`Tokens used: ${result.usage.total_tokens}`);

// Streaming request
body.stream = true;
const streamResp = await fetch(url, {
  method: "POST",
  headers,
  body: JSON.stringify(body)
});

const reader = streamResp.body.getReader();
const decoder = new TextDecoder();
let buffer = "";

while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  buffer += decoder.decode(value, { stream: true });
  const lines = buffer.split("\n");
  buffer = lines.pop() || "";
  for (const line of lines) {
    if (line.startsWith("data: ") && line !== "data: [DONE]") {
      const chunk = JSON.parse(line.slice(6));
      const content = chunk.choices[0]?.delta?.content;
      if (content) process.stdout.write(content);
    }
  }
}

可用模型

浏览模型广场查看所有支持的模型及详细定价信息。

Note: PingToken only supports domestic Chinese AI models. Foreign models (Claude, OpenAI/GPT, Gemini, etc.) are not supported.

Popular models include:

Model IDProvider
qwen3-maxAlibaba Cloud
qwen3-plusAlibaba Cloud
deepseek-v4-proDeepSeek
deepseek-r1DeepSeek
ernie-5.0Baidu
kimi-k2Moonshot AI
glm-5Zhipu AI
doubao-proByteDance
spark-4.0iFLYTEK

View the complete list at the Model Plaza.

定价说明

每个模型按千 Token 分别计费,输入和输出价格不同。Pro 订阅用户享受专属折扣价格。具体价格请查看模型广场。

Usage costs are deducted from your wallet balance automatically. You can top up your balance from the Console → Wallet page.

速率限制

免费用户:60 次请求/分钟。Pro 用户:600 次请求/分钟。如需更高限制请联系我们。

Rate limits are applied per API token. When the limit is exceeded, the API returns a 429 Too Many Requests response. Each token can have its own rate limit configured during creation.

客户端配置

Configure your PingToken model in various client tools. Replace MODEL_ID with the actual model ID and YOUR_API_TOKEN with your PingToken API key.

Base URL: https://pingtoken.cn/api/v1

Cursor

File: ~/.cursor/settings.json

{
  "chat.model": "MODEL_ID",
  "chat.openAiApiOverride": "https://pingtoken.cn/api/v1",
  "chat.openAiApiKeyOverride": "YOUR_API_TOKEN"
}

Cherry Studio

在 Cherry Studio 的模型提供商配置中添加 OpenAI 兼容提供商:

{
  "type": "openai",
  "name": "PingToken",
  "apiKey": "YOUR_API_TOKEN",
  "apiUrl": "https://pingtoken.cn/api/v1",
  "models": ["MODEL_ID"]
}

Cline (VS Code Extension)

File: cline_mcp_settings.json

{
  "apiProvider": "openai",
  "openAiApiKey": "YOUR_API_TOKEN",
  "openAiBaseUrl": "https://pingtoken.cn/api/v1",
  "openAiModelId": "MODEL_ID"
}

Dify

在 Dify 的模型提供商中选择「OpenAI API Compatible」:

{
  "provider": "openai_api_compatible",
  "model": "MODEL_ID",
  "api_key": "YOUR_API_TOKEN",
  "base_url": "https://pingtoken.cn/api/v1"
}

Claude Code Router

File: ~/.claude-code-router/config.json

{
  "Providers": [
    {
      "name": "pingtoken",
      "api_base_url": "https://pingtoken.cn/api/v1/chat/completions",
      "api_key": "YOUR_API_TOKEN",
      "models": ["MODEL_ID"]
    }
  ],
  "Router": {
    "default": "pingtoken,MODEL_ID"
  }
}

Codex CLI

通过环境变量或配置文件设置:

# 环境变量方式
export CODEX_API_BASE="https://pingtoken.cn/api/v1"
export CODEX_MODEL="MODEL_ID"
export CODEX_API_KEY="YOUR_API_TOKEN"

# codex_config.json 方式:
# {
#   "apiBase": "https://pingtoken.cn/api/v1",
#   "model": "MODEL_ID",
#   "apiKey": "YOUR_API_TOKEN"
# }

更多 Agent 工具配置:

以下 Agent 工具已有独立文档页面,包含完整的安装和配置说明:

查看完整 Agent 工具列表 →

Qwen Code

File: qwen_code_config.json

{
  "api_base": "https://pingtoken.cn/api/v1",
  "api_key": "YOUR_API_TOKEN",
  "model": "MODEL_ID"
}

Lingma

File: lingma_config.json

{
  "apiKey": "YOUR_API_TOKEN",
  "baseUrl": "https://pingtoken.cn/api/v1",
  "model": "MODEL_ID"
}

帮助文档

欢迎使用 PingToken 帮助文档。这里提供详细的使用指南和操作说明,帮助您快速上手平台功能。

计费规则

费用计算方式

API 调用按 Token 用量计费,包括输入 Token 和输出 Token。每个模型有独立的输入/输出价格(每百万 Token),费用从用户账户余额实时扣除。

计算公式:总费用 = (输入 Token × 输入价格 + 输出 Token × 输出价格) / 1百万

扣费优先级
  1. Token 余额:直接按 Token 数量抵扣,优先级最高
  2. 订阅额度:购买订阅套餐获得的额度
  3. 钱包余额:充值获得,允许为负数

模型 API 使用规则

认证方式

所有 API 请求必须在 Authorization 请求头中携带令牌:

Authorization: Bearer YOUR_API_TOKEN
请求限制
用户类型请求频率上下文限制
免费用户60 次/分钟5K tokens
Pro 用户600 次/分钟无限制
错误处理
错误码说明
401未授权 - 检查 Authorization 头
402余额不足 - 充值或等待奖励
429请求超限 - 降低请求频率

工具使用规则

通用规则
  • 必须使用 PingToken 提供的 API 端点
  • 必须配置正确的 Authorization 令牌
  • 建议设置合理的速率限制
  • 不要在公共仓库中提交令牌
支持的工具

OpenClaw、Claude-Code、Codex、Qoder、Cursor、Cherry Studio、Dify 等

钱包、订阅、Token 奖励区别与使用

余额类型获取方式使用场景是否可负
Token 余额注册奖励、邀请奖励免费 API 调用
订阅额度购买订阅套餐API 调用消费
钱包余额充值订阅支付、API 消费

令牌管理流程

创建令牌
  1. 登录控制台,进入"令牌管理"页面
  2. 填写令牌名称、过期时间
  3. 可选:绑定特定模型、设置速率限制
  4. 保存并复制令牌(仅显示一次)
使用令牌

在 API 请求头中携带令牌进行认证。建议为不同用途创建独立令牌,便于追踪和管理。

吊销令牌

在令牌管理页面点击"吊销"按钮,令牌立即失效。

模型测试

  1. 登录控制台,进入"模型测试"页面
  2. 选择令牌和模型
  3. 设置温度、响应风格等参数
  4. 输入消息并发送

注意:测试对话使用付费模型会正常计费,消耗您的账户余额。

Postman API 测试

配置步骤
  1. 创建 POST 请求:https://pingtoken.cn/api/v1/chat/completions
  2. 添加请求头:Authorization: Bearer YOUR_API_TOKEN
  3. 设置请求体(JSON 格式)
  4. 发送请求并查看响应

Python 代码测试

import requests

url = "https://pingtoken.cn/api/v1/chat/completions"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}
data = {
    "model": "deepseek-v4-pro",
    "messages": [{"role": "user", "content": "Hello"}]
}

response = requests.post(url, headers=headers, json=data)
print(response.json()["choices"][0]["message"]["content"])

工具测试指南

通用配置步骤
  1. 找到工具的 API 设置页面
  2. 设置 API 端点为 https://pingtoken.cn/api/v1
  3. 配置 Authorization 令牌
  4. 测试连接确保配置正确
常见工具配置
  • Cursor: 在 ~/.cursor/settings.json 中配置
  • Claude Code: 在 ~/.claude/settings.json 中配置
  • OpenClaw: 在插件设置中配置