# bailian-ide

Part of **BAILIAN**

# Alibaba Cloud Model Studio Developer Tools and Support Troubleshooting Guide

## Problem Index

| Problem | Symptoms | Severity | Solution Summary |
|---------|----------|----------|------------------|
| Authentication and API Key Failures | `401 invalid access token`, `HTTP 401`, `403 invalid api-key` | High | Verify plan-specific API key format and Base URL. |
| Quota and Concurrency Limit Exhaustion | `hour/week/month allocated quota exceeded`, `concurrency allocated quota exceeded` | Medium | Wait for the specific quota reset window or retry for concurrency. |
| Context Length and Model Support Errors | `Range of input length should be [1, xxx]`, `model 'xxx' is not supported` | Medium | Reduce input length or verify exact case-sensitive model name. |
| Base URL and Routing Errors | `404 status code (no body)`, `Connection error`, OpenClaw timeouts | High | Correct the Base URL path and restart the local gateway. |

## Problem Details

### Problem 1: Authentication and API Key Failures

**Symptoms**
- Error message: `401 invalid access token or token expired`, `HTTP 401: Incorrect API key provided`, `403 invalid api-key`, `InvalidApiKey: Invalid API-key provided.`
- Behavior: API requests are rejected with 401 or 403 status codes. The IDE or coding agent fails to connect to the model service.
- Context: Occurs when configuring a new IDE plugin, switching between general Model Studio keys and plan-specific keys, or when a subscription expires.

**Root Cause**
- Using a general Model Studio API key instead of a plan-specific key (e.g., Coding Plan requires keys starting with `sk-sp-xxx`).
- The API key was copied with leading or trailing spaces.
- The subscription (Coding Plan or Token Plan) has expired.
- Using the wrong Base URL for the specific plan (e.g., using the general `dashscope.aliyuncs.com` URL for a Token Plan key).

**Solution**
1. Verify your API key format. For the Coding Plan, ensure the key starts with `sk-sp-xxx`.
2. Check for and remove any extra spaces in the API key string.
3. Ensure the Base URL matches your specific plan:
   - Coding Plan (China): `https://coding.dashscope.aliyuncs.com/v1`
   - Coding Plan (Global): `https://coding-intl.dashscope.aliyuncs.com/v1`
4. Log in to the Alibaba Cloud console to verify that your subscription is active and has not expired.

**Verification**
- Make a simple test API call or restart the IDE plugin. A `200 OK` response or successful model connection confirms authentication is working.

### Problem 2: Quota and Concurrency Limit Exhaustion

**Symptoms**
- Error message: `hour allocated quota exceeded`, `week allocated quota exceeded`, `month allocated quota exceeded`, `concurrency allocated quota exceeded`
- Behavior: API calls suddenly start failing after a period of heavy usage, even with a valid API key.
- Context: Occurs when using the Coding Plan, which enforces strict rolling and calendar-based quotas.

**Root Cause**
- The Coding Plan does not fall back to pay-as-you-go billing. Once a specific quota window is exhausted, further calls are blocked until the reset time. Concurrency limits are dynamically adjusted by the platform based on current resource load.

**Solution**
1. For `hour allocated quota exceeded`: Wait for the 5-hour rolling window to reset.
2. For `week allocated quota exceeded`: Wait until 00:00:00 (UTC+8) on Monday.
3. For `month allocated quota exceeded`: Wait until 00:00:00 (UTC+8) on the same day of the next billing month.
4. For `concurrency allocated quota exceeded`: Wait a few moments and retry the request, as the platform dynamically adjusts concurrency limits.

**Verification**
- Monitor your quota usage in the Alibaba Cloud console. Retry the API call after the specified reset time to confirm it succeeds.

### Problem 3: Context Length and Model Support Errors

**Symptoms**
- Error message: `400 InvalidParameter: Range of input length should be [1, xxx]`, `model 'xxx' is not supported`, `model 'xxx' not found or not supported`
- Behavior: The request fails immediately before generation starts.
- Context: Occurs when passing large codebases or long chat histories, or when specifying a model name that is not included in the current subscription plan.

**Root Cause**
- The input prompt exceeds the maximum context window allowed by the model.
- The requested model name is misspelled, has incorrect capitalization, or is not supported by the specific plan (Coding Plan or Token Plan).

**Solution**
1. To fix context length errors, create a new session, simplify the input, or switch to a model with a larger context window.
2. To fix model support errors, verify the exact model name. Ensure it is case-sensitive and matches the list provided in the Coding Plan or Token Plan overview documentation.

**Verification**
- Send a request with a shorter prompt or the corrected model name. A successful generation response confirms the fix.

### Problem 4: Base URL and Routing Errors

**Symptoms**
- Error message: `404 status code (no body)`, `Connection error`, `Failed to discover Alibaba Cloud models: TimeoutError: The operation was aborted due to timeout`, `auth.profiles.xxx: Invalid input`
- Behavior: The IDE cannot fetch the model list, or requests return 404 Not Found.
- Context: Common when configuring OpenClaw, Claude Code, or modifying local authentication profiles.

**Root Cause**
- Using an incorrect Base URL path (e.g., using `/v1` instead of `/apps/anthropic` for Claude Code).
- Misspelled Base URL domain or local network connectivity issues.
- Corrupted or incorrectly modified local OpenClaw configuration files.

**Solution**
1. For Claude Code, update the Base URL to use the correct path:
   - China: `https://coding.dashscope.aliyuncs.com/apps/anthropic`
   - Global: `https://coding-intl.dashscope.aliyuncs.com/apps/anthropic`
2. If you encounter OpenClaw timeout errors (`Failed to discover Alibaba Cloud models`), this does not affect normal use. You can ignore it or remove the `alibaba-cloud:default` profile.
3. If you see `auth.profiles.xxx: Invalid input`, fix the configuration by removing invalid fields and ensuring the API key is set in `models.providers.bailian.apiKey`.
4. If the gateway is stuck, clear the local agent configs and restart:
   ```bash
   rm ~/.openclaw/agents/main/agent/auth.json
   rm ~/.openclaw/agents/main/agent/models.json
   openclaw gateway restart
   ```

**Verification**
- The IDE successfully fetches the model list, and API requests return valid responses without 404 or timeout errors.

## FAQ

**Q: Does the Coding Plan switch to pay-as-you-go if I exceed my quota?**
A: No. After quota exhaustion, further API calls will fail. The Coding Plan does not automatically switch to pay-as-you-go billing. You must wait for the quota to reset.

**Q: How are credits deducted in the Token Plan (Team Edition)?**
A: Credits are first deducted from the individual seat quota, and then from the shared quota pack. Unused quota does not carry over to the next month, and the subscription is non-refundable.

**Q: Why am I getting a "Coding Plan is currently only available for Coding Agents" error?**
A: This occurs when an API call is made from an unsupported tool or environment. The Coding Plan can only be used with supported programming tools like Claude Code or Qwen Code.

**Q: How can I reduce model hallucination in Alibaba Cloud Model Studio?**
A: You can reduce hallucination by using Retrieval-Augmented Generation (RAG), fine-tuning the model with high-quality data, and adjusting model parameters like temperature and top_p to make the output more deterministic.

**Q: What should I do if I get a "Missing parameters" (Error 100004) in Model Studio?**
A: This indicates that a required parameter is missing. Verify that all required parameters (such as AppId, Prompt, User, and Bot) are included in your request and that their formats are correct.

## Source Documents

- FAQ_6413436.xdita
- FAQ_4546135.xdita
- FAQ_6522328.xdita