EN ▾
Get API key

MiniMax API: Integration Guide

The Minimax API offers a distinct path for LLM integration, particularly for multimodal workflows, but its pricing and parameter structures differ significantly from OpenAI. This guide breaks down the technical specifics of Minimax, helping you decide if it fits your architecture or if an uncensored, OpenAI-compatible alternative better suits your needs.

MiniMax API: Integration Guide

Updated

Understanding the Minimax API

The Minimax API provides access to a suite of large language models, including text and image generation capabilities. Unlike unified endpoints that handle multiple modalities, Minimax often separates its models by capability, such as Minimax-01 for text or Minimax's image models. This specialization allows for optimized performance but requires developers to select the correct model endpoint for their use case.

Minimax is known for supporting long context windows, which is critical for applications processing large documents or extended conversational histories. However, the pricing model is token-based, with distinct rates for input and output tokens. Developers must calculate costs carefully, as image generation models often have fixed pricing per image rather than token-based billing.

When comparing Minimax to other providers, note that it does not use the OpenAI chat-completions format natively. If your codebase relies on OpenAI SDKs, you will need an abstraction layer or a compatible API endpoint to integrate Minimax without rewriting your client code. This is where services offering an OpenAI-compatible wrapper become valuable for reducing integration time.

Authentication Setup

Minimax uses a dual-key authentication system: an API Key and a Secret Key. This differs from the single-key standard seen in OpenAI, Anthropic, and most OpenAI-compatible services. You must include both keys in your HTTP headers for every request.

  • X-API-Key: Your public API identifier.
  • X-Secret-Key: Your private secret identifier.

Store these securely in your environment variables. Unlike single-key systems, losing either key breaks authentication. Some providers, like the openainsfw.com API, simplify this by using a single Authorization: Bearer header, which aligns directly with the official OpenAI Python and Node.js SDKs. If you value a straightforward authentication setup that works out-of-the-box with standard SDKs, an OpenAI-compatible endpoint may reduce boilerplate code.

Configuring the Client

To integrate Minimax, you typically initialize a client object with your keys. Since Minimax does not use the OpenAI base URL structure, you cannot simply swap the base URL in an OpenAI SDK instance. You must use Minimax’s specific SDK or configure a generic HTTP client with the correct headers.

For example, in Python, you might use the minimax-python library. In Node.js, you would use minimax-node. These libraries handle the dual-key authentication and endpoint routing. If you want to use a single SDK for multiple providers, you need an abstraction layer that maps Minimax’s parameters to your code’s expectations.

from openai import OpenAI

client = OpenAI(base_url="https://api.openainsfw.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)

Consider the trade-off: using native SDKs gives you access to Minimax-specific features but locks you into their ecosystem. Using an OpenAI-compatible API allows you to keep your existing codebase while swapping the backend model. This is particularly useful if you need uncensored outputs or specific pricing structures that Minimax does not offer.

Making the First Request

A typical text generation request to Minimax involves specifying the model ID, user messages, and generation parameters. Minimax models often require a specific message format, including system prompts and user inputs.

Here is a conceptual example of a request structure:

  • Model: Specify the exact model ID (e.g., minimax-01).
  • Messages: An array of role-based content objects.
  • Parameters: Temperature, top_p, and stop sequences.

curl https://api.openainsfw.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Write a blunt product review of a cheap VPN."}]
  }'

When sending requests, ensure you handle the response structure correctly. Minimax responses may include usage statistics that differ from OpenAI’s usage object. Always check the documentation for the exact response schema. If you are building a chat interface, ensure your client handles the streaming response format if available, as not all Minimax endpoints support streaming by default.

Parsing Responses

Minimax returns JSON responses that include the generated text, usage statistics, and potentially finish reasons. Unlike OpenAI’s standardized response format, Minimax may include additional metadata specific to its models.

When parsing responses, extract the content field from the first assistant message. Be prepared for variations in the response structure, especially if you are using different model types (text vs. image). Image responses may return URLs or base64-encoded data, requiring different handling logic.

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.openainsfw.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);

If you are using an OpenAI-compatible API, the response format will match OpenAI’s schema exactly. This consistency simplifies parsing logic across different providers. For developers who want to avoid custom parsing code, an OpenAI-compatible endpoint ensures that your existing response parsers work without modification.

Handling Errors

Minimax returns standard HTTP status codes for errors. Common errors include 401 for authentication issues, 429 for rate limits, and 500 for server errors. Unlike some providers, Minimax may include detailed error messages in the response body, which can help debug issues quickly.

Implement robust error handling in your client. Retries with exponential backoff are recommended for 429 and 500 errors. For authentication errors, verify that both the API Key and Secret Key are correct and not expired.

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)

Consider the cost of errors. Some providers charge for tokens even in error responses, while others do not. Minimax’s pricing policy should be checked for error token charges. In contrast, the openainsfw.com API charges only for real token usage, meaning errors and refusals are free, which can reduce costs for experimental or high-failure-rate workflows.

Optimizing Performance

To optimize performance with the Minimax API, consider the following strategies:

  • Batch Requests: If supported, batch multiple queries to reduce latency.
  • Caching: Cache frequent responses to reduce API calls and costs.
  • Stream Responses: Use streaming for chat interfaces to improve perceived latency.

Monitor your token usage closely. Minimax’s token counting may differ from other providers, so track usage accurately. For long-context applications, ensure your context window limits are respected to avoid truncation errors.

If performance is critical, an OpenAI-compatible API may offer more predictable latency and caching strategies due to their widespread adoption. The standardization of the OpenAI format allows for better tooling support, such as automated retry libraries and monitoring dashboards.

Common Use Cases

The Minimax API is well-suited for:

  • Content Generation: Writing articles, stories, and scripts with high creativity.
  • Code Assistance: Generating and debugging code snippets.
  • Multimodal Workflows: Combining text and image generation for rich media applications.

However, if you need uncensored outputs for adult content or unrestricted creative writing, Minimax may apply content filters. The openainsfw.com API provides a dedicated uncensored model that does not refuse lawful adult content, making it a better fit for specific creative or adult-oriented applications.

For developers who need a simple, predictable API with transparent pricing, Minimax is a strong choice. For those who need flexibility in model routing or uncensored outputs, an OpenAI-compatible alternative may offer more control.

Next Steps

To get started with the Minimax API:

  1. Sign up for a Minimax account and generate your API and Secret keys.
  2. Install the Minimax SDK for your preferred language.
  3. Configure your client with the keys and test a basic text generation request.
  4. Monitor your usage and adjust parameters for optimal performance.

Consider experimenting with an OpenAI-compatible API like openainsfw.com if you want to compare performance, pricing, or content filtering. By testing both, you can choose the best fit for your application’s needs.

Remember to check the official Minimax documentation for the latest updates on models, pricing, and features.

Questions and answers

Does Minimax support streaming?

Yes, Minimax supports streaming for text generation endpoints, allowing you to receive responses token-by-token. This is useful for chat interfaces where real-time updates are needed. However, not all endpoints, such as image generation, support streaming.

How does Minimax pricing compare to OpenAI?

Minimax pricing is token-based, with different rates for input and output tokens. Image models often have fixed pricing per image. OpenAI’s pricing is also token-based but may have different rates. Always calculate costs based on your specific usage patterns, as token counts can vary between models.

Can I use Minimax with OpenAI SDKs?

Not directly, as Minimax uses a different base URL and authentication structure. You would need to use Minimax’s native SDK or an abstraction layer that maps Minimax’s parameters to the OpenAI format. For easy integration, an OpenAI-compatible API allows you to use standard SDKs without modification.

Is Minimax uncensored?

Minimax applies content filters similar to other major providers. If you need an uncensored model for adult content or unrestricted creative writing, consider an API like openainsfw.com, which is designed to not refuse lawful adult topics.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API key