Quick Start
Get started with the AimiChat API in minutes. Generate an API key from your account settings and start making requests.
API Keys
Generate and manage your API keys from your account settings. Each key uses your daily credit allotment and supports basic chat (talk mode) only.
Authentication
All API requests require authentication using your API key. You can provide your API key in three ways:
Authorization Header
Authorization: Bearer aimichat_your_api_key_here
X-API-Key Header
X-API-Key: aimichat_your_api_key_here
Query Parameter
?api_key=aimichat_your_api_key_here
Rate Limits
API requests count against your monthly credit limit based on your subscription tier. All API keys from the same account share the same quota.
Rate Limit Headers
Rate limit information is included in response headers:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 75
X-RateLimit-Reset: 2024-01-19T00:00:00Z
Endpoints
https://aimichat.app/v1/chat/completions
Send a chat message and receive an AI response. Supports both streaming and non-streaming modes.
Request Body
messagesrole and contentstreammax_tokenstemperatureExample Request
curl -X POST https://aimichat.app/v1/chat/completions \
-H "Authorization: Bearer aimichat_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "Hello, how are you?"}
],
"max_tokens": 500,
"temperature": 0.7
}'
Example Response
{
"model": "aimichat-1",
"choices": [
{
"message": {
"role": "assistant",
"content": "Hello! I'm doing well, thank you for asking..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 45,
"total_tokens": 57
}
}
Streaming Response
When stream: true, responses are sent as Server-Sent Events (SSE):
data: {"choices":[{"delta":{"content":"Hello"}}]}
data: {"choices":[{"delta":{"content":"!"}}]}
data: [DONE]
Error Responses
The API uses standard HTTP status codes to indicate success or failure.
Example Error Response
{
"error": "Rate limit exceeded",
"message": "Daily credit limit reached",
"limit": 100,
"used": 100,
"resetAt": "2024-01-19T00:00:00Z"
}
Code Examples
Get started quickly with these code examples in popular programming languages.
import requests
api_key = "aimichat_your_api_key_here"
url = "https://aimichat.app/v1/chat/completions"
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
}
data = {
"messages": [
{"role": "user", "content": "What is the capital of France?"}
],
"max_tokens": 100
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const fetch = require('node-fetch');
const apiKey = 'aimichat_your_api_key_here';
const url = 'https://aimichat.app/v1/chat/completions';
const data = {
messages: [
{ role: 'user', content: 'What is the capital of France?' }
],
max_tokens: 100
};
fetch(url, {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(res => res.json())
.then(data => console.log(data));
curl -X POST https://aimichat.app/v1/chat/completions \
-H "Authorization: Bearer aimichat_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "What is the capital of France?"}
],
"max_tokens": 100
}'
Best Practices
Secure Your Keys
Never commit API keys to version control. Use environment variables to store them securely.
Error Handling
Implement proper error handling for rate limits and API errors to ensure reliability.
Monitor Usage
Track your API usage to avoid hitting daily limits and optimize your credit consumption.
Rotate Keys
Revoke and regenerate keys immediately if they are compromised or exposed.
Need Help?
Our team is here to help you integrate AimiChat into your applications.