MiniMaxCoding Start Free

Integration Guides

Step-by-step tutorials to integrate MiniMax into your workflow

🤖 Integrate with OpenClaw

Add AI code generation to your OpenClaw agent workflows

OpenClaw is an AI assistant framework. Integrate MiniMax to give your agents code-writing capabilities.

Step 1: Install MiniMax SDK

pip install minimax-code

Step 2: Create OpenClaw Tool

# tools/minimax_code.py
from minimax_code import MiniMaxCode
import os

class MiniMaxCodeTool:
    def __init__(self):
        self.client = MiniMaxCode(api_key=os.getenv("MINIMAX_API_KEY"))
    
    def generate_code(self, prompt: str, language: str = "python") -> str:
        """Generate code from a text prompt."""
        result = self.client.complete(
            code=prompt,
            language=language
        )
        return result.suggestion
    
    def review_code(self, code: str) -> dict:
        """Review code for bugs and issues."""
        result = self.client.review(code=code, language="python")
        return result.issues

# Register as OpenClaw tool
tool = MiniMaxCodeTool()

Step 3: Configure in OpenClaw

# openclaw.yaml
tools:
  - name: minimax_code
    enabled: true
    config:
      api_key: ${MINIMAX_API_KEY}
      default_language: python
      max_tokens: 2048

# Use in your agent prompts
prompt: |
  You have access to the MiniMax Code tool.
  When user asks to write code, use the minimax_code.generate_code function.

Step 4: Set Environment Variable

# Add to your .env file
MINIMAX_API_KEY=your_api_key_here

💡 Pro Tip: Add code generation to any OpenClaw workflow by calling the MiniMax API in your tool definitions.

💙 Integrate with VS Code

Build a custom VS Code extension with MiniMax

Step 1: Create VS Code Extension Project

npm init -y
npm install vscode @types/vscode axios

Step 2: Create Extension Entry Point

// extension.ts
import * as vscode from 'vscode';
import axios from 'axios';

const API_KEY = process.env.MINIMAX_API_KEY;

export function activate(context: vscode.ExtensionContext) {
    // Register AI Code Completion command
    const completeCommand = vscode.commands.registerCommand(
        'minimax.complete',
        async () => {
            const editor = vscode.window.activeTextEditor;
            if (!editor) return;
            
            const document = editor.document;
            const position = editor.selection.active;
            const text = document.getText();
            
            // Get current line context
            const line = document.lineAt(position.line).text;
            
            const response = await axios.post(
                'https://api.minimax.io/v1/code/complete',
                {
                    code: line,
                    language: getLanguageId(document.languageId)
                },
                { headers: { Authorization: \`Bearer \${API_KEY}\` }}
            );
            
            if (response.data.suggestion) {
                await editor.edit(insertBuilder => {
                    insertBuilder.insert(position, response.data.suggestion);
                });
            }
        }
    );
    
    context.subscriptions.push(completeCommand);
}

function getLanguageId(lang: string): string {
    const map: Record = {
        'python': 'python',
        'javascript': 'javascript',
        'typescript': 'typescript',
        'go': 'go',
        'rust': 'rust'
    };
    return map[lang] || 'python';
}

Step 3: Add Keybindings

// keybindings.json
[
    {
        "key": "ctrl+shift+a",
        "command": "minimax.complete",
        "when": "editorTextFocus"
    }
]

Step 4: Package and Install

vsce package
code --install-extension minimax-ai-1.0.0.vsix

🐙 Integrate with GitHub Actions

Add AI code review to your CI/CD pipeline

Create GitHub Action for Code Review

# .github/workflows/ai-code-review.yml
name: AI Code Review

on:
  pull_request:
    branches: [main, develop]

jobs:
  ai-review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'
      
      - name: Install MiniMax SDK
        run: pip install minimax-code github-sdk
      
      - name: Run AI Code Review
        env:
          MINIMAX_API_KEY: ${{ secrets.MINIMAX_API_KEY }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          python << 'EOF'
          import os
          import github
          from minimax_code import MiniMaxCode
          
          client = MiniMaxCode(api_key=os.getenv("MINIMAX_API_KEY"))
          gh = github.Github(os.getenv("GITHUB_TOKEN"))
          
          # Get PR diff
          pr = gh.get_pull(...)
          
          for file in pr.get_files():
              # Analyze each changed file
              issues = client.review(
                  code=file.patch,
                  language=detect_language(file.filename)
              )
              
              if issues:
                  pr.create_review_comment(
                      body=f"🤖 AI Review: {issues}",
                      commit_id=file.commit_id,
                      path=file.filename
                  )
          EOF

Add API Key Secret

  1. Go to your GitHub repo → Settings → Secrets
  2. Click "New repository secret"
  3. Name: MINIMAX_API_KEY
  4. Value: Your MiniMax API key

🔧 Integrate with Jenkins

Add automated code review to Jenkins pipelines

Jenkinsfile Example

// Jenkinsfile
pipeline {
    agent any
    
    environment {
        MINIMAX_API_KEY = credentials('minimax-api-key')
    }
    
    stages {
        stage('AI Code Scan') {
            steps {
                sh '''
                pip install minimax-code
                
                python3 << 'PYEOF'
                import os
                import glob
                from minimax_code import MiniMaxCode
                
                client = MiniMaxCode(api_key=os.environ["MINIMAX_API_KEY"])
                
                # Scan all Python files
                for file in glob.glob("**/*.py"):
                    with open(file) as f:
                        code = f.read()
                        issues = client.review(code=code, language="python")
                        
                        if issues:
                            print(f"⚠️ {file}: {len(issues)} issues found")
                            for issue in issues:
                                print(f"  - {issue}")
                PYEOF
                '''
            }
        }
    }
    
    post {
        always {
            cleanWs()
        }
    }
}

🐍 Python Integration

Complete Python SDK documentation

Installation

pip install minimax-code

Code Completion

from minimax_code import MiniMaxCode

client = MiniMaxCode(api_key="YOUR_API_KEY")

# Complete partial code
result = client.complete(
    code="def fibonacci(n):",
    language="python"
)
print(result.suggestion)
# Output: 
#     if n <= 1:
#         return n
#     return fibonacci(n-1) + fibonacci(n-2)

Code Generation from Prompt

# Generate code from description
result = client.generate(
    prompt="Create a function that validates email addresses using regex",
    language="python"
)
print(result.code)

Bug Detection

# Find bugs in code
code = """
def divide(a, b):
    return a / b
"""

result = client.review(code=code, language="python")
for issue in result.issues:
    print(f"Line {issue.line}: {issue.type} - {issue.message}")
# Output: Line 2: Warning - Potential division by zero

Generate Tests

# Auto-generate tests
result = client.generate_tests(
    code=existing_code,
    language="python",
    framework="pytest"
)
print(result.tests)

📦 Node.js Integration

Complete JavaScript/TypeScript SDK

Installation

npm install minimax-code

Basic Usage

const { MiniMaxCode } = require('minimax-code');

const client = new MiniMaxCode({ 
  apiKey: process.env.MINIMAX_API_KEY 
});

// Code completion
const completion = await client.complete({
  code: 'const fibonacci = (n) => {',
  language: 'javascript'
});
console.log(completion.suggestion);

// Code review
const review = await client.review({
  code: `function add(a, b) { return a + b; }`,
  language: 'javascript'
});
console.log(review.issues);

TypeScript Support

import { MiniMaxCode } from 'minimax-code';

const client = new MiniMaxCode({ 
  apiKey: process.env.MINIMAX_API_KEY 
});

// Full TypeScript support
const result = await client.complete({
  code: 'const processData = (data: string[]): number => {',
  language: 'typescript'
});

⌨️ CLI Tools

Use MiniMax from the command line

Install CLI

pip install minimax-code-cli

# Or via npm
npm install -g minimax-cli

Commands

# Complete code
minimax complete "def hello_world():" --lang python

# Review code file
minimax review app.py

# Generate from prompt
minimax generate "create a REST API endpoint" --lang python

# Explain code
minimax explain app.py

Add to Shell Profile

# ~/.bashrc or ~/.zshrc
alias ai="minimax"

# Usage
ai complete "function add("

🔗 Webhook Integration

Trigger AI code review from any webhook

Receive Webhooks and Respond

# webhook_server.py
from flask import Flask, request, jsonify
from minimax_code import MiniMaxCode

app = Flask(__name__)
client = MiniMaxCode(api_key="YOUR_API_KEY")

@app.route('/webhook/code-review', methods=['POST'])
def code_review():
    data = request.json
    
    code = data.get('code')
    language = data.get('language', 'python')
    
    result = client.review(code=code, language=language)
    
    return jsonify({
        'issues': result.issues,
        'suggestions': result.suggestions
    })

@app.route('/webhook/generate', methods=['POST'])
def generate_code():
    data = request.json
    
    prompt = data.get('prompt')
    language = data.get('language', 'python')
    
    result = client.generate(prompt=prompt, language=language)
    
    return jsonify({
        'code': result.code
    })

if __name__ == '__main__':
    app.run(port=5000)

Configure Webhook URL

# In your GitHub repo settings:
# Webhook URL: https://your-server.com/webhook/code-review

# Payload would be:
{
  "code": "def calculate(): pass",
  "language": "python"
}

Ready to Integrate?

Get your API key and start building.

Get API Key →