API Documentation

Build with AimiChat

Integrate powerful AI capabilities into your applications with our simple REST API. Secure, scalable, and easy to use.

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:

Recommended

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.

Free
500 credits/month
1 credit per request
~500 requests/month
Ultra
10,000 credits/month
0.5-3 credits per request
~3,300-20,000 requests/month

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

POST https://aimichat.app/v1/chat/completions

Send a chat message and receive an AI response. Supports both streaming and non-streaming modes.

Request Body

Parameter
Type
Required
Description
messages
array
Required
Array of message objects with role and content
stream
boolean
Optional
Enable streaming responses (default: false)
max_tokens
integer
Optional
Maximum tokens in response (max: 2000)
temperature
float
Optional
Sampling temperature 0-1 (default: 0.7)

Example 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.

400
Bad Request
Invalid request body or parameters
401
Unauthorized
Invalid or missing API key
429
Rate Limit Exceeded
Daily credit limit reached
500
Internal Server Error
Something went wrong on our end

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.

Python
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())
JavaScript (Node.js)
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
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.