Getting Started
Register an Account Visit the MaiToken Platform, click the "Register / Log In" button in the top right corner, and follow the prompts to complete account registration.
Obtain an API Key After logging in, go to the API Key page and click create API Keys to generate a new API Key.
Please keep your API Key secure—do not share it with others or hardcode it directly in your source code. It is recommended to store your API Key using environment variables or configuration files.
Token Configuration Under Basic Info, enter a name, select a token group (which determines the available models), and set an expiration time. Next, under Quota Settings, toggle the total/monthly quota limits. Then, under Access Restrictions, specify the allowed models and IP whitelist. Finally, click Submit for the token to take effect securely according to your configured rules.
Make a Request Once your
API Keyand selected model are ready, you can start making API calls. Below is an example usingcurl:
curl -X POST "https://{BASE_URL}/v1" -H "Content-Type: application/json" -H "Authorization: Bearer YOUR_API_KEY" -d '{ "model": "glm-5.2", "messages": [ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Hello, please introduce yourself." } ], "temperature": 1.0, "stream": true}'Related Questions
- How to handle API call errors? When an API call fails, the server returns the corresponding HTTP status code and error message. Common errors include:
401 Unauthorized: Invalid or expired API Key
400 Bad Request: Invalid request parameters
429 Too Many Requests: API rate limit exceeded
500 Internal Server Error: Internal server error
We recommend implementing proper error handling and retry logic, especially for 429 and 500 errors.
See the Full Error Code Reference or Submit a Ticket
- How to optimize API call costs?
Here are some tips to optimize your API call costs:
1. Choose models suited to your task, as pricing varies across models
2. Reduce unnecessary context to lower token consumption
3. Use caching mechanisms to avoid redundant calls
4. Set a reasonable max\_tokens parameter to prevent overly long responses
5. Use smaller models for testing during development
- How to handle long text inputs?
For long texts that exceed a model's context window size, consider the following strategies:
1. Use models with larger context windows such as GLM-4-Long
2. Split the text into chunks for processing and merge the results
3. Use text embedding models for relevance retrieval and keep only the most relevant passages
4. Summarize the text to extract key information before feeding it into the model
