Documentos

Inicio rápido

PingToken proporciona un endpoint API unificado para acceder a múltiples modelos de IA. Todas las solicitudes van a 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

Autenticación

Cree tokens de API desde la página Consola → Gestión de Tokens. Cada token puede restringirse a modelos específicos y límites de velocidad. Incluya su token en el encabezado Authorization de cada solicitud.

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.

Completaciones de Chat

Envíe mensajes a modelos de IA y reciba respuestas. Soporta modos streaming y no streaming.

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);
    }
  }
}

Modelos Disponibles

Explore la Plaza de Modelos para ver todos los modelos compatibles con precios detallados.

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.

Precios

Cada modelo se factura por 1.000 tokens, con tarifas diferentes para entrada y salida. Los suscriptores Pro disfrutan de tarifas con descuento. Consulte la Plaza de Modelos para precios específicos.

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

Límites de Velocidad

Usuarios gratuitos: 60 solicitudes/minuto. Usuarios Pro: 600 solicitudes/minuto. Contáctenos para límites superiores.

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.

Configuración del Cliente

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"
}

Documentación de Ayuda

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

Reglas de Facturación

费用计算方式

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

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

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

Reglas de Uso de API

认证方式

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

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

Reglas de Uso de Herramientas

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

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

Billetera, Suscripción y Bonificación de Tokens

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

Flujo de Gestión de Tokens

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

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

吊销令牌

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

Prueba de Modelo

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

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

Prueba de API Postman

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

Prueba de Código 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"])

Guía de Prueba de Herramientas

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