API Key Authentication
AGCloud API uses Bearer token authentication. All API requests must include your API key in the Authorization header.Get Your API Key
- Sign up for a AGCloud account at Dashboard
- Navigate to the API Keys section in your Dashboard
- Generate a new API key
- Copy and securely store your API key
Making Authenticated Requests
Include your API key in theAuthorization header with the Bearer prefix:
Envitonment Variables
Recommended Setup
Store yourAPI key in environment variables instead of hardcoding it:
Using .env Files
For local development, use a.env file:
Important! Remember add
.env to your .gitignore file to prevent accidentally committing secrets.Authentication Errors
Common Error Responses(Claude Code)
The request body is malformed or contains invalid parameters. Common causes include: missing required fields (e.g.
model, messages, max_tokens), incorrect data types, invalid JSON syntax, or unsupported parameter values. Please review your request payload and ensure it conforms to the API specification.Authentication failed. This typically occurs when the API key is missing from the
Authorization header, the key format is incorrect, or the key has been revoked or expired. Ensure your request includes a valid API key in the header as Authorization: <YOUR_API_KEY>.Your account balance is not enough to process this request. API calls are charged based on token usage, and your current balance cannot cover the cost. Please top up your account at the Dashboard before continuing to use the service.
Your account has exceeded its allocated usage quota. This may be a daily, monthly, or total usage limit depending on your plan. Please check your current quota and usage in the Dashboard, or contact support to upgrade your plan.
Too many requests in a short period of time. The API enforces rate limits to ensure fair usage and service stability. Please wait a moment and retry your request. We recommend implementing exponential backoff in your client to handle rate limiting gracefully.
The server encountered an unexpected condition that prevented it from fulfilling the request. Please try again later or contact support if the problem persists.
Best Practices
Use Environment Variables
Use Environment Variables
Always store API keys in environment variables, never in your source code
implement-key-rotation
implement-key-rotation
Regularly rotate your API keys to minimize security risks. Generate new keys and update your applications before revoking old ones.
Use Different Keys for Different Environments
Use Different Keys for Different Environments
Use sepatate API Keys for development, staging, and production environments.
Monitor API KeyUsage
Monitor API KeyUsage
Regularly check your API usage in dashboard to detect any on rasks.
Implement Rate Limiting
Implement Rate Limiting
Implement client-side rate limiting to avoid hitting API rate limits
API Key Management
Generating New Keys
- Log in to your Dashboard
- Navigate to API Keys
- Click Generate New Key
- Give your key a descriptive name
- Copy the key immediately (you won’t be able to see it again)
Revoking Your API Keys
If you suspect your API key has been compromised:- Go to your Dashboard
- Find the compromised key in the API Keys section
- Click Revoke
- Generate a new key and update your applications
Customer Support
If you’re experiencing authentication issues:- Check that your API key is correctly formatted
- Verify your key hasn’t been revoked
- Ensure you’re using the correct API endpoint
- Contact [info@thousandcloud.com]for help