MiniMax api: Quickstart and SDK Guide
This guide helps you integrate our uncensored LLM API into your application using standard OpenAI-compatible clients. You can start generating text immediately by swapping your base URL and API key.
Authentication and Base URL
Use the provided API key and point your client to the dedicated base URL. The endpoint for generating responses is https://api.minimaxaiapi.com/v1/chat/completions. You pass the key in the Authorization header as a bearer token. This works with any standard OpenAI SDK because we follow the same protocol.
- Header name:
Authorization - Header value:
Bearer YOUR_API_KEY - Base URL:
https://api.minimaxaiapi.com/v1
No complex setup is required. Just update the configuration in your existing project.
curl https://api.minimaxaiapi.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "return json with keys name and age"}]
}'
Chat Completions Endpoint
Send a POST request to the chat completions endpoint to get a text response. The model identifier is uncensored. You must include a messages array with your conversation history. The system processes the input and returns generated text based on your prompt.
This endpoint handles all text generation. It does not support embeddings, audio, or video. You can stream responses or wait for the full block. The model handles context up to 100,000 tokens total.
from openai import OpenAI
client = OpenAI(base_url="https://api.minimaxaiapi.com/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)
Streaming and Token Usage
Enable streaming by setting stream: true in your request. The API returns Server-Sent Events (SSE) for each token generated. This allows for real-time display of the output. Token usage statistics are included in the final chunk of the stream. This helps you track costs accurately without parsing every individual token.
Streaming reduces perceived latency for long responses. It is ideal for chat interfaces and dynamic content generation. You can stop the stream early if the user interrupts the generation.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.minimaxaiapi.com/v1", apiKey: process.env.API_KEY });
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);
Function Calling and JSON Mode
Use the tools parameter to enable function calling. Define your functions in the request body and let the model choose which to call. The tool_choice parameter lets you force a specific function or auto-select. For strict JSON output, set response_format to {"type": "json_object"}. This ensures the response is valid JSON.
Function calling is useful for extracting structured data or triggering actions. JSON mode is perfect for API integrations requiring predictable formats. Combine both for robust application logic.
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Tell the story in second person."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
Model Parameters and Constraints
Adjust generation behavior using standard parameters like temperature, top_p, and stop. The maximum context window is 100,000 tokens including the prompt and completion. The maximum output per request is 16,000 tokens. If you do not set max_tokens, the limit defaults to 2,048 tokens.
Use seed for reproducible results. Set presence_penalty and frequency_penalty to control repetition. These parameters give you fine-grained control over the model's creativity and consistency. Always test with your specific use case to find the right balance.
Rate Limits and Errors
The API enforces a limit of 300 requests per minute and 8 concurrent requests per key. If you exceed these limits, you will receive a 429 error. A 401 error indicates an invalid or missing API key. A 402 error means your prepaid credit is exhausted.
Errors do not consume your credit. You can retry failed requests without penalty. The request body size is limited to 8 MB. Manage your concurrency carefully to avoid throttling. Monitor your usage through the final chunk of streaming responses.
Frequently asked questions
What is the minimax AI API base URL?
The base URL is HTTPS://api.minimaxaiapi.com/v1. Use this endpoint with any OpenAI-compatible client to send requests.
How do I get an API key?
Sign up using Google or email and password on the Get API key page. Your key is shown immediately after creation. No phone number is required.
What happens if I run out of credit?
You receive a 402 error. Your prepaid credit never expires. You can top up with crypto to continue using the service without losing your existing balance.
Generate your key now
Register, retrieve your key, and update your endpoint URL. That is all you need to do.