EN ▾
Start now

MiniMax AI API Key Setup: A Working Text Alternative

A minimax ai api key setup usually means one thing: you want a text endpoint that answers requests today. This page shows how to get a key for a hosted, OpenAI-compatible API and send a first request. It is not MiniMax's official API.

Last updated

A glowing key entering a lock on a server panel, with data flowing to a terminal

Summary

  • This service is an independent, OpenAI-compatible text API with the model ID uncensored, not a MiniMax product.
  • Sign up, claim the $0.50 trial on the key page, and you can call the API without entering payment details.
  • Change two settings in any OpenAI SDK: the base URL and the key.
  • Keep the key in an environment variable and rotate it from the key page if it leaks.

What this setup gives you, and what it does not

Say it plainly first: a minimax ai api key setup on this site does not give you access to MiniMax's own models. This is not the official API of MiniMax, and it is not a router across vendors. You get one open-weight model, run by an independent provider and tuned to answer without content refusals for lawful adult use. In your code its ID is uncensored.

If you need a key for MiniMax's own models, get it from MiniMax and check their current pricing and terms. If what you really need is a text endpoint that speaks the OpenAI protocol, has a 100,000-token context window and does not refuse ordinary adult fiction or edgy prompts, the steps below take about five minutes.

Two limits to know before you start. The API is text only, so there is no image, audio or video generation, no embeddings and no fine-tuning. And one rule is fixed: no sexual content involving minors, ever.

Step 1: create an account and get your key

Open the API key page and sign up with Google, or with an email and password. After sign-up you see your key on the same page.

New users can claim $0.50 of trial credit with one click on that page. It needs no payment details, it is valid for 7 days, and it is limited to one per person. A trial key runs at 2 concurrent requests and 60 requests per minute, which is plenty for testing.

When you want more headroom, top up with any whole amount from $20 to $500. Payment is in crypto (USDT on TRC20 or USDC on Base). Larger top-ups carry a bonus: +5% from $50, +10% from $100 and +15% from $200. A full key then allows 8 concurrent requests and 300 requests per minute. Credit never expires and there is no subscription.

Step 2: store the key as an environment variable

Do not paste the key into source files. Put it in an environment variable and read it at runtime.

export API_KEY="paste-your-key-here"

On Windows PowerShell the equivalent is $env:API_KEY = "paste-your-key-here". For a project, a .env file that is listed in .gitignore works just as well.

If the key ever ends up in a public repo or a chat log, go back to the key page and regenerate it. The old key stops working at once, and you do not need to contact support. Accounts that have topped up can hold up to 5 keys with labels, so you can give each app its own key and revoke one without touching the rest.

Step 3: send your first request

Any OpenAI SDK works once you change the base URL and the key. The base URL for this site is https://api.minimaxaiapi.com/v1, the model is uncensored, and auth is a standard Authorization: Bearer header, which the SDKs add for you.

Python

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.minimaxaiapi.com/v1",
    api_key=os.environ["API_KEY"],
)

resp = client.chat.completions.create(
    model="uncensored",
    messages=[
        {"role": "system", "content": "You are a concise writing assistant."},
        {"role": "user", "content": "Write a four-line opening for a noir short story."},
    ],
)
print(resp.choices[0].message.content)

Node.js

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: "Give me three names for a fantasy tavern." }],
});
console.log(resp.choices[0].message.content);

curl

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":"Say hello in one sentence."}]}'

The same API also exposes POST /v1/responses and GET /v1/models. The docs page lists every method with examples.

Turn on streaming, JSON mode or tools

The first request is a plain call. Real apps usually need one of three extras, and all of them are passed straight through.

  • Streaming. Add stream: true and read server-sent events. Usage is reported at the end of the stream.
  • JSON mode. Set response_format to {"type":"json_object"} and say in the prompt that you want JSON.
  • Tool calling. Send tools and tool_choice, read tool_calls from the reply, and return results as messages with role: "tool".
stream = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Describe a rainy harbor town in 80 words."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Sampling controls such as temperature, top_p, stop, seed and the frequency and presence penalties are accepted too. Output length defaults to the rest of the 100,000-token window, so max_tokens is optional. Set it anyway if you want a hard cap on spend.

Check your balance and limits

Every response carries an X-Balance-USD header with your remaining credit, and the rate-limit headers X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency. Each response also includes an X-Request-Id, which is worth logging so you can quote it if something looks wrong.

curl -i https://api.minimaxaiapi.com/v1/chat/completions   -H "Authorization: Bearer $API_KEY"   -H "Content-Type: application/json"   -d '{"model":"uncensored","max_tokens":5,"messages":[{"role":"user","content":"ping"}]}'

Look for X-Balance-USD in the response headers. You can also call GET /v1/balance, or the OpenAI-style GET /v1/dashboard/billing/credit_grants, if you prefer a dedicated request.

Price is $0.15 per 1M input tokens and $0.50 per 1M output tokens. A request with 1,000 input tokens and 500 output tokens costs $0.00015 plus $0.00025, which is $0.0004. The $0.50 trial therefore covers roughly 1,250 requests of that size. Failed or refused requests are not charged. For a fuller breakdown see the pricing page.

Common setup mistakes

  • The base URL is missing /v1. Use https://api.minimaxaiapi.com/v1 exactly. The SDK appends /chat/completions itself.
  • The old vendor's model name is still in the code. Set model to uncensored. A model name from another provider will not match.
  • A shell that did not export the variable. If the SDK complains about a missing key, run echo $API_KEY in the same terminal.
  • Too many parallel calls. A trial key allows 2 at once. Over the limit you get HTTP 429 with the code rate_limited or concurrency. A streamed request holds its slot until the stream ends.

Looking for the pricing comparison instead? The existing article on MiniMax API pricing and the uncensored model covers that side in more detail.

Before you go to production

A first request proves the plumbing. A few habits keep it healthy once real users arrive.

  • Give each app its own key. Once your account has topped up you can hold up to 5 keys with labels. If a staging key leaks, you revoke that one and production keeps running.
  • Cap the output. Because the completion can use the rest of the 100,000-token window, a runaway generation can be long. A sensible max_tokens keeps the cost of a bad prompt small.
  • Retry politely. On a 429, wait and try again. If the response carries Retry-After: 5, the service is briefly overloaded and five seconds is the right pause. If the code is concurrency, you are sending too many parallel calls; lower your worker count instead of retrying faster.
  • Log the request ID. The X-Request-Id header makes any odd reply traceable.
  • Mind the body size. A request body can be up to 8 MB, which is far more than a normal prompt but can matter if you paste in large files.

On privacy: prompts are not used for training. That helps, but you should still avoid sending secrets or personal data that your own policies would not allow you to share with a third-party service.

Finally, remember the scope. This is a text API for chat, writing, roleplay and code. It does not generate images, audio or video, and it does not offer embeddings or fine-tuning. If your project needs those, pair it with a different service for that one job and keep this endpoint for text.

Frequently asked questions

Is this the official MiniMax API?

No. It is an independent, OpenAI-compatible text API with its own model ID, uncensored. It is not an API of MiniMax or any other model vendor.

Can I use my existing OpenAI client code?

Yes. Change the base URL to https://api.minimaxaiapi.com/v1, use your key and set the model to uncensored. Chat completions, streaming, tool calling and JSON mode work as in the OpenAI format.

Do I need to pay to try it?

No payment details are needed. After sign-up you can claim $0.50 of trial credit with one click on the API key page. It is valid for 7 days, one per person. Paid top-ups are in crypto.

What if my key leaks?

Regenerate it on the API key page. The old key stops working immediately, so no support ticket is needed.

Generate your key now

Register, retrieve your key, and update your endpoint URL. That is all you need to do.

Begin with free credit

Sign up with email and password; your key appears instantly.