Troubleshooting

401 Authentication Error

Symptom: Claude Code returns "Authentication error" or "Invalid API key".

Steps to resolve:

  1. Confirm your API key format is correct (should start with ck-):
terminal
bash
echo $ANTHROPIC_API_KEY
# Should output ck-xxxxxxxxxxxx
  1. Verify the key is valid with curl:
terminal
bash
curl -s https://api.chuizi.ai/v1/key/info \
  -H "Authorization: Bearer $ANTHROPIC_API_KEY" | jq
  1. If this returns an error, the cause is likely:
    • Key was deleted or disabled -- check key status at app.chuizi.ai
    • Key was partially copied -- recopy the full key
    • Environment variable not loaded -- run source ~/.zshrc or open a new terminal

Connection Timeout

Symptom: Requests hang for a long time before timing out.

Steps to resolve:

  1. Test connectivity to Chuizi.AI:
terminal
bash
curl -I https://api.chuizi.ai/health
  1. Confirm ANTHROPIC_BASE_URL is set correctly:
terminal
bash
echo $ANTHROPIC_BASE_URL
# Should output https://api.chuizi.ai/anthropic
  1. Common causes:
    • Network requires a proxy -- set the HTTPS_PROXY environment variable
    • DNS resolution issues -- try using 1.1.1.1 or 8.8.8.8 as your DNS server
    • Firewall blocking -- ensure HTTPS outbound to api.chuizi.ai is allowed

Prompt Caching Not Working

Symptom: Costs are not reduced as expected, no cache_read_input_tokens visible in the dashboard.

Steps to resolve:

  1. Confirm you're using the /anthropic endpoint:
terminal
bash
echo $ANTHROPIC_BASE_URL
# Must be https://api.chuizi.ai/anthropic
# If set to https://api.chuizi.ai/v1, caching behavior differs
  1. Check the request log in the dashboard for these usage fields:

    • cache_creation_input_tokens -- tokens written to cache on first request
    • cache_read_input_tokens -- tokens served from cache on subsequent requests
  2. Common reasons caching doesn't activate:

    • System prompt is too short -- Anthropic requires at least 1024 tokens to trigger caching
    • Too much time between requests -- cache expires after approximately 5 minutes
    • Request prefix changes between calls -- caching requires identical prefixes across consecutive requests

Next Steps