MiniMax API, explained for developers
Integrating the MiniMax API often fails due to simple configuration errors rather than complex infrastructure issues. This guide walks through nine common mistakes developers make when switching from standard OpenAI clients to our uncensored endpoint, ensuring your integration works correctly from day one.

Updated
Key points
Verify your context window calculations to prevent silent truncation of long conversations.
Use the correct streaming syntax, as default SDK settings often disable token-by-token updates.
Track token usage in loops explicitly, as our billing reflects actual input/output consumption.
Adjust function calling schemas to match our specific model requirements for tool usage.
Mistake 1: Ignoring Context Window Limits
Many developers assume the context window is infinite or larger than it actually is. Our model supports a total context window of 100,000 tokens, which includes both the prompt and the completion. If you exceed this limit, the API will either truncate your input or return an error, depending on your configuration. This is particularly problematic for applications that maintain long-term memory or process large documents. To avoid this, calculate the token count of your system prompt, conversation history, and the expected output before sending the request. Remember that there is no separate output cap, and if you do not specify max_tokens the response can run to the end of the window. Keeping your usage within these bounds ensures consistent performance and prevents unexpected billing surprises due to hidden token consumption.
Mistake 2: Misconfiguring Streaming Responses
Streaming is essential for a good user experience, but it is often misconfigured. To enable streaming, you must explicitly set stream: true in your request. Without this flag, the API waits for the entire completion before returning a response, which can lead to high latency for long outputs. When streaming is enabled, you receive a series of Server-Sent Events (SSE). Each chunk contains a portion of the text, and the final chunk includes the token usage statistics. Make sure your client code correctly handles these incremental updates. If you are using a standard OpenAI SDK, ensure you are iterating over the stream object correctly. Misconfiguring the stream handler can result in lost tokens or incomplete responses, frustrating your end users.
Mistake 3: Overlooking Token Costs in Loops
Billing is based on real token usage, not just the number of API calls. If you are running loops that send multiple requests per user action, you must account for the cumulative token cost. For example, a simple chat interface might send the entire conversation history with each new message. As the history grows, the input token count increases, leading to higher costs per turn. Our pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens. Errors and refusals are free, but successful completions are charged. To optimize costs, consider pruning old messages from the context window or summarizing previous turns. Always monitor your token usage to ensure your prepaid credit is being used efficiently.
Mistake 4: Incorrect Function Calling Syntax
Function calling allows your model to interact with external tools, but the syntax can be tricky. You must define your tools in the tools parameter and specify tool_choice to control how the model uses them. The model returns a list of tool calls, which you must then execute and feed back into the conversation. A common mistake is passing the tool definition incorrectly or failing to handle the tool_calls object in the response. Ensure your schema matches the expected format exactly. If the model fails to call a tool correctly, it may return invalid JSON, breaking your application flow. Test your function calling logic thoroughly with various inputs to ensure robustness.
Mistake 5: Assuming Standard OpenAI Defaults
While our API is OpenAI-compatible, it is not identical. Default parameters like temperature and top_p may behave differently depending on the underlying model. For instance, our uncensored model might respond differently to low temperature values compared to GPT-4. Always review the default behavior of your client library and adjust parameters as needed. Our model supports temperature, top_p, stop, seed, presence_penalty, and frequency_penalty. Experiment with these values to find the right balance between creativity and accuracy for your specific use case. Do not assume that settings that work perfectly for OpenAI will yield identical results here.
Mistake 6: Not Handling API Rate Limits
Rate limits are in place to ensure stability. Our API allows 300 requests per minute per key and 8 concurrent requests at the same time. If you exceed these limits, you will receive a 429 error. To handle this, implement exponential backoff in your client code. Retry requests after a short delay, increasing the delay with each failure. Also, be aware that the request body size is limited to 8 MB. If you are sending large files or extensive context, ensure you stay within this limit. Monitoring your usage and adjusting your request frequency can help you avoid hitting these limits during peak usage times.
Mistake 7: Forgetting to Set JSON Mode
If your application requires structured output, you must explicitly enable JSON mode by setting response_format to {"type": "json_object"}. Without this setting, the model may return text that looks like JSON but is not strictly valid, causing parsing errors in your code. JSON mode ensures that the output is well-formed and can be directly parsed by your application. This is particularly useful for applications that rely on specific data structures, such as forms or configuration files. Always validate the JSON output before using it to ensure it meets your requirements. If the model fails to produce valid JSON, handle the error gracefully and retry or prompt the user.
Mistake 8: Misunderstanding Prepaid Billing
Our billing model is straightforward: you pay for what you use, and your prepaid credit never expires. There are no monthly fees or subscriptions. You can top up with crypto (USDT on TRC20 or USDC on Base) in amounts from $20 to $500. Bonus credit is available for larger top-ups: +5% for $50, +10% for $100, and +15% for $200. Errors and refusals do not consume your credit. However, successful completions are charged based on token usage. Make sure you understand this model to avoid unexpected charges. If you make a mistake, such as a double charge, contact support through the Support page. Your credit is safe and will remain available until you use it.
Mistake 9: Overlooking Content Moderation Nuances
While our model is uncensored, it is not entirely without limits. The hard content limit that always applies is no sexual content involving minors. Requests of this kind will be refused. Other adult, fictional, or controversial topics are generally allowed. However, the model may still refuse content that is extremely explicit or violates specific legal standards. It is important to test your specific use case to understand where the boundaries lie. If you are building an application for a general audience, consider implementing your own moderation layer on top of our API. This ensures that your application meets the expectations of your users and complies with relevant regulations.
More guides
Questions and answers
How do I get started with the MiniMax NSFW API?
Sign up on the 'Get API key' page using Google or email. You will receive a key immediately. Then, update your client's base URL to https://api.minimaxnsfw.cc/v1 and set your API key. You can start sending requests to the /v1/chat/completions endpoint right away.
Is there a free trial available?
Yes, new users get $0.50 of trial credit valid for 7 days, one per person. Claim this credit with one click on your API key page. No card is needed. This allows you to test the API and verify your integration before purchasing prepaid credit.
What happens if I exceed the rate limits?
You will receive a 429 Too Many Requests error. Implement exponential backoff in your client code to retry requests after a short delay. The limits are 300 requests per minute and 8 concurrent requests per key.
Can I use this API with the official OpenAI SDK?
Yes, our API is OpenAI-compatible. You can use the official SDK by changing the base URL to https://api.minimaxnsfw.cc/v1 and providing your API key. Ensure you set the model ID to 'uncensored'.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.