The ChatofAI API uses API keys for authentication. Visit your API keys page to retrieve the API key you'll use in your requests.

Remember that your API key is a secret! Do not share it with others or expose it in any client-side code (browsers, apps). Production requests must be routed through your own backend server where your API key can be securely loaded from an environment variable or key management service.

All API requests should include your API key in an Authorization HTTP header as follows:

Authorization: Bearer CHATOFAI_API_KEY

Example curl command:

curl https://chatof.ai/api/v1/backend\
  -H "Authorization: Bearer $CHATOFAI_API_KEY"

Example with python

import requests
url = "https://chatof.ai/api/v1/backend"
headers = {
    "Authorization": f"Bearer {CHATOFAI_API_KEY}"
resp = requests.get(url, headers=headers)


Normally, we use HTTP status codes to represent whether a request is permitted. When the HTTP status code is 200, it means that the request is legal. We use 'code' to indicate whether the request is successful. Only when 'code' equals 0 does it mean that the request is successful.

HTTP Status

200 This request is valid, we will return a JSON string in the request body. 401 Authentication failed, please check if you have included the API_KEY in the header, or verify if your API_KEY has been deleted by the administrator. 403 You do not have permission to access this interface. 404 The request path was not found, please check if your request path is correct. 500 There is an internal server error while processing the request.

Structure of the returned data

The structure of the returned data typically follows a standard format. Here's an example:

    "code": 0,  # 0 means success, other values indicate different types of errors
    "message": "Success",  # A message describing the result
    "data": {
        # The actual data returned by the API
    "request_id": "892bf29e-07e5-4ac1-8120-040c8268cb5b" # The unique identifier for this request.

This structure allows the client to easily understand the status of the request and handle the returned data appropriately.

Last updated