Authentication
Learn how to authenticate with the INK API and manage your API keys securely.
Overview
INK uses API keys to authenticate requests. You can create and manage API keys from your account dashboard.
Getting Your API Key
- Log in to your INK Dashboard
- Navigate to Account Settings
- Click on API Keys
- Generate a new key or copy an existing one
Important: Keep your API keys secret. Never expose them in client-side code or public repositories.
Using Your API Key
Include your API key in the Authorization header of all requests:
curl https://api.inkai.ph/v1/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt": "Your prompt here"}'
OAuth 2.0 Authentication
For user-facing applications, INK supports OAuth 2.0 authentication:
Authorization Flow
- Redirect users to the authorization endpoint
- User grants permission to your application
- Receive an authorization code
- Exchange the code for access tokens
Token Endpoints
| Endpoint | Description |
|----------|-------------|
| /oauth/authorize | Authorization endpoint |
| /oauth/token | Token exchange endpoint |
| /oauth/revoke | Token revocation endpoint |
Best Practices
- Rotate keys regularly - Generate new keys periodically
- Use environment variables - Never hardcode keys in source code
- Limit key permissions - Create keys with minimal required access
- Monitor usage - Check your dashboard for unusual activity
Troubleshooting
Invalid API Key
If you receive a 401 Unauthorized error:
- Verify the key is correctly copied
- Check if the key has been revoked
- Ensure proper header formatting
Rate Limited
If you receive a 429 Too Many Requests error:
- Review your rate limits
- Implement exponential backoff
- Consider upgrading your plan