API Key and Authentication Issues
Troubleshoot ApiSmart API Key authentication errors, invalid credentials, model access issues, and common authorization problems.
ApiSmart uses API Keys to authenticate API requests.
If a request returns 401 or 403, check your API Key, authorization header, and model access before retrying.
🔑 Check Your Authorization Header
Include your API Key in every authenticated request:
Authorization: Bearer <your-api-key>Example:
curl https://gw.apismart.ai/v1/models \
-H "Authorization: Bearer <your-api-key>"Make sure that:
Beareris includedThere is one space between
Bearerand the API KeyThe API Key is complete
No extra quotes or spaces were copied into the key
401 — Invalid API Key
If the API returns:
401 invalid_api_keythe API Key could not be authenticated.
Check that you are using the correct API Key and that your application is sending it in the Authorization header.
If necessary, create or manage your credentials from the ApiSmart Console.
For API Key management, see Create and Manage API Keys.
403 — Model Access Issues
A 403 response does not always mean that your API Key itself is invalid.
For example:
means the API Key was authenticated, but the selected model is not currently available to your account.
Other model-related 403 errors can include:
model_not_image_capable— The model cannot be used with the Image Generation APImodel_not_video_capable— The model cannot be used with the Video Generation APIAccessDenied— Access to the requested model or operation was denied
Choose a supported model or contact ApiSmart Support if you need access.
🧩 Verify the Model ID
You can retrieve the current model list with:
Use the returned data[].id value exactly as provided.
Model IDs are matched exactly, including periods, hyphens, and version numbers. An incorrectly written model ID can result in an unexpected 503, so check the model ID carefully before assuming the issue is authentication-related.
🔒 Keep Your API Key Secure
Do not:
Expose API Keys in frontend code
Commit API Keys to public repositories
Include full API Keys in screenshots or logs
Send your full API Key to support
Store API Keys in environment variables or another secure secrets-management system.
For security recommendations, see Secure Your API Keys.
✅ Quick Troubleshooting Checklist
If authentication fails, verify:
The API Key is correct
The header uses
Authorization: Bearer <your-api-key>The requested model ID is correct
The model is available to your API Key
The selected model supports the API endpoint
For other errors, see HTTP Status Codes and API Errors.
➡️ Next Steps
最後更新於
這有幫助嗎?