How to Integrate MoneyPrinterTurbo with Pixabay API: Complete Configuration Guide
MoneyPrinterTurbo includes native Pixabay API support that activates automatically once you configure your API key and set the video source to "pixabay", enabling automatic retrieval of royalty-free video clips.
MoneyPrinterTurbo streamlines automated video generation by integrating directly with Pixabay's extensive library of royalty-free footage. By configuring the Pixabay API integration, you enable the application to automatically search, filter, and download relevant video clips that match your generated scripts. This guide covers the complete integration process using both the configuration file and Streamlit UI, with references to the specific implementation details found in the MoneyPrinterTurbo source code.
Step 1: Obtain Your Pixabay API Key
Before configuring MoneyPrinterTurbo, you must generate a Pixabay API key:
- Visit the Pixabay API documentation and create a free account.
- Navigate to your account settings and copy your API key.
- Store this key securely—you'll need it for the next configuration step.
Pixabay offers generous rate limits for free accounts, making it ideal for automated video generation workflows.
Step 2: Configure the API Key in MoneyPrinterTurbo
MoneyPrinterTurbo retrieves your Pixabay credentials through the pixabay_api_keys configuration parameter. According to app/services/material.py (lines 17-31), the system calls get_api_key("pixabay_api_keys") to retrieve credentials when initializing searches.
Option A: Using config.toml
Copy the example configuration file and add your key:
# config.toml (copied from config.example.toml)
pixabay_api_keys = "YOUR_PIXABAY_API_KEY"
The application loads this value at startup via app/config.py. You can also specify multiple keys separated by commas to enable automatic rotation.
Option B: Using the Streamlit UI
For users running the web interface:
- Launch the application:
streamlit run webui/Main.py. - Expand Video Source Settings in the sidebar.
- Paste your key into the Pixabay API Key field (implemented in
webui/Main.py, lines 75-79). - Click Save to persist the configuration.
The UI mirrors the configuration file settings and stores the key for subsequent API calls.
Step 3: Select Pixabay as Your Video Source
After configuring your API key, specify Pixabay as the video provider:
- Via UI: Select Pixabay from the Video Source dropdown menu.
- Via configuration: Set
video_source = "pixabay"in yourconfig.toml.
When you initiate video generation, MoneyPrinterTurbo invokes the download pipeline. The source selection logic in webui/Main.py (lines 1001-1012) routes requests to the Pixabay-specific downloader when this setting is active.
How the Pixabay Integration Works (Source Code Deep Dive)
Understanding the internal implementation helps troubleshoot integration issues and optimize your workflow.
The Search Implementation
The core Pixabay search logic resides in app/services/material.py (lines 91-138) within the search_videos_pixabay() function:
- Authentication: The function retrieves your stored key using
get_api_key("pixabay_api_keys"). - Request Construction: It builds the endpoint URL
https://pixabay.com/api/videos/with your search terms and API key as query parameters (lines 100-108). - Response Processing: The function parses the JSON response, filters results by minimum duration requirements, and instantiates
MaterialInfoobjects with theproviderfield set to"pixabay"(lines 121-138).
Video Download Pipeline
Once search results are returned, the download_videos() function handles the actual file retrieval. According to webui/Main.py (lines 1001-1012), the system:
- Validates the selected video source.
- Calls the appropriate search function based on the
sourceparameter. - Downloads matching videos to your configured
material_directory(default:cache_videos). - Caches files to avoid redundant API calls for identical search terms.
Programmatic Usage Example
You can trigger Pixabay video downloads directly from Python without using the UI:
from app.services.material import download_videos
from app.models.schema import VideoAspect, VideoConcatMode
# Download videos matching "city skyline" from Pixabay
video_paths = download_videos(
task_id="demo_task",
search_terms=["city skyline"],
source="pixabay", # Specify Pixabay as the source
video_aspect=VideoAspect.landscape, # Options: landscape, portrait
video_concat_mode=VideoConcatMode.random,
audio_duration=120, # Match video length to audio (seconds)
max_clip_duration=10, # Maximum clip length per segment
)
print(f"Downloaded {len(video_paths)} videos: {video_paths}")
This code invokes search_videos_pixabay() internally, which executes the API call using your configured credentials and returns local file paths to the downloaded MP4 files.
Summary
- MoneyPrinterTurbo includes native Pixabay support through the
search_videos_pixabay()function inapp/services/material.py. - Configuration requires only your API key added to
pixabay_api_keysinconfig.tomlor the Streamlit UI (lines 75-79 ofwebui/Main.py). - Automatic key rotation is supported if you provide multiple API keys separated by commas.
- Source selection triggers the Pixabay pipeline when set to
"pixabay"(handled inwebui/Main.py, lines 1001-1012). - Downloaded videos are cached in your configured
material_directoryto optimize repeated generations.
Frequently Asked Questions
Can I use multiple Pixabay API keys with MoneyPrinterTurbo?
Yes. The pixabay_api_keys configuration parameter accepts comma-separated values (e.g., "key1,key2,key3"). According to the implementation in app/services/material.py (lines 17-31), the application automatically rotates through available keys when making requests to the https://pixabay.com/api/videos/ endpoint, helping distribute rate limits across multiple accounts.
Where does MoneyPrinterTurbo store downloaded Pixabay videos?
Downloaded files are stored in the directory specified by material_directory in your config.toml file, defaulting to cache_videos in the project root. The download_videos() function manages this caching automatically, reusing existing files when search terms match previously downloaded content to minimize redundant API calls.
What happens if the Pixabay API returns no results for my search terms?
If search_videos_pixabay() returns an empty list after filtering (lines 121-138 of app/services/material.py), the application logs a warning and either skips the video segment or falls back to alternative sources if configured. Ensure your search terms are generic enough to match Pixabay's video library, as highly specific phrases may yield limited results.
Is there a way to filter Pixabay videos by duration or aspect ratio?
Yes. The search_videos_pixabay() function filters API results by minimum duration before returning MaterialInfo objects (lines 121-138). Additionally, you can specify video_aspect (landscape or portrait) and max_clip_duration parameters when calling download_videos(), which further refines the selection during the download phase according to your project requirements.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →