# ViMax Production Deployment: Required Environment Variables and Configuration Settings

> Deploy ViMax in production by configuring API credentials, environment variables like MINIMAX_API_KEY, and essential rate limits for stable multi-agent orchestration.

- Repository: [✨Data Intelligence Lab@HKU✨/ViMax](https://github.com/HKUDS/ViMax)
- Tags: how-to-guide
- Published: 2026-05-20

---

**To deploy ViMax in production, you must configure API credentials for chat, image, and video generation services in YAML configuration files, export `MINIMAX_API_KEY` when using the MiniMax provider, and define rate limits and working directories for stable multi-agent orchestration.**

ViMax is a multi-agent video generation framework developed by HKUDS that orchestrates external LLM, image generation, and video generation services. Proper configuration of environmental variables and YAML settings ensures secure credential management and reliable operation in production environments.

## Core Configuration Components

ViMax requires three primary service configurations defined in [`configs/idea2video.yaml`](https://github.com/HKUDS/ViMax/blob/main/configs/idea2video.yaml) or [`configs/script2video.yaml`](https://github.com/HKUDS/ViMax/blob/main/configs/script2video.yaml):

- **Chat model**: Requires `model_provider` (e.g., `openai` or `minimax`), `model`, `api_key`, and `base_url` under `chat_model.init_args`
- **Image generator**: Requires `api_key` under `image_generator.init_args` (class path such as `tools.ImageGeneratorNanobananaGoogleAPI`)
- **Video generator**: Requires `api_key` under `video_generator.init_args` (class path such as `tools.VideoGeneratorVeoGoogleAPI`)

Additionally, you must specify a `working_dir` path for temporary assets and final output storage.

## Environment Variable Integration

ViMax supports environment-based credential injection specifically for the MiniMax provider. In [`utils/provider_presets.py`](https://github.com/HKUDS/ViMax/blob/main/utils/provider_presets.py), the preset defines:

```python
PROVIDER_PRESETS["minimax"]["env_key"] = "MINIMAX_API_KEY"

```

When `model_provider: minimax` is configured, the `resolve_chat_model_config` function (lines 35–88 in [`utils/provider_presets.py`](https://github.com/HKUDS/ViMax/blob/main/utils/provider_presets.py)) automatically reads `MINIMAX_API_KEY` from the environment if `api_key` is omitted in the YAML file.

Export the variable before starting the service:

```bash
export MINIMAX_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx

```

## Production YAML Configuration Structure

A production-ready configuration file (e.g., [`configs/idea2video.yaml`](https://github.com/HKUDS/ViMax/blob/main/configs/idea2video.yaml)) contains structured initialization arguments for each service component.

### Chat Model Settings

The chat model configuration specifies the LLM backend and authentication:

```yaml
chat_model:
  init_args:
    model: google/gemini-2.5-flash-lite-preview-09-2025
    model_provider: openai
    api_key: <YOUR_API_KEY>
    base_url: https://openrouter.ai/api/v1
  max_requests_per_minute: 500
  max_requests_per_day: 2000

```

Replace `<YOUR_API_KEY>` with your actual API credentials or leave empty for MiniMax environment variable resolution.

### Image and Video Generator Settings

Configure media generation tools with class paths and authentication:

```yaml
image_generator:
  class_path: tools.ImageGeneratorNanobananaGoogleAPI
  init_args:
    api_key: <YOUR_API_KEY>
  max_requests_per_minute: 10
  max_requests_per_day: 500

video_generator:
  class_path: tools.VideoGeneratorVeoGoogleAPI
  init_args:
    api_key: <YOUR_API_KEY>
  max_requests_per_minute: 2
  max_requests_per_day: 10

```

### Rate Limiting and Working Directory

Control external API usage and define asset storage:

```yaml
working_dir: .working_dir/idea2video

```

Set `max_requests_per_minute` and `max_requests_per_day` to match your external provider quotas, or use `null` to disable throttling.

## MiniMax Provider Configuration

When deploying with MiniMax, the `resolve_chat_model_config` function transforms the configuration automatically:

1. Sets `model_provider` to `"openai"` for LangChain compatibility
2. Injects `base_url: https://api.minimax.io/v1`
3. Pulls `MINIMAX_API_KEY` from the environment if `api_key` is empty
4. Applies default model `MiniMax-M2.7` and clamps temperature values

Example MiniMax configuration:

```yaml
chat_model:
  init_args:
    model: MiniMax-M2.7
    model_provider: minimax
    api_key:  # Omitted; uses MINIMAX_API_KEY environment variable

```

## Runtime Configuration Examples

### Loading and Overriding Configuration in Python

Override API keys programmatically when integrating with secret managers:

```python
import yaml
import os
from utils.provider_presets import resolve_chat_model_config

with open("configs/idea2video.yaml") as f:
    cfg = yaml.safe_load(f)

# Override from environment or secret manager

cfg["chat_model"]["init_args"]["api_key"] = os.getenv("OPENAI_API_KEY")

chat_args = resolve_chat_model_config(cfg["chat_model"]["init_args"])

```

### Starting the Production Pipeline

Execute the pipeline with your configured YAML:

```bash
uv run python main_idea2video.py

```

The pipeline loader in [`pipelines/idea2video_pipeline.py`](https://github.com/HKUDS/ViMax/blob/main/pipelines/idea2video_pipeline.py) validates the configuration and initializes the backend via [`tools/render_backend.py`](https://github.com/HKUDS/ViMax/blob/main/tools/render_backend.py).

## Summary

- **Configuration files**: Edit [`configs/idea2video.yaml`](https://github.com/HKUDS/ViMax/blob/main/configs/idea2video.yaml) or [`configs/script2video.yaml`](https://github.com/HKUDS/ViMax/blob/main/configs/script2video.yaml) to define chat, image, and video service credentials
- **MiniMax deployment**: Export `MINIMAX_API_KEY` environment variable instead of hardcoding credentials in YAML files
- **Rate limiting**: Set `max_requests_per_minute` and `max_requests_per_day` to prevent quota exhaustion
- **Working directory**: Specify a persistent `working_dir` path for intermediate assets and final outputs
- **Environment resolution**: The `resolve_chat_model_config` function in [`utils/provider_presets.py`](https://github.com/HKUDS/ViMax/blob/main/utils/provider_presets.py) handles MiniMax-specific transformations and credential injection

## Frequently Asked Questions

### What environment variables does ViMax require?

ViMax strictly requires the `MINIMAX_API_KEY` environment variable only when using the MiniMax chat model provider without hardcoding the API key in the YAML configuration. All other service credentials (OpenAI, Google, etc.) must be configured directly in the [`configs/idea2video.yaml`](https://github.com/HKUDS/ViMax/blob/main/configs/idea2video.yaml) file via the `api_key` fields.

### How does ViMax handle MiniMax API authentication?

When `model_provider: minimax` is set in the configuration, the `resolve_chat_model_config` function in [`utils/provider_presets.py`](https://github.com/HKUDS/ViMax/blob/main/utils/provider_presets.py) automatically reads the `MINIMAX_API_KEY` environment variable if the `api_key` field is empty. It also injects the correct base URL (`https://api.minimax.io/v1`) and converts the provider type to `"openai"` for LangChain compatibility.

### Where do I configure rate limits for external APIs?

Rate limits are configured in the YAML configuration files ([`configs/idea2video.yaml`](https://github.com/HKUDS/ViMax/blob/main/configs/idea2video.yaml) or [`configs/script2video.yaml`](https://github.com/HKUDS/ViMax/blob/main/configs/script2video.yaml)) under each service section. Use the keys `max_requests_per_minute` and `max_requests_per_day` at the same level as `init_args` for the chat model, image generator, and video generator components.

### Can I override configuration settings programmatically?

Yes. You can load the YAML configuration using Python's `yaml` module, modify the dictionary values (such as injecting API keys from a secret manager), and then pass the modified configuration to `resolve_chat_model_config` before initializing the pipeline in [`pipelines/idea2video_pipeline.py`](https://github.com/HKUDS/ViMax/blob/main/pipelines/idea2video_pipeline.py).