zai-org / zai-org/feedback

[Documentation Gap + Bug] Z.ai Official Docs Missing Instructions for API (Pay-Per-Go) Users to Use Claude Code β€” No Valid Endpoint for Prepaid Balance

Open
#316 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

priority: P2
Dominant language
No language data
Stars
22
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Documentation Gap & Functionality Issue: Claude Code Usage for API (Prepaid) Users

πŸ“‹ Summary

Critical documentation gap and potential functionality bug: Z.ai official documentation does not provide clear instructions for API (pay-per-go/prepaid balance) users who want to use Claude Code. Users on exhausted Coding Plan quotas cannot seamlessly fall back to prepaid balance for Claude Code usage, and there is no documented Anthropic-compatible endpoint that works for API-only users.

Severity: HIGH β€” Paying customers unable to use purchased credits with popular tool


🎯 Problem Description

User Scenario
User: systemserik
Plan: GLM Coding Max (monthly)
Status: Weekly quota EXHAUSTED (100% used)
Action: Added funds to prepaid/API balance
Goal: Use Claude Code with prepaid balance after quota exhaustion
Result: ❌ 429 Error 1310 "Weekly/Monthly Limit Exhausted"
       ❌ Prepaid balance NOT being used
Core Issues
Issue #1: Documentation Gap

Missing from official docs:

  • ❌ No instructions for API (prepaid) users on how to configure Claude Code
  • ❌ No clarification on which endpoint to use for pay-per-go vs Coding Plan
  • ❌ No explanation of whether /api/paas/v4 supports Anthropic Messages API format
  • ❌ No fallback mechanism documented when Coding Plan quota is exhausted

What docs DO show (confusing/incomplete):

Endpoint Documented For Protocol Who Can Use?
/api/anthropic Claude Code, Coding Plan Anthropic Messages API Coding Plan subscribers ONLY?
/api/paas/v4 OpenAI-compatible tools OpenAI Chat Completions ??? Unclear for Claude Code
??? API/Prepaid users + Claude Code ??? ❌ NOT DOCUMENTED

πŸ’¬ Discord Conversation Timeline

Initial Problem Report

systemserik: "I'm on the GLM Coding Max monthly plan and have hit 100% of my weekly quota. I added money to my prepaid balance, but Claude Code won't use it and still returns 429 / 1310 Weekly/Monthly Limit Exhausted."

"How can I make Claude Code use the prepaid balance after the plan quota is exhausted?"

Staff Response #1

Agnes|Z.ai: "plz change the URL: https://api.z.ai/api/paas/v4"

User Clarification Question

systemserik: "Just to confirm: in Claude Code, should I set ANTHROPIC_BASE_URL=https://api.z.ai/api/paas/v4 directly, while keeping my existing Z.ai API key?"

Staff Response #2 (Creating More Confusion)

Agnes|Z.ai: "CZ API and coding plan have different URL"

User's Technical Question

systemserik: "Thanks. Just want to confirm the protocol: the docs show Claude Code using the Anthropic Messages endpoint /api/anthropic, while /api/paas/v4 is documented as OpenAI-compatible."

"Does /api/paas/v4 also support Anthropic Messages directly, so I can set it as ANTHROPIC_BASE_URL in Claude Code? Or is there a separate Anthropic-compatible endpoint for prepaid/API balance?"

Volunteer Intervention

Roman | Z (Volunteer/Mod): "Hello, for Claude we shall only use the anthropic supported endpoint. Others won't work properly if at all."

User's Concern

systemserik: "So that means I can't use my prepaid balance I added with Claude?"

Escalation

Roman | Z: "Let me double check on that question, since you should be able to."
"Looks like official docs lacking clarity on this question."
"I shall escalate with @Agnes|Z.ai to see if we could get proper confirmation from back end team."

Testing Suggested

Roman | Z: "Could you please try in your API balance, to use the same anthropic endpoint, see if it works for you?"

Test Result β€” STILL BROKEN

systemserik: "no it does not work, that's what we were already using when we received the 1310 error despite having API balance"
"I am able to have a temporary workaround through a local LiteLLM proxy, but it seems very slow"

Final Assessment

Roman | Z: "@Agnes|Z.ai tagging here, to assist with internal check on this one. There isn't an official anthropic endpoint for API users and a user who try to use this endpoint on API balance, having a clear rejection error."


πŸ” Root Cause Analysis

The Fundamental Problem
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚                 THE ENDPOINT GAP                              β”‚β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”‚                                                             β”‚β”‚  CODING PLAN USERS:                                         β”‚β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                        β”‚β”‚  β”‚ /api/anthropic  β”‚ ← Works with Claude Code βœ…             β”‚β”‚  β”‚ (Anthropic Msg) β”‚    Uses plan quota                      β”‚β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                        β”‚β”‚         ↓                                                    β”‚β”‚    Quota Exhausted β†’ 429 Error 1310                          β”‚β”‚         ↓                                                    β”‚β”‚    User wants to use PREPAID balance                        β”‚β”‚         ↓                                                    β”‚β”‚  ❌ NO ENDPOINT DOCUMENTED FOR THIS!                       β”‚β”‚                                                             β”‚β”‚  WHAT USER TRIED:                                           β”‚β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                        β”‚β”‚  β”‚ /api/anthropic  β”‚ + API key β†’ 429 Error ❌               β”‚β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    (Rejects API balance)                β”‚β”‚                                                             β”‚β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                        β”‚β”‚  β”‚ /api/paas/v4    β”‚ + ANTHROPIC_BASE_URL β†’ ??? ❓          β”‚β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    (OpenAI format? Won't work?)         β”‚β”‚                                                             β”‚β”‚  WORKAROUND (Slow):                                         β”‚β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                        β”‚β”‚  β”‚ Local LiteLLM   β”‚ ← Works but slow ⚠️                   β”‚β”‚  β”‚ Proxy           β”‚    (User shouldn't need this!)          β”‚β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                        β”‚β”‚                                                             β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜```

### Questions That Remain Unanswered

1. **Is there an Anthropic-compatible endpoint for API/prepaid users?**
   - If YES: What is it? Why isn't it documented?
   - If NO: When will one be available?

2. **Does `/api/paas/v4` support Anthropic Messages API format?**
   - If YES: Document this clearly for Claude Code users
   - If NO: Users need a different solution

3. **Should `/api/anthropic` accept BOTH Coding Plan AND API balance?**
   - Current behavior: Rejects API balance with 1310 error
   - Expected behavior: Fall back to prepaid after quota exhaustion

4. **Why is there a separation between "CZ API" and "coding plan" URLs?**
   - This creates confusion for users
   - Should be abstracted away or clearly explained

---

## βœ… Proposed Solutions

### Solution A: Documentation Fix (Immediate)

**Create clear guide: "Using Claude Code with Z.ai"**

```markdown
# Using Claude Code with Z.ai

## For Coding Plan Subscribers

1. Set your API key from Z.ai dashboard
2. Configure Claude Code:
   ```bash
   export ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic
   export ANTHROPIC_API_KEY=your_zai_key
  1. Use normally β€” counts against your plan quota

When Quota Is Exhausted

⚠️ Currently, Claude Code will return 429 when plan quota is exhausted.

Option 1: Wait for quota reset (weekly/monthly)
Option 2: Add prepaid balance (COMING SOON / NOT YET SUPPORTED)

[Clear status of this feature]

Option 3: Switch to API-only mode
export ANTHROPIC_BASE_URL=https://api.z.ai/api/[CORRECT-ENDPOINT-FOR-API]
# Note: This uses your prepaid balance, not plan quota

For API-Only Users (No Coding Plan)

[Instructions if supported, or clear statement if not]


---

### Solution B: Backend Fix (Short-Term)

**Make `/api/anthropic` accept both plan quota AND prepaid balance:**

```javascript
// Pseudo-code for rate limit check
function checkRateLimit(user, request) {
  const planQuota = getPlanQuota(user);     // Coding Plan allowance
  const prepaidBalance = getPrepaidBalance(user); // API balance
  
  if (planQuota.remaining > 0) {
    deductFromPlanQuota(user, request.cost);
    return { allowed: true, source: 'plan' };
  }
  
  if (prepaidBalance > request.cost) {
    deductFromPrepaid(user, request.cost);
    return { allowed: true, source: 'prepaid' };
  }
  
  // Both exhausted
  throw new RateLimitError(1310, 'Plan quota and prepaid balance exhausted');
}

Benefits:

  • Seamless fallback from plan β†’ prepaid
  • Single endpoint for all users
  • No configuration changes needed when quota exhausts

Solution C: New Endpoint (If B Not Possible)

Create dedicated Anthropic-compatible endpoint for API users:

POST https://api.z.ai/api/anthropic/v1/messages

Headers:
  Authorization: Bearer zai-api-key-[PREPAID]
  anthropic-version: 2023-06-01

Body: Standard Anthropic Messages API format

Behavior:
  - Ignores Coding Plan quota entirely
  - Charges only against prepaid/API balance
  - Returns standard Anthropic error format
  - Works with Claude Code out-of-box

πŸ“‹ Current Workarounds (Not Ideal)

Workaround 1: Local LiteLLM Proxy (User Found)
# litellm_config.yaml
model_list:
  - model_name: claude-sonnet-4-20250514
    litellm_params:
      model: anthropic/claude-sonnet-4-20250514
      api_base: https://api.z.ai/[SOME-ENDPOINT]
      api_key: ${ZAI_API_KEY}

# Run proxy
litellm --config litellm_config.yaml --port 4000

# Point Claude Code to local proxy
export ANTHROPIC_BASE_URL=http://localhost:4000

Pros: Works (sort of)
Cons: Slow; adds latency; requires self-hosting; shouldn't be necessary

Workaround 2: Wait for Quota Reset

Pros: Free; no config changes
Cons: Downtime; loses productivity; defeats purpose of prepaid balance

Workaround 3: Switch to Different Tool

Use ZCode, OpenCode, or web interface instead of Claude Code during quota exhaustion.

Pros: May work with other endpoints
Cons: Loses Claude Code workflow; tool lock-in


πŸ“Š Impact Assessment

Metric Value
Severity HIGH β€” Paying customers blocked from using purchased credits
Affected Users All API/prepaid users who want Claude Code + Coding Plan subscribers post-quota-exhaustion
Confusion Level HIGH β€” Even staff gave conflicting guidance
Documentation Quality POOR β€” Critical gap for popular use case
Workaround Difficulty MEDIUM β€” Requires technical knowledge (LiteLLM)
Revenue Impact Users may not top up balance if they can't use it

🎯 Specific Asks for Team

Immediate (This Week)
  1. Clarify endpoint situation: Which endpoint (if any) should API users use for Claude Code?
  2. Update docs: Add section "Claude Code for API/Prepaid Users" even if status is "not yet supported"
  3. Fix error message: When /api/anthropic rejects API balance, say clearly: "This endpoint is for Coding Plan only. API users should use: [endpoint or 'not yet supported']"
Short-Term (This Month)
  1. Enable prepaid fallback on /api/anthropic OR create new API-user endpoint
  2. Unify documentation under single "Claude Code Setup" page with clear paths for each user type
Long-Term (This Quarter)
  1. Seamless quota stacking: Plan quota β†’ Auto-fallback to prepaid β†’ Clear usage breakdown
  2. Single endpoint abstraction: One URL, automatic billing source selection

πŸ’‘ Additional Context

  • Primary Reporter: systemserik (Discord)
  • Staff Involved: Agnes|Z.ai, Roman|Z (Volunteer/Mod)
  • Discord Thread: https://discord.com/channels/1346756824233148527/1539503972652548106
  • Error Codes Encountered:
    • 429 β€” Rate Limit
    • 1310 β€” Weekly/Monthly Limit Exhausted
  • User's Workaround: Local LiteLLM proxy (functional but slow)
  • Key Insight from Volunteer: "There isn't an official anthropic endpoint for API users and a user who try to use this endpoint on API balance, having a clear rejection error."

Submitted by:
Regards,
Roman (Discord: bignavi_x)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up β€” it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the documented Claude Code setup and the two mentioned endpoints: /api/anthropic and /api/paas/v4. Verify which user types and request protocols each supports, using the reported 429/1310 behavior as the test case. Done means the supported API/prepaid path and quota behavior are confirmed and clearly documented, or the missing functionality is separately defined.

Written by the indexing model from the issue text.

Assessment

Domain
api, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.