Introduction
Learn how to use the ChatofAI API
Authentication
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:
Example curl command:
Example with python
Return
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:
This structure allows the client to easily understand the status of the request and handle the returned data appropriately.