API Reference
Complete reference for the ConfigureMyAI API endpoints. All endpoints use JSON for request and response bodies.
Base URL
https://configuremyai.com/api/v1
Authentication
All API requests require a valid endpoint token in the Authorization header:
Authorization: Bearer cmai_your_token_here
Chat Completions
Create a chat completion using your configured AI.
Endpoint
POST /api/v1/[endpoint-path]
Headers
| Header | Required | Description |
|---|---|---|
| Content-Type | Yes | Must be application/json |
| Authorization | If required | Bearer token for authentication |
Request Body
{
"messages": [
{
"role": "user",
"content": "Your message here"
}
]
}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| messages | array | Yes | Array of message objects |
| messages[].role | string | Yes | "user" or "assistant" |
| messages[].content | string | Yes | The message text |
Response
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"object": "chat.completion",
"created": 1702483200,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 15,
"completion_tokens": 12,
"total_tokens": 27
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
| id | string | Unique identifier for the completion |
| object | string | Always "chat.completion" |
| created | integer | Unix timestamp |
| model | string | Model used for completion |
| choices | array | Array of completion choices |
| usage | object | Token usage information |
Error Responses
All errors return a JSON object with an error field:
{
"error": {
"message": "Human-readable error description",
"type": "error_type"
}
}
Error Types
| HTTP Code | Type | Description |
|---|---|---|
| 400 | invalid_request_error | Invalid request format or parameters |
| 401 | authentication_error | Invalid or missing authentication token |
| 404 | not_found_error | Endpoint not found or inactive |
| 429 | rate_limit_error | Rate limit exceeded |
| 500 | api_error | Internal server or AI provider error |
Code Examples
cURL
curl -X POST https://configuremyai.com/api/v1/your-endpoint \
-H "Content-Type: application/json" \
-H "Authorization: Bearer cmai_your_token" \
-d '{
"messages": [
{"role": "user", "content": "What can you help me with?"}
]
}'
JavaScript (Fetch)
const response = await fetch('https://configuremyai.com/api/v1/your-endpoint', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer cmai_your_token'
},
body: JSON.stringify({
messages: [
{ role: 'user', content: 'What can you help me with?' }
]
})
});
const data = await response.json();
console.log(data.choices[0].message.content);
Python (requests)
import requests
response = requests.post(
'https://configuremyai.com/api/v1/your-endpoint',
headers={
'Content-Type': 'application/json',
'Authorization': 'Bearer cmai_your_token'
},
json={
'messages': [
{'role': 'user', 'content': 'What can you help me with?'}
]
}
)
data = response.json()
print(data['choices'][0]['message']['content'])
Ruby
require 'net/http'
require 'json'
uri = URI('https://configuremyai.com/api/v1/your-endpoint')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer cmai_your_token'
request.body = {
messages: [
{ role: 'user', content: 'What can you help me with?' }
]
}.to_json
response = http.request(request)
data = JSON.parse(response.body)
puts data['choices'][0]['message']['content']
Rate Limits
Rate limits can be set at two levels:
- Endpoint level: Total requests allowed for all tokens
- Token level: Requests allowed for a specific token
When a rate limit is exceeded, the API returns a 429 status code with a
rate_limit_error type.
Best Practices
-
Handle errors gracefully
Always check for error responses and handle them appropriately. -
Implement retries with backoff
For 429 and 500 errors, implement exponential backoff. -
Store conversation history
Include previous messages for context-aware responses. -
Monitor token usage
Track usage to manage costs and stay within limits.