Skip to content

Zhipu AI and Z.ai Quota Query: 5-Hour Token Limit and Monthly MCP Quota

What You'll Learn

  • View usage status of Zhipu AI and Z.ai 5-hour token limits
  • Understand the meaning and reset rules of MCP monthly quotas
  • Read information from quota output such as progress bars, usage, totals
  • Know when usage warnings are triggered

Your Current Challenge

You use Zhipu AI or Z.ai for application development but often encounter these issues:

  • Unsure how much remains in the 5-hour token limit
  • Request failures after exceeding limits, impacting development progress
  • Unclear about the specific meaning of MCP monthly quotas
  • Need to log into both platforms separately to check quotas, which is inconvenient

When to Use This

When you:

  • Use Zhipu AI / Z.ai APIs for application development
  • Need to monitor token usage to avoid exceeding limits
  • Want to understand the monthly quota for MCP search functionality
  • Use both Zhipu AI and Z.ai and want unified quota management

Core Concepts

Zhipu AI and Z.ai quota systems are divided into two types:

Quota TypeMeaningReset Cycle
5-Hour Token LimitToken usage limit for API requestsAutomatically resets every 5 hours
MCP Monthly QuotaMonthly limit on MCP (Model Context Protocol) search countResets monthly

The plugin calls official APIs to query this data in real-time and visually displays remaining quotas with progress bars and percentages.

What is MCP?

MCP (Model Context Protocol) is the Model Context Protocol provided by Zhipu AI, allowing AI models to search and reference external resources. The MCP monthly quota limits the number of searches available each month.

Follow Along

Step 1: Configure Zhipu AI / Z.ai Accounts

Why The plugin needs API Keys to query your quotas. Zhipu AI and Z.ai use API Key authentication.

Action

  1. Open the ~/.local/share/opencode/auth.json file

  2. Add API Key configuration for Zhipu AI or Z.ai:

json
{
  "zhipuai-coding-plan": {
    "type": "api",
    "key": "Your Zhipu AI API Key"
  },
  "zai-coding-plan": {
    "type": "api",
    "key": "Your Z.ai API Key"
  }
}

You should see:

  • The configuration file contains zhipuai-coding-plan or zai-coding-plan fields
  • Each field has type: "api" and key fields

Step 2: Query Quotas

Why Call official APIs to get real-time quota usage status.

Action

Execute the slash command in OpenCode:

bash
/mystatus

Or ask in natural language:

Check my Zhipu AI quota

You should see output similar to this:

## Zhipu AI Account Quota

Account:        9c89****AQVM (Coding Plan)

5-Hour Token Limit
███████████████████████████ 95% remaining
Used: 0.5M / 10.0M
Reset: in 4 hours

MCP Monthly Quota
██████████████████░░░░░░░ 60% remaining
Used: 200 / 500

## Z.ai Account Quota

Account:        9c89****AQVM (Z.ai)

5-Hour Token Limit
███████████████████████████ 95% remaining
Used: 0.5M / 10.0M
Reset: in 4 hours

Step 3: Interpret Output

Why Understanding the meaning of each output line allows you to effectively manage quotas.

Action

Compare your output with the following explanation:

Output FieldMeaningExample
AccountMasked API Key and account type9c89****AQVM (Coding Plan)
5-Hour Token LimitToken usage within current 5-hour periodProgress bar + percentage
Used: X / YUsed tokens / Total quota0.5M / 10.0M
Reset: in X hoursCountdown to next resetin 4 hours
MCP Monthly QuotaMonthly MCP search count usageProgress bar + percentage
Used: X / YUsed count / Total quota200 / 500

You should see:

  • The 5-hour token limit section has a reset time countdown
  • The MCP monthly quota section has no reset time (because it resets monthly)
  • If usage exceeds 80%, a warning alert appears at the bottom

Checkpoint ✅

Confirm you understand the following:

  • [ ] 5-hour token limits have a reset countdown
  • [ ] MCP monthly quotas reset monthly and don't show a countdown
  • [ ] Usage warnings are triggered when usage exceeds 80%
  • [ ] API Keys are masked (only first 4 and last 4 characters shown)

Troubleshooting

❌ Common Error 1: Missing type Field in Configuration File

Error: Query prompts "No configured accounts found"

Cause: Missing type: "api" field in auth.json

Fix:

json
// ❌ Wrong
{
  "zhipuai-coding-plan": {
    "key": "Your API Key"
  }
}

// ✅ Correct
{
  "zhipuai-coding-plan": {
    "type": "api",
    "key": "Your API Key"
  }
}

❌ Common Error 2: API Key Expired or Invalid

Error: Shows "API request failed" or "Authentication failed"

Cause: API Key has expired or been revoked

Fix:

  • Log in to Zhipu AI / Z.ai console
  • Regenerate API Key
  • Update the key field in auth.json

❌ Common Error 3: Confusing Two Quota Types

Error: Assuming token limit and MCP quota are the same thing

Fix:

  • Token Limit: Token usage for API calls, resets every 5 hours
  • MCP Quota: MCP search count, resets monthly
  • These are two independent limits and don't affect each other

Summary

In this lesson, we learned how to use opencode-mystatus to query quotas for Zhipu AI and Z.ai:

Core Concepts:

  • 5-Hour Token Limit: API call limit with reset countdown
  • MCP Monthly Quota: MCP search count, resets monthly

Steps:

  1. Configure zhipuai-coding-plan or zai-coding-plan in auth.json
  2. Execute /mystatus to query quotas
  3. Interpret progress bars, usage, and reset times from the output

Key Points:

  • Usage warnings are triggered when usage exceeds 80%
  • API Keys are automatically masked
  • Token limits and MCP quotas are two independent limits

Coming Up Next

In the next lesson, we'll learn GitHub Copilot Quota Query.

You'll learn:

  • How to view Premium Requests usage
  • Monthly quota differences across subscription types
  • How to interpret model usage details

Appendix: Source Code Reference

Click to expand source code locations

Last updated: 2026-01-23

FeatureFile PathLines
Query Zhipu AI quotasource/vbgate/opencode-mystatus/plugin/lib/zhipu.ts213-217
Query Z.ai quotasource/vbgate/opencode-mystatus/plugin/lib/zhipu.ts224-228
Format outputsource/vbgate/opencode-mystatus/plugin/lib/zhipu.ts115-177
API endpoint configurationsource/vbgate/opencode-mystatus/plugin/lib/zhipu.ts62-76
ZhipuAuthData type definitionsource/vbgate/opencode-mystatus/plugin/lib/types.ts38-41
High usage warning thresholdsource/vbgate/opencode-mystatus/plugin/lib/types.ts110-111

Key Constants:

  • HIGH_USAGE_THRESHOLD = 80: Show warning when usage exceeds 80% (types.ts:111)

Key Functions:

  • queryZhipuUsage(authData): Query Zhipu AI account quota (zhipu.ts:213-217)
  • queryZaiUsage(authData): Query Z.ai account quota (zhipu.ts:224-228)
  • formatZhipuUsage(data, apiKey, accountLabel): Format quota output (zhipu.ts:115-177)
  • fetchUsage(apiKey, config): Call official API to get quota data (zhipu.ts:81-106)

API Endpoints:

  • Zhipu AI: https://bigmodel.cn/api/monitor/usage/quota/limit (zhipu.ts:63)
  • Z.ai: https://api.z.ai/api/monitor/usage/quota/limit (zhipu.ts:64)