APIHub
Back to Help Center

错误排查

What to do when APIHub API returns errors 401, 404, 429? Troubleshooting order and solutions

Updated 10/30/2026, 22:36:43

When calling APIHub, for 401, check the API Key and authentication header first; for 404, check the interface path and model ID first; for 429, check the request frequency and concurrency first. Do not directly repeat the same request for all errors; read the error message in the response first, then handle it according to the cause.

Status Code Quick Reference Table

Status CodePriority check based on APIHub documentationSuggested handling
401Key is invalid, disabled, or expiredVerify the Key and authentication method, replace with a valid Key if necessary
402Insufficient balance or Key quota limitCheck account balance and Key quota
403Model access permissionCheck the Key's model whitelist and the selected model
404Path error, model does not exist, or not enabledVerify Base URL, endpoint, and model ID
429Request frequency or concurrency limitReduce concurrency, delay retry according to response prompt
500 / 502Gateway or upstream exceptionSave error information, limited retry or contact support if necessary

Upstream or clients may also produce the same status codes. Final diagnosis must be combined with the response body; the cause cannot be determined solely by the status code.

401: Confirm the correct Key is used

First, confirm that the Key entered is the one created in the APIHub console, not a Key from another service. Check if extra spaces or line breaks were added during copying, and confirm the Key has not been disabled, revoked, or set to expire.

OpenAI-compatible requests use Authorization: Bearer ...; Anthropic requests use x-api-key according to the documentation. If the client automatically adds the prefix, avoid manually adding Bearer again.

Do not send your Key to public groups for help. If it has been leaked, revoke it first, then create a new Key.

404: Distinguish between path errors and model errors

First, check the final URL. For example, the full path for Chat Completions should be https://api.apihub.ltd/v1/chat/completions, and the full path for Messages should be https://api.apihub.ltd/v1/messages.

If the path is correct, copy the model ID from the Model Pricing Page, and check the spelling, hyphens, and whether the model supports the current interface. The displayed model name is not necessarily equal to the model ID in the request.

429: Avoid immediate infinite retries

If the response includes Retry-After, prioritize following that prompt; otherwise, use an exponential backoff retry with a limit, and add random delays to avoid a large number of clients retrying simultaneously. The number of retries must be limited, while reducing request frequency or concurrency.

For example, you can start with a shorter wait and gradually increase the wait time after failures; the specific interval and number of retries depend on the business timeout budget and service limits, and the example interval should not be taken as a fixed rule of APIHub.

Timeout: Confirm if the request has already been executed first

A client timeout does not mean the upstream has not processed the request, nor does it mean no charges have been incurred. For streaming requests that have already started outputting, retrying may generate new results or duplicate business operations. You should record the request ID (if any), the content received, and the time before deciding whether to re-initiate the request.

What to provide when contacting support?

Provide the request time and time zone, client and version, interface path, model ID, HTTP status code, desensitized error body, and request ID (if returned). This information helps distinguish between configuration, permission, rate limiting, and upstream failures.

Submit issues through the Contact Page. For first-time users, you can first check the Integration Documentation, then Register and Create an API Key.

Information verification date: 2026-10-30. Basic source of error codes: APIHub Integration Documentation; retry and troubleshooting steps are general engineering recommendations.