Beginner Q&A: what is the difference between 401 and 403, and which one does a new key fix?
401 means the request lacks valid authentication credentials, and the right key usually fixes it. 403 means the credentials are valid but lack permission, and re-authenticating changes nothing. Telling them apart stops you from swapping keys against a 403 or hunting permissions for a 401.
Short answer
- 401 Unauthorized: the request lacks valid authentication credentials. The server usually sends a
WWW-Authenticateheader naming the expected scheme, such asBearer.1 - 403 Forbidden: the server understood the request but refused to process it. Unlike 401, authenticating or re-authenticating makes no difference; the failure is tied to application logic such as insufficient permission for a resource or action. Repeating the unchanged request should be expected to fail again.2
In one sentence: 401 is "I don't recognize you"; 403 is "I know who you are, but you can't do this." A new key usually fixes a 401; a 403 calls for checking permissions, groups and model availability.
Q1: Common causes of 401
- The key is not sent: the environment variable is not loaded, the name is misspelled, or code reads a different variable.
- Wrong format: it should be
Authorization: Bearer <Key>; common mistakes are a missingBearer, extra quotes, or stray newlines or spaces.
- The key is no longer valid: deleted, disabled, expired, or truncated when copied.
- Key and service mismatch: a key for service A sent to service B's address. A gateway key works only with that gateway's
base_url.
SalpX docs specify Authorization: Bearer <API Key> with Base URL https://www.salpx.com/v1.3
Q2: Common causes of 403
- The account or token lacks permission for the model: for example the token is restricted to certain models or groups and you requested one outside that scope.
- Region or policy restrictions: the provider refuses some requests by region or compliance policy.
- IP allowlists or token limits: the token allows certain IPs and the request came from elsewhere.
- The resource is not yours: you accessed someone else's task ID or file ID.
MDN also notes that servers sometimes send 404 instead of 403 to avoid revealing a resource's existence to unauthorized clients.2 So an "it exists but returns 404" case can be investigated as a permission issue too.
Q3: The fastest way to investigate
- Read the full error body: not just the status, but
error.message,error.codeand the request ID. Many services state the reason in the message.
- Validate the key with a minimal request: call an endpoint that does not involve specific model permissions, such as listing models. If that returns 401, the key is the problem; if listing succeeds but a specific model returns 403, the permission scope is.
- Print the outgoing headers, redacted: confirm
Authorizationappears once, starts withBearerand the key length is right. Never log the full key.
- Check base_url: confirm the key and the request address belong to the same service.
Q4: Should they be retried automatically?
- 401: do not retry the same request. A wrong key stays wrong, and retries may trigger risk controls.
- 403: MDN states that repeating the unchanged request should be expected to fail.2 Do not retry either.
Both should stop the program immediately and prompt a human check rather than enter a retry loop.
Quick reference
- Fixed by a new key → most likely a 401-type issue.
- Same after a new key → most likely a 403-type issue: check permissions, groups, model scope and IP limits.
- An HTML page instead of JSON → possibly intercepted by an intermediate proxy; first find which hop responded.
In one line
401 means check credentials; 403 means check permissions. Use a minimal request like listing models to tell which one you have, then fix accordingly instead of swapping keys against a 403.
Sources & attribution
This article references the public materials listed below. Analysis and wording are SalpX's own; quoted material remains the property of its original authors and publishers.
- 401 Unauthorized - HTTP — MDN Web Docs · accessed 2026-11-28Note:MDN: 401 means valid authentication credentials are missing; 403 is for valid credentials without permission.
- 403 Forbidden - HTTP — MDN Web Docs · accessed 2026-11-28Note:MDN: re-authenticating makes no difference for 403, and repeating the unchanged request should be expected to fail again.
- SalpX API Reference — SalpX · accessed 2026-11-28Note:SalpX official docs: Base URL, Bearer auth, image size tiers, 4K model names, the clamp response header, and integration notes such as a 300s+ timeout, a 10 MB response budget and publicly downloadable reference images.
One key for Claude, GPT and 50+ models
The SalpX gateway is OpenAI-SDK compatible. Point base_url at https://www.salpx.com/v1 and you are done.