How to Integrate AI Chat Using the API
Step-by-step guide to integrate AI chat functionality into your application using our API with proper authentication.
Integration Steps
Step 1: Obtain Your API Key
Get your authentication credentials from your project dashboard.
- Navigate to your AI Chat project dashboard
- Go to the 'API Keys' section in your project settings
- Generate a new API key for your project
- Copy and securely store your API key
Step 2: Set Up Authentication Headers
Configure your HTTP requests with proper authentication headers.
- Add the 'Authorization' header to all API requests
- Use the format: 'Authorization: Bearer YOUR_API_KEY'
- Replace 'YOUR_API_KEY' with your actual API key from Step 1
- Ensure the API key is kept secure and not exposed in client-side code
Step 3: Make Your First API Call
Send a test message to verify your authentication setup.
- Use the '/newUserMessage' endpoint for sending chat messages
- Include required parameters: user_message, chat_id (or consumer_id for new chats)
- Send a POST request with your authentication header
- Verify you receive a successful response with assistant_response
Quick Start Example
A simple example of making an authenticated API call:
curl -X POST "https://your-api-endpoint.com/newUserMessage" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_message": "Hello, how can you help me?",
"chat_id": "",
"consumer_id": "user123"
}'
Important Security Notes
- Never expose your API key in client-side code or public repositories
- Use environment variables or secure configuration for API key storage
- Regenerate API keys if you suspect they have been compromised
- Each API key is tied to a specific username and project
- API keys provide full access to your chat service - treat them like passwords
Next Steps
After completing these steps, you can:
- Explore the detailed API reference
- Implement conversation management using chat_id
- Add consumer_id for user-specific chat tracking