MiniMax API Keys & Auth: Getting Started (Video Generation Basics)

# minimax# ai# api# python
MiniMax API Keys & Auth: Getting Started (Video Generation Basics)karleeov

How MiniMax API authentication works — Bearer tokens, regional base URLs, and the create → poll → download async flow you need before generating your first AI video.

Before you generate a single frame with MiniMax, you need to understand how the API authenticates, where it lives, and why everything is asynchronous. This is the foundation — the same material from the first module of my MiniMax AI generation course.

Lesson 1 — API Keys & Authentication

The API key

Grab your key from the MiniMax Platform. Treat it like a password — never hardcode it, never commit it.

export MINIMAX_API_KEY="your-api-key"
Enter fullscreen mode Exit fullscreen mode

Bearer token auth

Every request sends the key as a Bearer token in the Authorization header:

import os

headers = {
    "Authorization": f"Bearer {os.environ['MINIMAX_API_KEY']}",
    "Content-Type": "application/json",
}
Enter fullscreen mode Exit fullscreen mode

🔒 DevKing rule: load secrets from the environment. If you ever paste a key straight into source, delete it from history and rotate it immediately.

Pick your base URL

Region Base URL
Mainland China https://api.minimaxi.com
Overseas / International https://api.minimax.io

All examples below use the China endpoint (api.minimaxi.com). Swap it out if you're on the international plan.

Lesson 2 — Endpoints & the Async Model

Video generation is not instant — it's a background job. Understand this loop and everything else is trivial.

The three-step flow

1. Create task   →  POST /v1/video_generation        → returns task_id
2. Poll status   →  GET  /v1/query/video_generation  → returns status + file_id
3. Get download  →  GET  /v1/files/retrieve           → returns download_url
Enter fullscreen mode Exit fullscreen mode

Status lifecycle

Preparing → Queueing → Processing → Success ✅  (or Fail ❌)
Enter fullscreen mode Exit fullscreen mode

The polling loop

import time, requests

API_BASE = "https://api.minimaxi.com/v1"

def poll_until_done(task_id):
    while True:
        data = requests.get(
            f"{API_BASE}/query/video_generation",
            headers=headers,
            params={"task_id": task_id},
        ).json()
        status = data["status"]
        if status == "Success":
            return data["file_id"]
        if status == "Fail":
            raise RuntimeError(f"Generation failed: {data}")
        print(f"Waiting... {status}")
        time.sleep(10)  # recommended interval
Enter fullscreen mode Exit fullscreen mode

Key limits to remember

  • Download URLs expire in 1 hour.
  • Recommended polling interval: 10 seconds.
  • Video prompts: max 2,000 chars. Image prompts: max 1,500 chars.

Checklist

  • [ ] API key set as an environment variable
  • [ ] headers dict with Bearer token
  • [ ] Correct base URL for your region
  • [ ] You can explain the create → poll → download flow

Next up in the course: text-to-video generation. Follow along and I'll publish each module as a post.


Connect

If this kind of post is useful, the easiest way to support the work is to: