Get API Key
Generate and manage API keys for authenticating with Cyborg services.
What are API Keys?
API keys are the primary authentication mechanism for ChatSDK, connecting your React SDK to backend services. They provide:
- Authentication: Verify the identity of your client application
- Authorization: Control access to resources and features
- Rate Limiting: Enforce usage quotas per project
- Usage Tracking: Monitor and attribute API usage and costs
- Environment Separation: Distinguish between test and production environments
Key Format
Format: chatsdk_{environment}_{secret}
Examples:
- chatsdk_live_ak1nDk3jF9sL2mP0qR8tU7vW5xY6zB4cE3fG2hI1jK0
- chatsdk_test_pQ9rS8tU7vW6xY5zB4cE3fG2hI1jK0mN1oP2qR3sT4uGenerating API Keys
- Log into the Cyborg Admin UI
- Navigate to the API Keys section
- Click "Generate New Key"
- Choose your environment:
- Test: For development and testing
- Live: For production use
- Copy your key immediately (it won't be shown again)
- Store it securely (use environment variables)
Using Your API Key
In React Applications
tsx
import { ChatProvider } from '@cyborg-sdk/react'
function App() {
return (
<ChatProvider apiKey={process.env.REACT_APP_CYBORG_API_KEY}>
{/* Your app */}
</ChatProvider>
)
}Environment Variables
Never commit API keys to version control. Use environment variables:
bash
# .env.local
REACT_APP_CYBORG_API_KEY=chatsdk_live_your_key_hereSecurity Best Practices
- ✅ Store keys in environment variables
- ✅ Never commit keys to version control
- ✅ Use test keys for development
- ✅ Rotate keys regularly
- ✅ Revoke compromised keys immediately
- ❌ Never expose keys in client-side code
- ❌ Don't share keys between projects
- ❌ Don't use production keys for testing
Key Management
Revoking Keys
If a key is compromised:
- Go to API Keys in Admin UI
- Find the compromised key
- Click "Revoke"
- Generate a new key
- Update your application
Monitoring Usage
Track API usage per key:
- Request counts
- Rate limit hits
- Error rates
- Cost attribution
For more details, see the Admin UI API Keys Documentation.