Authentication
Learn how to authenticate your API requests to Konnect.ai.
API Keys
The Konnect.ai API uses API keys for authentication. All API requests must include your API key in the Authorization header.
Authorization: Bearer sk_live_your_api_key_hereGenerating API Keys
To generate an API key:
- 1Navigate to your Dashboard Settings
- 2Click on the "API Keys" section
- 3Click "Create new secret key"
- 4Give your key a name and click "Create"
- 5Copy your key immediately - it won't be shown again
Key Types
sk_live_*ProductionLive API keys for production use. Requests count against your usage quota and are billed accordingly.
sk_test_*TestingTest API keys for development. Requests are limited and return mock responses.
Security Best Practices
Never expose keys in client-side code
API keys should only be used in server-side code. Never include them in JavaScript that runs in the browser.
Use environment variables
Store your API keys in environment variables, not in your source code.
Rotate keys regularly
Create new keys periodically and revoke old ones to minimize risk.
Use separate keys per environment
Create different keys for development, staging, and production.
Keep your API keys secure
If you believe an API key has been compromised, revoke it immediately from your dashboard and create a new one. Konnect.ai is not responsible for unauthorized usage of exposed keys.
Example Usage
cURL
curl https://api.konnect.ai/v1/chat \
-H "Authorization: Bearer $KONNECT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "Hello"}'Node.js
const response = await fetch('https://api.konnect.ai/v1/chat', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.KONNECT_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ message: 'Hello' }),
});Python
import os
import requests
response = requests.post(
'https://api.konnect.ai/v1/chat',
headers={
'Authorization': f'Bearer {os.environ["KONNECT_API_KEY"]}',
'Content-Type': 'application/json',
},
json={'message': 'Hello'}
)