API Conventions
A summary of common rules for calling the MaiAgent platform API, including URLs and version prefixes, API Key authentication, rate limits, error responses, pagination, field formats, and upload size l
The API Conventions page in the API documentation is the authoritative source for rules shared across API endpoints. Refer to that page when building integrations. This page provides only a one- or two-sentence summary of each section, with a link to the corresponding section in the API documentation.
Base URL and Version Prefix
The SaaS API URL is https://api.maiagent.ai/api/v1/. For on-premises and private cloud deployments, replace the domain with your company's platform domain. Always use /api/v1/ for new integrations. See API Conventions: Base URL and Version Prefix.
Authentication
For server-to-server calls, include Api-Key <key> in the Authorization header. Each key is tied to a member and has the permissions of that member's role. For conditions that invalidate keys, authentication failure responses, and recommendations for integration keys, see API Conventions: Authentication.
Each member can hold multiple active keys at the same time, with no limit on the number of keys (see API Key Management in the user manual). Keys can also be issued through the API: administrators can issue keys on behalf of members using POST /api/v1/organizations/{organizationPk}/api-keys/ (requires the “API Key Management” permission and supports setting a name, expiration time, and RPM), while members can create their own using POST /api/v1/organizations/{organizationPk}/my-api-keys/. Revoke keys using the corresponding DELETE endpoint. The full key appears only once, in the creation response. For fields, see Organizations and Members in the API documentation.
Rate Limits
The platform API has no default global limit. The main limits are RPM per API Key and TPM for AI Gateway. Exceeding a limit returns 429 with Retry-After. For the full scope of rate limiting, see API Conventions: Rate Limits.
Error Responses
Identify errors using the HTTP status code and code; do not match the text in detail. For the error response structure, recommended handling for each status code, and cases that return 402, see API Conventions: Error Responses.
Pagination
Most lists use page-based pagination with page and page_size (default 20, maximum 100). Use next to retrieve the next page. Conversation and message lists use cursor-based pagination. See API Conventions: Pagination.
Field Formats
Response keys always use camelCase. Time fields are typically millisecond timestamp strings. See API Conventions: Field Formats.
Upload Size Limits
The response from GET /api/v1/allowed-file-specs/ is the authoritative source for upload limits. For current limits by use case, see API Conventions: Upload Size Limits. For the presigned upload flow, see Presigned File Upload Mode.
Request Content Encoding
All request and response JSON uses UTF-8. Fields such as role instructions (instructions) and message content can contain Chinese and other Unicode characters directly, without conversion to ASCII or escaping. Include Content-Type: application/json in the request and ensure that your HTTP client sends it using UTF-8 encoding. Response JSON also returns UTF-8 characters directly, without converting them to \uXXXX. After an update, use the corresponding GET endpoint to read back and verify the stored content. The admin interface displays the same data.
Request Size and 413
The platform API itself does not return
413. A JSON request body exceeding Django's default limit (2.5 MB) returns400. This limit counts only JSON and form fields, excluding multipart file bodies.File size limits are determined by
GET /api/v1/allowed-file-specs/. Exceeding a limit returns400when obtaining an upload URL or registering a file. See Upload Size Limits.Receiving
413means that the proxy layer in front of the platform (CDN or load balancer) blocked the entire request. This usually occurs when files are embedded in JSON as Base64 or large files are sent directly via multipart. Switch to Presigned File Upload Mode: upload the file directly to storage and include only the file's key in the API request.
Frequently Asked Questions
For keys that keep returning 401, whether a key's call scope can be restricted, and the difference between /api/ and /api/v1/, see API Conventions: Frequently Asked Questions.
Last updated
Was this helpful?