解决CC Switch调用Minimax Coding Plan用量查询失败问题(附完整提取器代码)

5 阅读1分钟

问题背景

最近把Minimax刚出的Coding Plan加到Claude Code CLI里当自定义模型用,但是CC Switch开启配置用量查询后默认配置会失败

根因分析

默认配置用的是Minimax通用大模型的余额查询接口,而Coding Plan是独立的开发者产品线,用量查询用的是专属独立端点,完全不通用。

完整修复步骤

  1. 进入用量查询配置 image.png

  2. 配置请求地址和提取器代码 image.png 请求地址: https://www.minimaxi.com/v1/api/openplatform/coding_plan/remains 提取器代码:

({
  request: {
    url: "https://www.minimaxi.com/v1/api/openplatform/coding_plan/remains",
    method: "GET",
    headers: {
      Authorization: "Bearer {{apiKey}}",
      "Content-Type": "application/json",
    },
  },
  extractor: function (response) {
    var data = typeof response === "string" ? JSON.parse(response) : response;
    var modelRemains = Array.isArray(data.model_remains)
      ? data.model_remains
      : [];
    var targetModel =
      modelRemains.find(
        (item) =>
          item.model_name.startsWith("MiniMax") &&
          Number(item.current_interval_total_count || 0) > 0,
      ) || {};
    var total = Number(targetModel.current_interval_total_count || 0);
    var remaining = Number(targetModel.current_interval_usage_count || 0);
    var used = total > 0 ? total - remaining : 0;
    var percent = total > 0 ? Math.round((used / total) * 100) : 0;
    return {
      modelName: targetModel.model_name || "",
      used: used,
      balance: remaining,
      total: total,
      unit: "count",
      extra: percent + "%",
    };
  },
});
  1. 配置自动查询(可选)

image.png 4. 保存

效果

image.png